Class DnsQueryProtection

java.lang.Object
io.netty.resolver.dns.DnsQueryProtection

final class DnsQueryProtection extends 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 Details

    • ACE_PREFIX

      private static final String ACE_PREFIX
      See Also:
    • random

      private final SecureRandom random
    • caseRandomization

      private final boolean caseRandomization
    • cookieServers

      private final Set<InetSocketAddress> cookieServers
  • Constructor Details

    • DnsQueryProtection

      DnsQueryProtection(boolean caseRandomization, boolean cookies)
  • Method Details

    • 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(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(InetSocketAddress nameServerAddr)
    • checkCookie

      static DnsQueryProtection.CookieStatus checkCookie(DnsResponse response, byte[] clientCookie)
      Inspect the COOKIE option of the OPT record of the response.
    • checkCookie

      private static DnsQueryProtection.CookieStatus checkCookie(ByteBuf rdata, byte[] clientCookie)