Class DnsCodecUtil

java.lang.Object
io.netty.handler.codec.dns.DnsCodecUtil

final class DnsCodecUtil extends Object
  • Field Details

  • Constructor Details

    • DnsCodecUtil

      private DnsCodecUtil()
  • Method Details

    • setTcpMessageLength

      static void setTcpMessageLength(ByteBuf buf)
      Writes the length of the message into the first two bytes of the given ByteBuf which were reserved for it, as defined by RFC 7766.
      Throws:
      IllegalArgumentException - if the message is too large for the length to fit into two bytes.
    • encodeDomainName

      static void encodeDomainName(String name, ByteBuf buf)
    • calculateMaxNameLength

      static int calculateMaxNameLength(int readable)
      Returns the initial capacity to use for the StringBuilder that accumulates a decoded domain name. A decoded name can never exceed MAX_DOMAIN_NAME_LENGTH characters (see the check in decodeDomainName(ByteBuf)), so the capacity must not scale with readable, the number of bytes left in the whole message: doing so would let a message with a huge amount of trailing data (e.g. many more records after this name) force an oversized allocation for every single name decoded from it.
    • checkRecordCount

      static int checkRecordCount(DnsSection section, int count)
      Ensures the record count of a section, as announced in the header of a DNS message, does not exceed MAX_RECORDS_PER_SECTION.
      Throws:
      TooLongFrameException - if the count is too large.
    • decodeDomainName

      static String decodeDomainName(ByteBuf in)
    • decompressDomainName

      static ByteBuf decompressDomainName(ByteBuf compression)
      Decompress pointer data.
      Parameters:
      compression - compressed data
      Returns:
      decompressed data