/** * Get all matching DNS entries from the table. * * @param name * @param type * @param recordClass * @return list of entries */ public synchronized Collection<? extends DNSEntry> getDNSEntryList(String name, DNSRecordType type, DNSRecordClass recordClass) { Collection<? extends DNSEntry> entryList = this.getDNSEntryList(name); if (entryList != null) { entryList = new ArrayList<DNSEntry>(entryList); for (Iterator<? extends DNSEntry> i = entryList.iterator(); i.hasNext();) { DNSEntry testDNSEntry = i.next(); if (!testDNSEntry.getRecordType().equals(type) || ((DNSRecordClass.CLASS_ANY != recordClass) && !testDNSEntry.getRecordClass().equals(recordClass))) { i.remove(); } } } else { entryList = Collections.emptyList(); } return entryList; }
/** * Get a matching DNS entry from the table (using isSameEntry). Returns the entry that was found. * * @param dnsEntry * @return DNSEntry */ public synchronized DNSEntry getDNSEntry(DNSEntry dnsEntry) { DNSEntry result = null; if (dnsEntry != null) { Collection<? extends DNSEntry> entryList = this.getDNSEntryList(dnsEntry.getKey()); if (entryList != null) { for (DNSEntry testDNSEntry : entryList) { if (testDNSEntry.isSameEntry(dnsEntry)) { result = testDNSEntry; break; } } } } return result; }
/** * 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. * * @param listener * DSN listener * @param question * DNS query */ public void addListener(DNSListener listener, DNSQuestion question) { final long now = System.currentTimeMillis(); // add the new listener _listeners.add(listener); // report existing matched records if (question != null) { for (DNSEntry dnsEntry : this.getCache().getDNSEntryList(question.getName().toLowerCase())) { if (question.answeredBy(dnsEntry) && !dnsEntry.isExpired(now)) { listener.updateRecord(this.getCache(), now, dnsEntry); } } } }
/** * 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. * * @param listener * DSN listener * @param question * DNS query */ public void addListener(DNSListener listener, DNSQuestion question) { final long now = System.currentTimeMillis(); // add the new listener _listeners.add(listener); // report existing matched records if (question != null) { for (DNSEntry dnsEntry : this.getCache().getDNSEntryList(question.getName().toLowerCase())) { if (question.answeredBy(dnsEntry) && !dnsEntry.isExpired(now)) { listener.updateRecord(this.getCache(), now, dnsEntry); } } } }
/** * 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. * * @param listener * DSN listener * @param question * DNS query */ public void addListener(DNSListener listener, DNSQuestion question) { final long now = System.currentTimeMillis(); // add the new listener _listeners.add(listener); // report existing matched records if (question != null) { for (DNSEntry dnsEntry : this.getCache().getDNSEntryList(question.getName().toLowerCase())) { if (question.answeredBy(dnsEntry) && !dnsEntry.isExpired(now)) { listener.updateRecord(this.getCache(), now, dnsEntry); } } } }
/** * 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. * * @param listener * DSN listener * @param question * DNS query */ public void addListener(DNSListener listener, DNSQuestion question) { final long now = System.currentTimeMillis(); // add the new listener _listeners.add(listener); // report existing matched records if (question != null) { Collection<? extends DNSEntry> entryList = this.getCache().getDNSEntryList(question.getName().toLowerCase()); if (entryList != null) { synchronized (entryList) { for (DNSEntry dnsEntry : entryList) { if (question.answeredBy(dnsEntry) && !dnsEntry.isExpired(now)) { listener.updateRecord(this.getCache(), now, dnsEntry); } } } } } }
/** * Get a matching DNS entry from the table. * * @param name * @param type * @param recordClass * @return DNSEntry */ public synchronized DNSEntry getDNSEntry(String name, DNSRecordType type, DNSRecordClass recordClass) { DNSEntry result = null; Collection<? extends DNSEntry> entryList = this.getDNSEntryList(name); if (entryList != null) { for (DNSEntry testDNSEntry : entryList) { if (testDNSEntry.getRecordType().equals(type) && ((DNSRecordClass.CLASS_ANY == recordClass) || testDNSEntry.getRecordClass().equals(recordClass))) { result = testDNSEntry; break; } } } return result; }
_ipv4Addresses.clear(); _ipv6Addresses.clear(); for (final DNSEntry entry : dnsCache.getDNSEntryList(_server, DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN)) { this.updateRecord(dnsCache, now, entry); for (final DNSEntry entry : dnsCache.getDNSEntryList(_server, DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN)) { this.updateRecord(dnsCache, now, entry);
_ipv4Addresses.clear(); _ipv6Addresses.clear(); for (DNSEntry entry : dnsCache.getDNSEntryList(_server, DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN)) { this.updateRecord(dnsCache, now, entry); for (DNSEntry entry : dnsCache.getDNSEntryList(_server, DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN)) { this.updateRecord(dnsCache, now, entry);
@Override protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException { DNSOutgoing newOut = out; if (!_info.hasData()) { long now = System.currentTimeMillis(); newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN), now); newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN), now); if (_info.getServer().length() > 0) { for (DNSEntry addressEntry : this.getDns().getCache().getDNSEntryList(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN)) { newOut = this.addAnswer(newOut, (DNSRecord) addressEntry, now); } for (DNSEntry addressEntry : this.getDns().getCache().getDNSEntryList(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN)) { newOut = this.addAnswer(newOut, (DNSRecord) addressEntry, now); } } } return newOut; }
for (DNSEntry dnsEntry : this.getCache().getDNSEntryList(info.getKey())) { if (DNSRecordType.TYPE_SRV.equals(dnsEntry.getRecordType()) && !dnsEntry.isExpired(now)) { final DNSRecord.Service s = (DNSRecord.Service) dnsEntry;
for (DNSEntry dnsEntry : this.getCache().getDNSEntryList(info.getKey())) { if (DNSRecordType.TYPE_SRV.equals(dnsEntry.getRecordType()) && !dnsEntry.isExpired(now)) { final DNSRecord.Service s = (DNSRecord.Service) dnsEntry;
_ipv4Addresses.clear(); _ipv6Addresses.clear(); for (DNSEntry entry : dnsCache.getDNSEntryList(_server, DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN)) { this.updateRecord(dnsCache, now, entry); for (DNSEntry entry : dnsCache.getDNSEntryList(_server, DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN)) { this.updateRecord(dnsCache, now, entry);
Collection<? extends DNSEntry> entryList = this.getCache().getDNSEntryList(info.getKey()); if (entryList != null) { for (DNSEntry dnsEntry : entryList) {
for (DNSEntry dnsEntry : this.getCache().getDNSEntryList(info.getKey())) { if (DNSRecordType.TYPE_SRV.equals(dnsEntry.getRecordType()) && !dnsEntry.isExpired(now)) { final DNSRecord.Service s = (DNSRecord.Service) dnsEntry;
for (DNSEntry entry : this.getCache().getDNSEntryList(newRecord.getKey())) { if ( newRecord.getRecordType().equals(entry.getRecordType()) && newRecord.getRecordClass().equals(entry.getRecordClass()) &&
Collection<? extends DNSEntry> entries = this.getCache().getDNSEntryList(newRecord.getKey()); if (entries != null) { for (DNSEntry entry : entries) {
for (DNSEntry entry : this.getCache().getDNSEntryList(newRecord.getKey())) { if (newRecord.getRecordType().equals(entry.getRecordType()) && newRecord.getRecordClass().equals(entry.getRecordClass()) && (entry != cachedRecord)) { ((DNSRecord) entry).setWillExpireSoon(now);
for (DNSEntry entry : this.getCache().getDNSEntryList(newRecord.getKey())) { if (newRecord.getRecordType().equals(entry.getRecordType()) && newRecord.getRecordClass().equals(entry.getRecordClass()) && (entry != cachedRecord)) { ((DNSRecord) entry).setWillExpireSoon(now);
for (DNSEntry addressEntry : this.getCache().getDNSEntryList(server, DNSRecordType.TYPE_A, DNSRecordClass.CLASS_ANY)) { if (addressEntry instanceof DNSRecord) { ServiceInfo cachedAddressInfo = ((DNSRecord) addressEntry).getServiceInfo(persistent); for (DNSEntry addressEntry : this.getCache().getDNSEntryList(server, DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_ANY)) { if (addressEntry instanceof DNSRecord) { ServiceInfo cachedAddressInfo = ((DNSRecord) addressEntry).getServiceInfo(persistent);