dnsserver
request
func Proto
1 | func Proto(w dns.ResponseWriter) string |
传输所用的协议,udp或者tcp
type Request
1 | type Request struct { |
func (*Request) IP
1 | func (r *Request) IP() string |
获取发起dns请求的客户端ip地址
func (*Request) LocalAddr
1 | func (r *Request) LocalAddr() string |
LocalAddr returns the net.Addr of the server handling the current request.
func (*Request) LocalIP
1 | func (r *Request) LocalIP() string |
LocalIP gets the (local) IP address of server handling the request.
func (*Request) LocalPort
1 | func (r *Request) LocalPort() string |
LocalPort gets the local port of the server handling the request.
func (*Request) Name
1 | func (r *Request) Name() string |
Name returns the name of the question in the request. Note this name will always have a closing dot and will be lower cased. After a call Name the value will be cached. To clear this caching call Clear. If the request is malformed the root zone is returned.
func (*Request) QName
1 | func (r *Request) QName() string |
QName returns the name of the question in the request. If the request is malformed the root zone is returned.
dns
type Msg
Msg 列举DNS信息1
2
3
4
5
6
7
8type Msg struct {
MsgHdr
Compress bool `json:"-"` // If true, the message will be compressed when converted to wire format.
Question []Question // Holds the RR(s) of the question section.
Answer []RR // Holds the RR(s) of the answer section.
Ns []RR // Holds the RR(s) of the authority section.
Extra []RR // Holds the RR(s) of the additional section.
}
type RR
RR(resource record) 资源记录1
2
3
4
5
6
7
8
9
type RR interface {
// Header returns the header of an resource record. The header contains
// everything up to the rdata.
Header() *RR_Header
// String returns the text representation of the resource record.
String() string
// contains filtered or unexported methods
}
type MsgHdr
MsgHdr is a a manually-unpacked version of (id, bits).1
2
3
4
5
6
7
8
9
10
11
12
13type MsgHdr struct {
Id uint16
Response bool
Opcode int
Authoritative bool
Truncated bool
RecursionDesired bool
RecursionAvailable bool
Zero bool
AuthenticatedData bool
CheckingDisabled bool
Rcode int
}
type Question
question包含一个dns询问1
2
3
4
5type Question struct {
Name string `dns:"cdomain-name"` // "cdomain-name" specifies encoding (and may be compressed)
Qtype uint16
Qclass uint16
}
type Name
dns.name1
2
3
4
5type Name string
//Name is a DNS domain name.
func (n Name) String() string
//String returns the string representation for the name n.
type Server
1 | type Server struct { |