/** * Creates a new instance. * * @param maxPayloadSize the suggested max payload size in bytes * @param protocolFamily the {@link InternetProtocolFamily} to use. This should be the same as the one used to * send the query. */ public DefaultDnsOptEcsRecord(int maxPayloadSize, InternetProtocolFamily protocolFamily) { this(maxPayloadSize, 0, 0, 0, protocolFamily.localhost().getAddress()); }
InternetProtocolFamily.IPv4.addressNumber() : InternetProtocolFamily.IPv6.addressNumber()); int payloadLength = calculateEcsAddressLength(sourcePrefixLength, lowOrderBitsToPreserve);
@Override List<InetAddress> filterResults(List<InetAddress> unfiltered) { final Class<? extends InetAddress> inetAddressType = parent.preferredAddressType().addressType(); final int size = unfiltered.size(); int numExpected = 0; for (int i = 0; i < size; i++) { InetAddress address = unfiltered.get(i); if (inetAddressType.isInstance(address)) { numExpected++; } } if (numExpected == size || numExpected == 0) { // If all the results are the preferred type, or none of them are, then we don't need to do any filtering. return unfiltered; } List<InetAddress> filtered = new ArrayList<InetAddress>(numExpected); for (int i = 0; i < size; i++) { InetAddress address = unfiltered.get(i); if (inetAddressType.isInstance(address)) { filtered.add(address); } } return filtered; }
@Override List<InetAddress> filterResults(List<InetAddress> unfiltered) { final Class<? extends InetAddress> inetAddressType = parent.preferredAddressType().addressType(); final int size = unfiltered.size(); int numExpected = 0; for (int i = 0; i < size; i++) { InetAddress address = unfiltered.get(i); if (inetAddressType.isInstance(address)) { numExpected++; } } if (numExpected == size || numExpected == 0) { // If all the results are the preferred type, or none of them are, then we don't need to do any filtering. return unfiltered; } List<InetAddress> filtered = new ArrayList<InetAddress>(numExpected); for (int i = 0; i < size; i++) { InetAddress address = unfiltered.get(i); if (inetAddressType.isInstance(address)) { filtered.add(address); } } return filtered; }
/** * Creates a new instance. * * @param maxPayloadSize the suggested max payload size in bytes * @param protocolFamily the {@link InternetProtocolFamily} to use. This should be the same as the one used to * send the query. */ public DefaultDnsOptEcsRecord(int maxPayloadSize, InternetProtocolFamily protocolFamily) { this(maxPayloadSize, 0, 0, 0, protocolFamily.localhost().getAddress()); }
InternetProtocolFamily.IPv4.addressNumber() : InternetProtocolFamily.IPv6.addressNumber()); int payloadLength = calculateEcsAddressLength(sourcePrefixLength, lowOrderBitsToPreserve);
for (int i = 0; i < numEntries; i++) { final DnsCacheEntry e = cachedEntries.get(i); if (f.addressType().isInstance(e.address())) { if (result == null) { result = new ArrayList<InetAddress>(numEntries);
private InetAddress loopbackAddress() { return preferredAddressType().localhost(); }
InternetProtocolFamily.IPv4.addressNumber() : InternetProtocolFamily.IPv6.addressNumber()); int payloadLength = calculateEcsAddressLength(sourcePrefixLength, lowOrderBitsToPreserve);
private boolean doResolveCached(String hostname, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache) { final List<? extends DnsCacheEntry> cachedEntries = resolveCache.get(hostname, additionals); if (cachedEntries == null || cachedEntries.isEmpty()) { return false; } Throwable cause = cachedEntries.get(0).cause(); if (cause == null) { final int numEntries = cachedEntries.size(); // Find the first entry with the preferred address type. for (InternetProtocolFamily f : resolvedInternetProtocolFamilies) { for (int i = 0; i < numEntries; i++) { final DnsCacheEntry e = cachedEntries.get(i); if (f.addressType().isInstance(e.address())) { trySuccess(promise, e.address()); return true; } } } return false; } else { tryFailure(promise, cause); return true; } }
private InetAddress loopbackAddress() { return preferredAddressType().localhost(); }
InternetProtocolFamily.IPv4.addressNumber() : InternetProtocolFamily.IPv6.addressNumber()); int payloadLength = calculateEcsAddressLength(sourcePrefixLength, lowOrderBitsToPreserve);
for (int i = 0; i < numEntries; i++) { final DnsCacheEntry e = cachedEntries.get(i); if (f.addressType().isInstance(e.address())) { if (result == null) { result = new ArrayList<InetAddress>(numEntries);
/** * Creates a new instance. * * @param maxPayloadSize the suggested max payload size in bytes * @param protocolFamily the {@link InternetProtocolFamily} to use. This should be the same as the one used to * send the query. */ public DefaultDnsOptEcsRecord(int maxPayloadSize, InternetProtocolFamily protocolFamily) { this(maxPayloadSize, 0, 0, 0, protocolFamily.localhost().getAddress()); }
private boolean doResolveCached(String hostname, DnsRecord[] additionals, Promise<InetAddress> promise, DnsCache resolveCache) { final List<? extends DnsCacheEntry> cachedEntries = resolveCache.get(hostname, additionals); if (cachedEntries == null || cachedEntries.isEmpty()) { return false; } Throwable cause = cachedEntries.get(0).cause(); if (cause == null) { final int numEntries = cachedEntries.size(); // Find the first entry with the preferred address type. for (InternetProtocolFamily f : resolvedInternetProtocolFamilies) { for (int i = 0; i < numEntries; i++) { final DnsCacheEntry e = cachedEntries.get(i); if (f.addressType().isInstance(e.address())) { trySuccess(promise, e.address()); return true; } } } return false; } else { tryFailure(promise, cause); return true; } }
/** * Creates a new instance. * * @param maxPayloadSize the suggested max payload size in bytes * @param protocolFamily the {@link InternetProtocolFamily} to use. This should be the same as the one used to * send the query. */ public DefaultDnsOptEcsRecord(int maxPayloadSize, InternetProtocolFamily protocolFamily) { this(maxPayloadSize, 0, 0, 0, protocolFamily.localhost().getAddress()); }
private AuthoritativeDnsServerCache newAuthoritativeDnsServerCache() { return new DefaultAuthoritativeDnsServerCache( intValue(minTtl, 0), intValue(maxTtl, Integer.MAX_VALUE), // Let us use the sane ordering as DnsNameResolver will be used when returning // nameservers from the cache. new NameServerComparator(DnsNameResolver.preferredAddressType(resolvedAddressTypes).addressType())); }
private InetAddress loopbackAddress() { return preferredAddressType().localhost(); }
private AuthoritativeDnsServerCache newAuthoritativeDnsServerCache() { return new DefaultAuthoritativeDnsServerCache( intValue(minTtl, 0), intValue(maxTtl, Integer.MAX_VALUE), // Let us use the sane ordering as DnsNameResolver will be used when returning // nameservers from the cache. new NameServerComparator(DnsNameResolver.preferredAddressType(resolvedAddressTypes).addressType())); }
private InetAddress loopbackAddress() { return preferredAddressType().localhost(); }