Top Inners Fields Constructors Methods
io.vertx.core.dns.impl

public final Class DnsClientImpl

extends Object
implements DnsClient
Class Inheritance
All Implemented Interfaces
io.vertx.core.dns.DnsClient
Imports
io.netty.channel.*, io.netty.channel.socket.DatagramChannel, .InternetProtocolFamily, io.netty.handler.codec.DecoderException, io.netty.handler.codec.dns.*, io.netty.handler.logging.LoggingHandler, io.netty.util.collection.LongObjectHashMap, .LongObjectMap, io.vertx.codegen.annotations.Nullable, io.vertx.core.*, io.vertx.core.dns.*, .DnsResponseCode, io.vertx.core.dns.impl.decoder.RecordDecoder, io.vertx.core.impl.ContextInternal, .VertxInternal, io.vertx.core.impl.future.PromiseInternal, io.vertx.core.buffer.impl.PartialPooledByteBufAllocator, io.vertx.core.net.impl.ConnectionBase, io.vertx.core.spi.transport.Transport, java.net.Inet4Address, .InetAddress, .InetSocketAddress, .UnknownHostException, java.util.ArrayList, .Collections, .List, .Objects, java.util.concurrent.ThreadLocalRandom

Author
Norman Maurer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final DatagramChannel
private volatile Future<Void>
private final ContextInternal
private final InetSocketAddress
private static final char[]
private final LongObjectMap<DnsClientImpl.Query<T>>
private final DnsClientOptions
private final VertxInternal

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close(Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.dns.DnsClient.close.

Close the client.

public Future<Void>
close()

Implements io.vertx.core.dns.DnsClient.close.

Like close(Handler) but returns a Future of the asynchronous result

private long
dnsMessageId(int id, String query)

public void
public DnsClient
lookup(String
the name to resolve
name
,
Handler<AsyncResult<String>>
the io.vertx.core.Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with the resolved address if a record was found. If non was found it will get notifed with null. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.lookup.

Try to lookup the A (ipv4) or AAAA (ipv6) record for the given name.

public Future<@Nullable String>
lookup(String name)

Implements io.vertx.core.dns.DnsClient.lookup.

Like lookup(String, Handler) but returns a Future of the asynchronous result

public DnsClient
lookup4(String
the name to resolve
name
,
Handler<AsyncResult<String>>
the Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with the resolved java.net.Inet4Address if a record was found. If non was found it will get notifed with null. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.lookup4.

Try to lookup the A (ipv4) record for the given name.

public Future<@Nullable String>
lookup4(String name)

Implements io.vertx.core.dns.DnsClient.lookup4.

Like lookup4(String, Handler) but returns a Future of the asynchronous result

public DnsClient
lookup6(String
the name to resolve
name
,
Handler<AsyncResult<String>>
the Handler to notify with the AsyncResult. The handler will get notified with the resolved java.net.Inet6Address if a record was found. If non was found it will get notifed with null. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.lookup6.

Try to lookup the AAAA (ipv6) record for the given name.

public Future<@Nullable String>
lookup6(String name)

Implements io.vertx.core.dns.DnsClient.lookup6.

Like lookup6(String, Handler) but returns a Future of the asynchronous result

private <T> Future<List<T>>
private <T> Future<T>
public DnsClient
resolveA(String
the name to resolve
name
,
Handler<AsyncResult<List<String>>>
the io.vertx.core.Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with a java.util.List that contains all the resolved java.net.Inet4Addresses. If none was found an empty java.util.List will be used. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.resolveA.

Try to resolve all A (ipv4) records for the given name.

public Future<List<String>>
resolveA(String name)

Implements io.vertx.core.dns.DnsClient.resolveA.

Like resolveA(String, Handler) but returns a Future of the asynchronous result

public DnsClient
resolveAAAA(String
the name to resolve
name
,
Handler<AsyncResult<List<String>>>
the io.vertx.core.Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with a java.util.List that contains all the resolved java.net.Inet6Addresses. If none was found an empty java.util.List will be used. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.resolveAAAA.

Try to resolve all AAAA (ipv6) records for the given name.

public Future<List<String>>
resolveAAAA(String name)

Implements io.vertx.core.dns.DnsClient.resolveAAAA.

Like resolveAAAA(String, Handler) but returns a Future of the asynchronous result

public DnsClient
resolveCNAME(String
the name to resolve the CNAME for
name
,
Handler<AsyncResult<List<String>>>
the Handler to notify with the AsyncResult. The handler will get notified with the resolved String if a record was found. If none was found it will get notified with null. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.resolveCNAME.

Try to resolve the CNAME record for the given name.

public Future<List<String>>
resolveCNAME(String name)

Implements io.vertx.core.dns.DnsClient.resolveCNAME.

Like resolveCNAME(String, Handler) but returns a Future of the asynchronous result

public DnsClient
resolveMX(String
the name for which the MX records should be resolved
name
,
Handler<AsyncResult<List<MxRecord>>>
the io.vertx.core.Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with a List that contains all resolved MxRecords, sorted by their MxRecord#priority(). If non was found it will get notified with an empty java.util.List. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.resolveMX.

Try to resolve the MX records for the given name.

public Future<List<MxRecord>>
resolveMX(String name)

Implements io.vertx.core.dns.DnsClient.resolveMX.

Like resolveMX(String, Handler) but returns a Future of the asynchronous result

public Future<List<String>>
resolveNS(String name)

Implements io.vertx.core.dns.DnsClient.resolveNS.

Like resolveNS(String, Handler) but returns a Future of the asynchronous result

public DnsClient
resolveNS(String
the name for which the NS records should be resolved
name
,
Handler<AsyncResult<List<String>>>
the Handler to notify with the AsyncResult. The handler will get notified with a List that contains all resolved Strings. If none was found it will get notified with an empty java.util.List. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.resolveNS.

Try to resolve the NS records for the given name.

public Future<@Nullable String>
resolvePTR(String name)

Implements io.vertx.core.dns.DnsClient.resolvePTR.

Like resolvePTR(String, Handler) but returns a Future of the asynchronous result

public DnsClient
resolvePTR(String
the name to resolve the PTR for
name
,
Handler<AsyncResult<String>>
the Handler to notify with the AsyncResult. The handler will get notified with the resolved String if a record was found. If none was found it will get notified with null. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.resolvePTR.

Try to resolve the PTR record for the given name.

public Future<List<SrvRecord>>
resolveSRV(String name)

Implements io.vertx.core.dns.DnsClient.resolveSRV.

Like resolveSRV(String, Handler) but returns a Future of the asynchronous result

public DnsClient
resolveSRV(String
the name for which the SRV records should be resolved
name
,
Handler<AsyncResult<List<SrvRecord>>>
the Handler to notify with the AsyncResult. The handler will get notified with a List that contains all resolved SrvRecords. If none was found it will get notified with an empty java.util.List. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.resolveSRV.

Try to resolve the SRV records for the given name.

public Future<List<String>>
resolveTXT(String name)

Implements io.vertx.core.dns.DnsClient.resolveTXT.

Like resolveTXT(String, Handler) but returns a Future of the asynchronous result

public DnsClient
resolveTXT(String
the name for which the TXT records should be resolved
name
,
Handler<AsyncResult<List<String>>>
the Handler to notify with the AsyncResult. The handler will get notified with a List that contains all resolved Strings. If none was found it will get notified with an empty java.util.List. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.resolveTXT.

Try to resolve the TXT records for the given name.

public Future<@Nullable String>
reverseLookup(String address)

Implements io.vertx.core.dns.DnsClient.reverseLookup.

Like reverseLookup(String, Handler) but returns a Future of the asynchronous result

public DnsClient
reverseLookup(String
the IP address to resolve the PTR for
address
,
Handler<AsyncResult<String>>
the Handler to notify with the AsyncResult. The handler will get notified with the resolved String if a record was found. If none was found it will get notified with null. If an error accours it will get failed.
handler
)

Implements io.vertx.core.dns.DnsClient.reverseLookup.

Try to do a reverse lookup of an IP address.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelback to summary
private final DatagramChannel channel
closedback to summary
private volatile Future<Void> closed
contextback to summary
private final ContextInternal context
dnsServerback to summary
private final InetSocketAddress dnsServer
HEX_TABLEback to summary
private static final char[] HEX_TABLE
inProgressMapback to summary
private final LongObjectMap<DnsClientImpl.Query<T>> inProgressMap
optionsback to summary
private final DnsClientOptions options
vertxback to summary
private final VertxInternal vertx

Constructor Detail

DnsClientImplback to summary
public DnsClientImpl(VertxInternal vertx, DnsClientOptions options)

Method Detail

closeback to summary
public void close(Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.dns.DnsClient.close.

Doc from io.vertx.core.dns.DnsClient.close.

Close the client.

Annotations
@Override
closeback to summary
public Future<Void> close()

Implements io.vertx.core.dns.DnsClient.close.

Doc from io.vertx.core.dns.DnsClient.close.

Like close(Handler) but returns a Future of the asynchronous result

Annotations
@Override
dnsMessageIdback to summary
private long dnsMessageId(int id, String query)
inProgressQueriesback to summary
public void inProgressQueries(Handler<Integer> handler)
lookupback to summary
public DnsClient lookup(String name, Handler<AsyncResult<String>> handler)

Implements io.vertx.core.dns.DnsClient.lookup.

Doc from io.vertx.core.dns.DnsClient.lookup.

Try to lookup the A (ipv4) or AAAA (ipv6) record for the given name. The first found will be used.

Parameters
name:String

the name to resolve

handler:Handler<AsyncResult<String>>

the io.vertx.core.Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with the resolved address if a record was found. If non was found it will get notifed with null. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently

Annotations
@Override
lookupback to summary
public Future<@Nullable String> lookup(String name)

Implements io.vertx.core.dns.DnsClient.lookup.

Doc from io.vertx.core.dns.DnsClient.lookup.

Like lookup(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
lookup4back to summary
public DnsClient lookup4(String name, Handler<AsyncResult<String>> handler)

Implements io.vertx.core.dns.DnsClient.lookup4.

Doc from io.vertx.core.dns.DnsClient.lookup4.

Try to lookup the A (ipv4) record for the given name. The first found will be used.

Parameters
name:String

the name to resolve

handler:Handler<AsyncResult<String>>

the Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with the resolved java.net.Inet4Address if a record was found. If non was found it will get notifed with null. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently

Annotations
@Override
lookup4back to summary
public Future<@Nullable String> lookup4(String name)

Implements io.vertx.core.dns.DnsClient.lookup4.

Doc from io.vertx.core.dns.DnsClient.lookup4.

Like lookup4(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
lookup6back to summary
public DnsClient lookup6(String name, Handler<AsyncResult<String>> handler)

Implements io.vertx.core.dns.DnsClient.lookup6.

Doc from io.vertx.core.dns.DnsClient.lookup6.

Try to lookup the AAAA (ipv6) record for the given name. The first found will be used.

Parameters
name:String

the name to resolve

handler:Handler<AsyncResult<String>>

the Handler to notify with the AsyncResult. The handler will get notified with the resolved java.net.Inet6Address if a record was found. If non was found it will get notifed with null. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently

Annotations
@Override
lookup6back to summary
public Future<@Nullable String> lookup6(String name)

Implements io.vertx.core.dns.DnsClient.lookup6.

Doc from io.vertx.core.dns.DnsClient.lookup6.

Like lookup6(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
lookupListback to summary
private <T> Future<List<T>> lookupList(String name, DnsRecordType... types)
Annotations
@SuppressWarnings:unchecked
lookupSingleback to summary
private <T> Future<T> lookupSingle(String name, DnsRecordType... types)
resolveAback to summary
public DnsClient resolveA(String name, Handler<AsyncResult<List<String>>> handler)

Implements io.vertx.core.dns.DnsClient.resolveA.

Doc from io.vertx.core.dns.DnsClient.resolveA.

Try to resolve all A (ipv4) records for the given name.

Parameters
name:String

the name to resolve

handler:Handler<AsyncResult<List<String>>>

the io.vertx.core.Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with a java.util.List that contains all the resolved java.net.Inet4Addresses. If none was found an empty java.util.List will be used. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently

Annotations
@Override
resolveAback to summary
public Future<List<String>> resolveA(String name)

Implements io.vertx.core.dns.DnsClient.resolveA.

Doc from io.vertx.core.dns.DnsClient.resolveA.

Like resolveA(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
resolveAAAAback to summary
public DnsClient resolveAAAA(String name, Handler<AsyncResult<List<String>>> handler)

Implements io.vertx.core.dns.DnsClient.resolveAAAA.

Doc from io.vertx.core.dns.DnsClient.resolveAAAA.

Try to resolve all AAAA (ipv6) records for the given name.

Parameters
name:String

the name to resolve

handler:Handler<AsyncResult<List<String>>>

the io.vertx.core.Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with a java.util.List that contains all the resolved java.net.Inet6Addresses. If none was found an empty java.util.List will be used. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently

Annotations
@Override
resolveAAAAback to summary
public Future<List<String>> resolveAAAA(String name)

Implements io.vertx.core.dns.DnsClient.resolveAAAA.

Doc from io.vertx.core.dns.DnsClient.resolveAAAA.

Like resolveAAAA(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
resolveCNAMEback to summary
public DnsClient resolveCNAME(String name, Handler<AsyncResult<List<String>>> handler)

Implements io.vertx.core.dns.DnsClient.resolveCNAME.

Doc from io.vertx.core.dns.DnsClient.resolveCNAME.

Try to resolve the CNAME record for the given name.

Parameters
name:String

the name to resolve the CNAME for

handler:Handler<AsyncResult<List<String>>>

the Handler to notify with the AsyncResult. The handler will get notified with the resolved String if a record was found. If none was found it will get notified with null. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently.

Annotations
@Override
resolveCNAMEback to summary
public Future<List<String>> resolveCNAME(String name)

Implements io.vertx.core.dns.DnsClient.resolveCNAME.

Doc from io.vertx.core.dns.DnsClient.resolveCNAME.

Like resolveCNAME(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
resolveMXback to summary
public DnsClient resolveMX(String name, Handler<AsyncResult<List<MxRecord>>> handler)

Implements io.vertx.core.dns.DnsClient.resolveMX.

Doc from io.vertx.core.dns.DnsClient.resolveMX.

Try to resolve the MX records for the given name.

Parameters
name:String

the name for which the MX records should be resolved

handler:Handler<AsyncResult<List<MxRecord>>>

the io.vertx.core.Handler to notify with the io.vertx.core.AsyncResult. The handler will get notified with a List that contains all resolved MxRecords, sorted by their MxRecord#priority(). If non was found it will get notified with an empty java.util.List. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently.

Annotations
@Override
resolveMXback to summary
public Future<List<MxRecord>> resolveMX(String name)

Implements io.vertx.core.dns.DnsClient.resolveMX.

Doc from io.vertx.core.dns.DnsClient.resolveMX.

Like resolveMX(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
resolveNSback to summary
public Future<List<String>> resolveNS(String name)

Implements io.vertx.core.dns.DnsClient.resolveNS.

Doc from io.vertx.core.dns.DnsClient.resolveNS.

Like resolveNS(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
resolveNSback to summary
public DnsClient resolveNS(String name, Handler<AsyncResult<List<String>>> handler)

Implements io.vertx.core.dns.DnsClient.resolveNS.

Doc from io.vertx.core.dns.DnsClient.resolveNS.

Try to resolve the NS records for the given name.

Parameters
name:String

the name for which the NS records should be resolved

handler:Handler<AsyncResult<List<String>>>

the Handler to notify with the AsyncResult. The handler will get notified with a List that contains all resolved Strings. If none was found it will get notified with an empty java.util.List. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently.

Annotations
@Override
resolvePTRback to summary
public Future<@Nullable String> resolvePTR(String name)

Implements io.vertx.core.dns.DnsClient.resolvePTR.

Doc from io.vertx.core.dns.DnsClient.resolvePTR.

Like resolvePTR(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
resolvePTRback to summary
public DnsClient resolvePTR(String name, Handler<AsyncResult<String>> handler)

Implements io.vertx.core.dns.DnsClient.resolvePTR.

Doc from io.vertx.core.dns.DnsClient.resolvePTR.

Try to resolve the PTR record for the given name.

Parameters
name:String

the name to resolve the PTR for

handler:Handler<AsyncResult<String>>

the Handler to notify with the AsyncResult. The handler will get notified with the resolved String if a record was found. If none was found it will get notified with null. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently.

Annotations
@Override
resolveSRVback to summary
public Future<List<SrvRecord>> resolveSRV(String name)

Implements io.vertx.core.dns.DnsClient.resolveSRV.

Doc from io.vertx.core.dns.DnsClient.resolveSRV.

Like resolveSRV(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
resolveSRVback to summary
public DnsClient resolveSRV(String name, Handler<AsyncResult<List<SrvRecord>>> handler)

Implements io.vertx.core.dns.DnsClient.resolveSRV.

Doc from io.vertx.core.dns.DnsClient.resolveSRV.

Try to resolve the SRV records for the given name.

Parameters
name:String

the name for which the SRV records should be resolved

handler:Handler<AsyncResult<List<SrvRecord>>>

the Handler to notify with the AsyncResult. The handler will get notified with a List that contains all resolved SrvRecords. If none was found it will get notified with an empty java.util.List. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently.

Annotations
@Override
resolveTXTback to summary
public Future<List<String>> resolveTXT(String name)

Implements io.vertx.core.dns.DnsClient.resolveTXT.

Doc from io.vertx.core.dns.DnsClient.resolveTXT.

Like resolveTXT(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
resolveTXTback to summary
public DnsClient resolveTXT(String name, Handler<AsyncResult<List<String>>> handler)

Implements io.vertx.core.dns.DnsClient.resolveTXT.

Doc from io.vertx.core.dns.DnsClient.resolveTXT.

Try to resolve the TXT records for the given name.

Parameters
name:String

the name for which the TXT records should be resolved

handler:Handler<AsyncResult<List<String>>>

the Handler to notify with the AsyncResult. The handler will get notified with a List that contains all resolved Strings. If none was found it will get notified with an empty java.util.List. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently.

Annotations
@Override
reverseLookupback to summary
public Future<@Nullable String> reverseLookup(String address)

Implements io.vertx.core.dns.DnsClient.reverseLookup.

Doc from io.vertx.core.dns.DnsClient.reverseLookup.

Like reverseLookup(String, Handler) but returns a Future of the asynchronous result

Annotations
@Override
reverseLookupback to summary
public DnsClient reverseLookup(String address, Handler<AsyncResult<String>> handler)

Implements io.vertx.core.dns.DnsClient.reverseLookup.

Doc from io.vertx.core.dns.DnsClient.reverseLookup.

Try to do a reverse lookup of an IP address. This is basically the same as doing trying to resolve a PTR record but allows you to just pass in the IP address and not a valid ptr query string.

Parameters
address:String

the IP address to resolve the PTR for

handler:Handler<AsyncResult<String>>

the Handler to notify with the AsyncResult. The handler will get notified with the resolved String if a record was found. If none was found it will get notified with null. If an error accours it will get failed.

Returns:DnsClient

a reference to this, so the API can be used fluently.

Annotations
@Override
io.vertx.core.dns.impl back to summary

private Class DnsClientImpl.Query<T>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final DatagramDnsQuery
pack-priv final String
pack-priv final Promise<List<T>>
pack-priv long
pack-priv final DnsRecordType[]

Constructor Summary

AccessConstructor and Description
public
Query(String name, DnsRecordType[] types)

Method Summary

Modifier and TypeMethod and Description
private void
fail(Throwable cause)

pack-priv void
private boolean
pack-priv void
run()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

msgback to summary
pack-priv final DatagramDnsQuery msg
nameback to summary
pack-priv final String name
promiseback to summary
pack-priv final Promise<List<T>> promise
timerIDback to summary
pack-priv long timerID
typesback to summary
pack-priv final DnsRecordType[] types

Constructor Detail

Queryback to summary
public Query(String name, DnsRecordType[] types)

Method Detail

failback to summary
private void fail(Throwable cause)
handleback to summary
pack-priv void handle(DnsResponse msg)
isRequestedTypeback to summary
private boolean isRequestedType(DnsRecordType dnsRecordType, DnsRecordType[] types)
runback to summary
pack-priv void run()