Class DnsQueryProtection
java.lang.Object
io.netty.resolver.dns.DnsQueryProtection
final class DnsQueryProtection
extends java.lang.Object
Defences that make it harder for an off-path attacker to spoof the response of a UDP DNS query on top of the
query id and the source port, as recommended by
RFC 5452:
- "0x20" randomization of the case of the name in the question (draft-vixie-dnsext-dns0x20)
- client cookies as defined in RFC 7873
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumThe result of checking the cookie in a response. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final java.lang.Stringprivate final booleanprivate final java.util.Set<java.net.InetSocketAddress> private static final intUpper bound for the number of nameservers we remember to support cookies.private final java.security.SecureRandom -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static DnsQueryProtection.CookieStatuscheckCookie(ByteBuf rdata, byte[] clientCookie) (package private) static DnsQueryProtection.CookieStatuscheckCookie(DnsResponse response, byte[] clientCookie) Inspect the COOKIE option of the OPT record of the response.(package private) voidcookieReceived(java.net.InetSocketAddress nameServerAddr) (package private) boolean(package private) booleanisCookieExpected(java.net.InetSocketAddress nameServerAddr) Returnstrueif the given nameserver has returned a valid cookie before, and so is expected to do so for every response.(package private) boolean(package private) byte[](package private) DnsQuestionrandomizeCase(DnsQuestion question) Returns a copy of the givenDnsQuestionin which the case of every ASCII letter was picked at random.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
MAX_COOKIE_SERVERS
private static final int MAX_COOKIE_SERVERSUpper bound for the number of nameservers we remember to support cookies. Once reached we stop remembering new ones, which means that responses from those will not be rejected if they omit the cookie.- See Also:
-
ACE_PREFIX
private static final java.lang.String ACE_PREFIX- See Also:
-
random
private final java.security.SecureRandom random -
caseRandomization
private final boolean caseRandomization -
cookieServers
private final java.util.Set<java.net.InetSocketAddress> cookieServers
-
-
Constructor Details
-
DnsQueryProtection
DnsQueryProtection(boolean caseRandomization, boolean cookies)
-
-
Method Details
-
isCaseRandomizationEnabled
boolean isCaseRandomizationEnabled() -
isCookiesEnabled
boolean isCookiesEnabled() -
randomizeCase
Returns a copy of the givenDnsQuestionin which the case of every ASCII letter was picked at random. -
newClientCookie
byte[] newClientCookie() -
isCookieExpected
boolean isCookieExpected(java.net.InetSocketAddress nameServerAddr) Returnstrueif the given nameserver has returned a valid cookie before, and so is expected to do so for every response. -
cookieReceived
void cookieReceived(java.net.InetSocketAddress nameServerAddr) -
checkCookie
Inspect the COOKIE option of the OPT record of the response. -
checkCookie
-