mirror of
https://github.com/tladesignz/dnstt.git
synced 2026-09-27 17:37:56 +03:00
Do the payload size check after the TXT and base32 checks.
That way we can respond with NXDOMAIN rather than FORMERR to more of the random queries that arrive.
This commit is contained in:
+11
-12
@@ -283,18 +283,6 @@ func responseFor(query *dns.Message, domain dns.Name) (*dns.Message, turbotunnel
|
||||
resp.Flags |= 0x0400 // AA = 1
|
||||
}
|
||||
|
||||
// We require clients to support EDNS(0) with a minimum payload size;
|
||||
// otherwise we would have to set a small KCP MTU (only around 200
|
||||
// bytes). https://tools.ietf.org/html/rfc6891#section-7 "If there is a
|
||||
// problem with processing the OPT record itself, such as an option
|
||||
// value that is badly formatted or that includes out-of-range values, a
|
||||
// FORMERR MUST be returned."
|
||||
if payloadSize < maxUDPPayload {
|
||||
resp.Flags |= dns.RcodeFormatError
|
||||
log.Printf("FORMERR: EDNS payload size %d is too small (minimum %d)", payloadSize, maxUDPPayload)
|
||||
return resp, clientID, nil
|
||||
}
|
||||
|
||||
if resp.Flags&0x0400 == 0 { // AA
|
||||
// Not a name we are authoritative for.
|
||||
resp.Flags |= dns.RcodeNameError
|
||||
@@ -331,6 +319,17 @@ func responseFor(query *dns.Message, domain dns.Name) (*dns.Message, turbotunnel
|
||||
return resp, clientID, nil
|
||||
}
|
||||
|
||||
// We require clients to support EDNS(0) with a minimum payload size;
|
||||
// otherwise we would have to set a small KCP MTU (only around 200
|
||||
// bytes). https://tools.ietf.org/html/rfc6891#section-7 "If there is a
|
||||
// problem with processing the OPT record itself, such as an option
|
||||
// value that is badly formatted or that includes out-of-range values, a
|
||||
// FORMERR MUST be returned."
|
||||
if payloadSize < maxUDPPayload {
|
||||
resp.Flags |= dns.RcodeFormatError
|
||||
return resp, clientID, nil
|
||||
}
|
||||
|
||||
return resp, clientID, payload[len(clientID):]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user