public class ParallelResolverImpl extends java.lang.Object implements CustomResolver, java.beans.PropertyChangeListener
We achieve this by entering a redundant mode whenever we detect an abnormal delay (longer than DNS_PATIENCE) while waiting for a DNS resonse, or when that response is not considered satisfying.
Once we enter redundant mode, we start duplicating all queries and sending them to both our primary and backup resolvers (in case we have any). We then always return the first response we get, regardless of who sent it.
We exit redundant mode after receiving DNS_REDEMPTION consecutive timely and correct responses from our primary resolver.
Modifier and Type | Field and Description |
---|---|
static int |
currentDnsRedemption
The currently configured number of times that the primary DNS would have
to provide a faster response than the backup resolver before we consider
it safe enough to exit redundant mode.
|
DNS_PATIENCE, DNS_REDEMPTION, PDEFAULT_DNSSEC_RESOLVER_ENABLED, PNAME_DNS_PATIENCE, PNAME_DNS_REDEMPTION, PNAME_DNSSEC_RESOLVER_ENABLED
Constructor and Description |
---|
ParallelResolverImpl()
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
propertyChange(java.beans.PropertyChangeEvent evt) |
void |
reset()
Resets resolver configuration and populate our default resolver
with the newly configured servers.
|
org.xbill.DNS.Message |
send(org.xbill.DNS.Message query)
Sends a message and waits for a response.
|
java.lang.Object |
sendAsync(org.xbill.DNS.Message query,
org.xbill.DNS.ResolverListener listener)
Supposed to asynchronously send messages but not currently implemented.
|
void |
setEDNS(int level)
Sets the EDNS version used on outgoing messages.
|
void |
setEDNS(int level,
int payloadSize,
int flags,
java.util.List options)
Sets the EDNS information on outgoing messages.
|
void |
setIgnoreTruncation(boolean flag)
Sets whether truncated responses will be ignored.
|
void |
setPort(int port)
Sets the port to communicate on with the default servers.
|
void |
setTCP(boolean flag)
Sets whether TCP connections will be sent by default with the default
resolver.
|
void |
setTimeout(int secs)
Sets the amount of time to wait for a response before giving up.
|
void |
setTimeout(int secs,
int msecs)
Sets the amount of time to wait for a response before giving up.
|
void |
setTSIGKey(org.xbill.DNS.TSIG key)
Specifies the TSIG key that messages will be signed with
|
public static int currentDnsRedemption
ParallelResolverImpl()
public org.xbill.DNS.Message send(org.xbill.DNS.Message query) throws java.io.IOException
send
in interface org.xbill.DNS.Resolver
query
- The query to send.java.io.IOException
- An error occurred while sending or receiving.public java.lang.Object sendAsync(org.xbill.DNS.Message query, org.xbill.DNS.ResolverListener listener)
sendAsync
in interface org.xbill.DNS.Resolver
query
- The query to sendlistener
- The object containing the callbacks.public void setPort(int port)
setPort
in interface org.xbill.DNS.Resolver
port
- The port to send messages topublic void setTCP(boolean flag)
setTCP
in interface org.xbill.DNS.Resolver
flag
- Indicates whether TCP connections are madepublic void setIgnoreTruncation(boolean flag)
setIgnoreTruncation
in interface org.xbill.DNS.Resolver
flag
- Indicates whether truncated responses should be ignored.public void setEDNS(int level)
setEDNS
in interface org.xbill.DNS.Resolver
level
- The EDNS level to use. 0 indicates EDNS0 and -1 indicates no
EDNS.java.lang.IllegalArgumentException
- An invalid level was indicated.public void setEDNS(int level, int payloadSize, int flags, java.util.List options)
setEDNS
in interface org.xbill.DNS.Resolver
level
- The EDNS level to use. 0 indicates EDNS0 and -1 indicates no
EDNS.payloadSize
- The maximum DNS packet size that this host is capable
of receiving over UDP. If 0 is specified, the default (1280) is used.flags
- EDNS extended flags to be set in the OPT record.options
- EDNS options to be set in the OPT record, specified as a
List of OPTRecord.Option elements.java.lang.IllegalArgumentException
- An invalid field was specified.OPTRecord
public void setTSIGKey(org.xbill.DNS.TSIG key)
setTSIGKey
in interface org.xbill.DNS.Resolver
key
- The keypublic void setTimeout(int secs, int msecs)
setTimeout
in interface org.xbill.DNS.Resolver
secs
- The number of seconds to wait.msecs
- The number of milliseconds to wait.public void setTimeout(int secs)
setTimeout
in interface org.xbill.DNS.Resolver
secs
- The number of seconds to wait.public final void reset()
reset
in interface CustomResolver
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.