Documentation ¶
Index ¶
- Constants
- func GererateDNSNames(name string) []byte
- func GererateDNSNamesIP(ips string) []byte
- func GererateDNSNamesLen(name string) uint16
- func GererateDNSNamesString(buf []byte) string
- func GetOffsetNames(buf []byte, _id int) (string, int)
- type Answers
- type DNSHeader
- type DNSInfo
- func (dnsInfo *DNSInfo) GenerateAnswer() []byte
- func (dnsInfo *DNSInfo) GenerateHeaders() []byte
- func (dnsInfo *DNSInfo) GenerateQuestion() []byte
- func (dnsInfo *DNSInfo) GetAnswerInfo(buf []byte) []Answers
- func (dnsInfo *DNSInfo) GetHeader(buf []byte)
- func (dnsInfo *DNSInfo) GetQuestion(buf []byte)
- type HeaderInfo
- type Queries
- type QueriesStep
Constants ¶
const ( Type_A uint16 = 1 Type_CNAME uint16 = 5 )
Variables ¶
This section is empty.
Functions ¶
func GererateDNSNamesString ¶
根据报文式的 域名 获取 string式的域名
Types ¶
type Answers ¶
type Answers struct { NAME string // NAME // 暂时不考虑用标志位来实现响应报文 TYPE uint16 // TYPE CLASS uint16 // CLASS TTL uint32 // TTL RDLENGTH uint16 // RELENGTH RDATA []byte // RDATA RDATAString string // RDATA String }
Resource record
type DNSHeader ¶
type DNSHeader struct { ID uint16 // ID HeaderStatus HeaderInfo // QR QPCODE AA TC RD RA Z RCODE QCOUNT uint16 //QCOUNT ANCOUNT uint16 //ANCOUNT NSCOUNT uint16 // NSCOUNT ARCOUNT uint16 // ARCOUNT }
Header
type DNSInfo ¶
type DNSInfo struct { Header DNSHeader QueryInfo Queries QueryStep QueriesStep AnswerInfo Answers }
func (*DNSInfo) GetAnswerInfo ¶
获取 响应 报文数据
1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | / / / NAME / | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TYPE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | CLASS | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TTL | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | RDLENGTH | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| / RDATA / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
func (*DNSInfo) GetHeader ¶
获取 Header Header 协议 12 byte
1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ID | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |QR| Opcode |AA|TC|RD|RA| Z | RCODE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | QDCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ANCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | NSCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ARCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
func (*DNSInfo) GetQuestion ¶
获取 Query 查询报文
1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | / QNAME / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | QTYPE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | QCLASS | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
type HeaderInfo ¶
type HeaderInfo struct { QR uint8 // 1 bit Opcode uint8 // 4 bit AA uint8 // 1bit TC uint8 // 1 bit RD uint8 // 1 bit RA uint8 // 1 bit Z uint8 // 3 bit RCODE uint8 // 4bit }
Header Status
type Queries ¶
type Queries struct { QNAME []byte //QNAME QNAMEString string //QNAMEString QTYPE uint16 //QTYPE QCLASS uint16 //QClass }
Question
type QueriesStep ¶
type QueriesStep struct { QueryStart int // headEnd Question start QueriesEnd int //Question end QueriesDomainEnd int // QNAME end }
Question step