@Override protected boolean resolve(String ip) { try { dns.getByName(ip); return true; } catch (UnknownHostException e) { return false; } }
/** * @see org.apache.james.protocols.smtp.DNSService#getAllByName(java.lang.String) */ public InetAddress[] getAllByName(String host) throws UnknownHostException { return dns.getAllByName(host); }
/** * @see org.apache.james.protocols.smtp.DNSService#findTXTRecords(java.lang.String) */ public Collection<String> findTXTRecords(String hostname) { return dns.findTXTRecords(hostname); }
/** * @see org.apache.james.protocols.smtp.DNSService#getHostName(java.net.InetAddress) */ public String getHostName(InetAddress addr) { return dns.getHostName(addr); }
/** * @see org.apache.james.protocols.smtp.DNSService#getLocalHost() */ public InetAddress getLocalHost() throws UnknownHostException { return dns.getLocalHost(); }
/** * Return a fake DNSServer. */ protected DNSService getDNSServer(final String hostName) throws UnknownHostException { return new InMemoryDNSService() .registerMxRecord(hostName, "127.0.0.1") .registerMxRecord("127.0.0.1", "127.0.0.1"); }
/** * @see org.apache.james.protocols.smtp.DNSService#findMXRecords(java.lang.String) */ public Collection<String> findMXRecords(String hostname) throws TemporaryResolutionException { try { return dns.findMXRecords(hostname); } catch (org.apache.james.dnsservice.api.TemporaryResolutionException e) { throw new TemporaryResolutionException(e.getMessage()); } }
/** * @see org.apache.james.protocols.smtp.DNSService#getSMTPHostAddresses(java.lang.String) */ public Iterator<HostAddress> getSMTPHostAddresses(String domainName) throws TemporaryResolutionException { try { return dns.getSMTPHostAddresses(domainName); } catch (org.apache.james.dnsservice.api.TemporaryResolutionException e) { throw new TemporaryResolutionException(e.getMessage()); } }
@Override public String getHostName(final InetAddress addr) { Predicate<? super Entry<String, DNSRecord>> filterByValue = entry -> entry.getValue().contains(addr); try { return getDNSEntry(filterByValue).getKey(); } catch (UnknownHostException e) { throw new RuntimeException(e); } }
@Override public List<InetAddress> getAllByName(String host) throws UnknownHostException { return hostRecord(host).addresses; }
public InMemoryDNSService registerMxRecord(String hostname, String ip) throws UnknownHostException { InetAddress containerIp = InetAddress.getByName(ip); registerRecord(hostname, containerIp, hostname); return this; }
private DNSRecord dnsRecordFor(Collection<String> mxRecords, Collection<String> txtRecords, List<InetAddress> addresses) { return new DNSRecord(addresses, mxRecords, txtRecords); }
private DNSRecord dnsRecordFor(InetAddress addresses) { Collection<String> emptyList = ImmutableList.of(); return dnsRecordFor(emptyList, emptyList, ImmutableList.of(addresses)); }
/** * @see org.apache.james.protocols.smtp.DNSService#getByName(java.lang.String) */ public InetAddress getByName(String host) throws UnknownHostException { return dns.getByName(host); }
@Override protected Collection<String> resolveTXTRecords(String ip) { return dns.findTXTRecords(ip); } }
@Override public Collection<String> findTXTRecords(String hostname) { try { return hostRecord(hostname).txtRecords; } catch (UnknownHostException e) { throw new RuntimeException(e); } }
public InMemoryDNSService registerRecord(String hostname, InetAddress address, String mxRecord) { Collection<String> emptyTxtRecords = ImmutableList.of(); registerRecord(hostname, ImmutableList.of(address), ImmutableList.of(mxRecord), emptyTxtRecords); return this; }
@Override protected String resolve(String host) throws UnknownHostException { return dns.getByName(host).getHostName(); }
@Override public Collection<String> findMXRecords(String hostname) throws TemporaryResolutionException { try { return hostRecord(hostname).mxRecords; } catch (UnknownHostException e) { throw new RuntimeException(e); } }
@Override public InetAddress getByName(String host) throws UnknownHostException { return hostRecord(host).addresses.get(0); }