Class 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:
    • Field Detail

      • MAX_COOKIE_SERVERS

        private static final int MAX_COOKIE_SERVERS
        Upper 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:
        Constant Field Values
      • random

        private final java.security.SecureRandom random
      • caseRandomization

        private final boolean caseRandomization
      • cookieServers

        private final java.util.Set<java.net.InetSocketAddress> cookieServers
    • Constructor Detail

      • DnsQueryProtection

        DnsQueryProtection​(boolean caseRandomization,
                           boolean cookies)
    • Method Detail

      • isCaseRandomizationEnabled

        boolean isCaseRandomizationEnabled()
      • isCookiesEnabled

        boolean isCookiesEnabled()
      • randomizeCase

        DnsQuestion randomizeCase​(DnsQuestion question)
        Returns a copy of the given DnsQuestion in which the case of every ASCII letter was picked at random.
      • newClientCookie

        byte[] newClientCookie()
      • isCookieExpected

        boolean isCookieExpected​(java.net.InetSocketAddress nameServerAddr)
        Returns true if 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)