This is a creation in Article, where the information may have evolved or changed.
The previous section has described how to construct a DNS request packet, and this section goes on to the previous section to talk about The problem part of the DNS query message. The format of each issue in the issues section is as follows:
The query name is the name to look for, and it is a sequence of one or more identifiers. Each identifier describes the byte length of the subsequent identifier in the first byte of the value, and each query name ends with a last byte of 0 , and an identifier of length 0 is the root identifier. Let's grab a bag and look at the details:
we see that the name of the request is www.baidu.com the contents of the package is the part of the red Line identified below, the name to look for is transformed into a 3www5baidu3com This format, So when we construct the DNS Query Request package, we need to change the name format of the query:
VAR (
Buffer bytes. Buffer
segments []string = strings. Split (Domain, ".")
)
For _, SEG: = Range Segments {
Binary. Write (&buffer, Binary. Bigendian, Byte (len (SEG)))
Binary. Write (&buffer, Binary. Bigendian, []byte (SEG)]
}
Binary. Write (&buffer, Binary. Bigendian, Byte (0x00))
return buffer. Bytes ()
Complete code please go to the previous section. The problem section of the query message is briefly described here.