/** * Get a matching DNS entry from the table. */ public synchronized DNSEntry get(String name, int type, int clazz) { for (CacheNode node = find(name); node != null; node = node.next) { if (node.value.type == type && node.value.clazz == clazz) { return node.value; } } return null; }
/** * List all entries for debugging. */ public synchronized void print() { for (Iterator i = iterator(); i.hasNext();) { for (CacheNode n = (CacheNode) i.next(); n != null; n = n.next) { System.out.println(n.value); } } }
/** * List cache entries, for debugging only. */ void print() { System.out.println("---- cache ----"); cache.print(); System.out.println(); }
cache.clear(); logger.finer("recover() All is clean");
updateRecord(jmdns, now, (DNSRecord) jmdns.getCache().get(server, DNSConstants.TYPE_A, DNSConstants.CLASS_IN));
aLog.append(cache.toString()); aLog.append("\n"); aLog.append("\t---- Service Collectors ----");
cache = new DNSCache(100);
/** * Does the necessary actions, when this as a response. */ boolean handleResponse(JmDNS dns) { DNSRecord.Address dnsAddress = dns.getLocalHost().getDNSAddressRecord(this); if (dnsAddress != null) { if (dnsAddress.sameType(this) && dnsAddress.sameName(this) && (!dnsAddress.sameValue(this))) { logger.finer("handleResponse() Denial detected"); if (dns.getState().isProbing()) { dns.getLocalHost().incrementHostName(); dns.getCache().clear(); for (Iterator i = dns.services.values().iterator(); i.hasNext();) { ServiceInfo info = (ServiceInfo) i.next(); info.revertState(); } } dns.revertState(); return true; } } return false; }
out.addAnswer((DNSRecord) cache.get(info.getQualifiedName(), DNSConstants.TYPE_SRV, DNSConstants.CLASS_IN), now); out.addAnswer((DNSRecord) cache.get(info.getQualifiedName(), DNSConstants.TYPE_TXT, DNSConstants.CLASS_IN), now); if (info.server != null) out.addAnswer((DNSRecord) cache.get(info.server, DNSConstants.TYPE_A, DNSConstants.CLASS_IN), now);
/** * Get a matching DNS entry from the table (using equals). * Returns the entry that was found. */ public synchronized DNSEntry get(DNSEntry entry) { for (CacheNode node = find(entry.getName()); node != null; node = node.next) { if (node.value.equals(entry)) { return node.value; } } return null; }
public synchronized String toString() { StringBuffer aLog = new StringBuffer(); aLog.append("\t---- cache ----"); for (Iterator i = iterator(); i.hasNext();) { for (CacheNode n = (CacheNode) i.next(); n != null; n = n.next) { aLog.append("\n\t\t" + n.value); } } return aLog.toString(); }
/** * Does the necessary actions, when this as a query. */ boolean handleQuery(JmDNS dns, long expirationTime) { DNSRecord.Address dnsAddress = dns.getLocalHost().getDNSAddressRecord(this); if (dnsAddress != null) { if (dnsAddress.sameType(this) && dnsAddress.sameName(this) && (!dnsAddress.sameValue(this))) { logger.finer("handleQuery() Conflicting probe detected. dns state " + dns.getState() + " lex compare " + lexCompare(dnsAddress)); // Tie-breaker test if (dns.getState().isProbing() && lexCompare(dnsAddress) >= 0) { // We lost the tie-break. We have to choose a different name. dns.getLocalHost().incrementHostName(); dns.getCache().clear(); for (Iterator i = dns.services.values().iterator(); i.hasNext();) { ServiceInfo info = (ServiceInfo) i.next(); info.revertState(); } } dns.revertState(); return true; } } return false; }
/** * Add a listener for a question. The listener will receive updates * of answers to the question as they arrive, or from the cache if they * are already available. */ void addListener(DNSListener listener, DNSQuestion question) { long now = System.currentTimeMillis(); // add the new listener synchronized (this) { listeners.add(listener); } // report existing matched records if (question != null) { for (DNSCache.CacheNode i = cache.find(question.name); i != null; i = i.next()) { DNSRecord c = (DNSRecord) i.getValue(); if (question.answeredBy(c) && !c.isExpired(now)) { listener.updateRecord(this, now, c); } } } }
for (Iterator i = cache.iterator(); i.hasNext();)
for (DNSCache.CacheNode j = cache.find(host.getName().toLowerCase()); j != null; j = j.next())
for (DNSCache.CacheNode j = cache.find(info.getQualifiedName().toLowerCase()); j != null; j = j.next())