feat: Add P2P Domain Conflicts management
Implement comprehensive P2P domain conflict resolution allowing users to choose between local claim hashes and consensus-resolved hashes for domains where they have local claims but another claimant won consensus. Key features: - P2P Domain Conflicts UI tab in Local DNS section - Hash preference toggle (local vs resolved) with automatic client restart - Extended selector_cache.json to store hashPreferences alongside versionPreferences - DNS cache invalidation for immediate preference application - REST API endpoints for conflict detection and preference management - Automatic Holesail client restart when hash preferences change - Complete documentation updates across README, API docs, and glossary Resolves conflicts between local claims and consensus resolution by giving users control over which hash their domain resolves to, with seamless client management ensuring immediate effect.
This commit is contained in:
@@ -51,6 +51,13 @@ function setCachedDNSResolution(domain, p2pHash, publicIP, ttl = DEFAULT_CACHE_T
|
||||
});
|
||||
}
|
||||
|
||||
function clearDNSCacheForDomain(domain) {
|
||||
if (dnsCache.has(domain)) {
|
||||
dnsCache.delete(domain);
|
||||
logDebug('DNS', `Cleared DNS cache for domain ${domain} due to hash preference change`);
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup old cache entries periodically
|
||||
let dnsCacheCleanupInterval = null;
|
||||
|
||||
@@ -222,6 +229,7 @@ async function handleDnsMessage(msg, rinfo) {
|
||||
logDebug('DNS', `Resolved hash for ${domain}: ${hash || 'null'}`);
|
||||
if (hash) {
|
||||
p2pRecord = { hash };
|
||||
logInfo('DNS', `Creating P2P record for ${domain} with hash: ${hash}`);
|
||||
}
|
||||
publicDNSResponse = await checkPublicDNS(query);
|
||||
|
||||
@@ -276,6 +284,7 @@ async function handleDnsMessage(msg, rinfo) {
|
||||
dnsServer.send(response, rinfo.port, rinfo.address);
|
||||
return;
|
||||
}
|
||||
logInfo('DNS', `Starting Holesail client for ${domain} with hash: ${p2pRecord.hash}`);
|
||||
await startHolesailClient(domain, p2pRecord.hash, localIP, state.internalPort);
|
||||
const responseTime = Date.now() - startTime;
|
||||
trackDNSQueryWithTiming('p2p', domain, responseTime);
|
||||
@@ -350,4 +359,4 @@ function closeDnsServer() {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { dnsServer, handleDnsMessage, bindDnsServer, closeDnsServer, stopDNSCacheCleanup };
|
||||
module.exports = { dnsServer, handleDnsMessage, bindDnsServer, closeDnsServer, stopDNSCacheCleanup, clearDNSCacheForDomain };
|
||||
Reference in New Issue
Block a user