style: simplify query handling some more
This commit is contained in:
parent
9e44cc2979
commit
d28ad9ebaf
1 changed files with 7 additions and 14 deletions
21
stub.go
21
stub.go
|
|
@ -173,20 +173,6 @@ func (s *StubDNS) make_handler(fqdn string, txt string) dns.HandlerFunc {
|
|||
zap.Object("request", LoggableDNSMsg{r}),
|
||||
)
|
||||
|
||||
if len(r.Question) != 1 {
|
||||
m.Rcode = dns.RcodeRefused
|
||||
m.Answer = []dns.RR{}
|
||||
logger.Info(
|
||||
"refusing invalid request",
|
||||
zap.Object("response", LoggableDNSMsg{m}),
|
||||
)
|
||||
w.WriteMsg(m)
|
||||
return
|
||||
}
|
||||
|
||||
q := r.Question[0]
|
||||
domain := q.Name
|
||||
|
||||
reject_and_log := func(code int, reason string) {
|
||||
m.Rcode = code
|
||||
m.Answer = []dns.RR{}
|
||||
|
|
@ -198,6 +184,13 @@ func (s *StubDNS) make_handler(fqdn string, txt string) dns.HandlerFunc {
|
|||
w.WriteMsg(m)
|
||||
}
|
||||
|
||||
if len(r.Question) != 1 {
|
||||
reject_and_log(dns.RcodeRefused, "not exactly 1 question")
|
||||
return
|
||||
}
|
||||
q := r.Question[0]
|
||||
domain := q.Name
|
||||
|
||||
switch {
|
||||
case r.Response:
|
||||
reject_and_log(dns.RcodeRefused, "not a query")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue