Source File
acceptfunc.go
Belonging Package
github.com/miekg/dns
package dns// MsgAcceptFunc is used early in the server code to accept or reject a message with RcodeFormatError.// It returns a MsgAcceptAction to indicate what should happen with the message.type MsgAcceptFunc func(dh Header) MsgAcceptAction// DefaultMsgAcceptFunc checks the request and will reject if://// * isn't a request (don't respond in that case)//// * opcode isn't OpcodeQuery or OpcodeNotify//// * does not have exactly 1 question in the question section//// * has more than 1 RR in the Answer section//// * has more than 0 RRs in the Authority section//// * has more than 2 RRs in the Additional sectionvar DefaultMsgAcceptFunc MsgAcceptFunc = defaultMsgAcceptFunc// MsgAcceptAction represents the action to be taken.type MsgAcceptAction int// Allowed returned values from a MsgAcceptFunc.const (MsgAccept MsgAcceptAction = iota // Accept the messageMsgReject // Reject the message with a RcodeFormatErrorMsgIgnore // Ignore the error and send nothing back.MsgRejectNotImplemented // Reject the message with a RcodeNotImplemented)func defaultMsgAcceptFunc( Header) MsgAcceptAction {if := .Bits&_QR != 0; {return MsgIgnore}// Don't allow dynamic updates, because then the sections can contain a whole bunch of RRs.:= int(.Bits>>11) & 0xFif != OpcodeQuery && != OpcodeNotify {return MsgRejectNotImplemented}if .Qdcount != 1 {return MsgReject}// NOTIFY requests can have a SOA in the ANSWER section. See RFC 1996 Section 3.7 and 3.11.if .Ancount > 1 {return MsgReject}// IXFR request could have one SOA RR in the NS section. See RFC 1995, section 3.if .Nscount > 1 {return MsgReject}if .Arcount > 2 {return MsgReject}return MsgAccept}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |