@Test public void emptyEtcResolverDirectoryDoesNotThrow() throws IOException { File f = buildFile("domain linecorp.local\n" + "nameserver 127.0.0.2\n" + "nameserver 127.0.0.3\n"); UnixResolverDnsServerAddressStreamProvider p = new UnixResolverDnsServerAddressStreamProvider(f, folder.newFolder().listFiles()); DnsServerAddressStream stream = p.nameServerAddressStream("somehost"); assertHostNameEquals("127.0.0.2", stream.next()); }
@Override public DnsServerAddressStream nameServerAddressStream(String hostname) { for (;;) { int i = hostname.indexOf('.', 1); if (i < 0 || i == hostname.length() - 1) { return defaultNameServerAddresses.stream(); } DnsServerAddresses addresses = domainToNameServerStreamMap.get(hostname); if (addresses != null) { return addresses.stream(); } hostname = hostname.substring(i + 1); } }
UnixResolverDnsServerAddressStreamProvider implements DnsServerAddressStreamProvider { @Override public DnsServerAddressStream nameServerAddressStream(String hostname) { for (;;) { int i = hostname.indexOf('.', 1); if (i < 0 || i == hostname.length() - 1) { return defaultNameServerAddresses.stream(); } DnsServerAddresses addresses = domainToNameServerStreamMap.get(hostname); if (addresses != null) { return addresses.stream(); } hostname = hostname.substring(i + 1); } } }
UnixResolverDnsServerAddressStreamProvider implements DnsServerAddressStreamProvider { @Override public DnsServerAddressStream nameServerAddressStream(String hostname) { for (;;) { int i = hostname.indexOf('.', 1); if (i < 0 || i == hostname.length() - 1) { return defaultNameServerAddresses.stream(); } DnsServerAddresses addresses = domainToNameServerStreamMap.get(hostname); if (addresses != null) { return addresses.stream(); } hostname = hostname.substring(i + 1); } } UnixResolverDnsServerAddressStreamProvider(File etcResolvConf, File... etcResolverFiles);  UnixResolverDnsServerAddressStreamProvider(String etcResolvConf, String etcResolverDir); }
UnixResolverDnsServerAddressStreamProvider implements DnsServerAddressStreamProvider { @Override public DnsServerAddressStream nameServerAddressStream(String hostname) { for (;;) { int i = hostname.indexOf('.', 1); if (i < 0 || i == hostname.length() - 1) { return defaultNameServerAddresses.stream(); } DnsServerAddresses addresses = domainToNameServerStreamMap.get(hostname); if (addresses != null) { return addresses.stream(); } hostname = hostname.substring(i + 1); } } UnixResolverDnsServerAddressStreamProvider(File etcResolvConf, File... etcResolverFiles);  UnixResolverDnsServerAddressStreamProvider(String etcResolvConf, String etcResolverDir); @Override DnsServerAddressStream nameServerAddressStream(String hostname); }
UnixResolverDnsServerAddressStreamProvider implements DnsServerAddressStreamProvider { @Override public DnsServerAddressStream nameServerAddressStream(String hostname) { for (;;) { int i = hostname.indexOf('.', 1); if (i < 0 || i == hostname.length() - 1) { return defaultNameServerAddresses.stream(); } DnsServerAddresses addresses = domainToNameServerStreamMap.get(hostname); if (addresses != null) { return addresses.stream(); } hostname = hostname.substring(i + 1); } } UnixResolverDnsServerAddressStreamProvider(File etcResolvConf, File... etcResolverFiles);  UnixResolverDnsServerAddressStreamProvider(String etcResolvConf, String etcResolverDir); @Override DnsServerAddressStream nameServerAddressStream(String hostname);  }