summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJames Tucker <james@tailscale.com>2025-03-10 10:04:19 -0700
committerJames Tucker <james@tailscale.com>2025-03-10 10:04:19 -0700
commitb267bc5e79c58c5b3071fc8213110350070531c7 (patch)
treebab858b4e7898028ac1ba9bf505afd292dd58e80
parent5f515a3731a8f08a185d69d57fb66bf69e79561e (diff)
downloadtailscale-raggi/natc-6.tar.xz
tailscale-raggi/natc-6.zip
cmd/natc: add an explicit error for missing peer stateraggi/natc-6
Updates tailscale/corp#26968 Signed-off-by: James Tucker <james@tailscale.com>
-rw-r--r--cmd/natc/natc.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/natc/natc.go b/cmd/natc/natc.go
index 73ba116ff..5bf5ae360 100644
--- a/cmd/natc/natc.go
+++ b/cmd/natc/natc.go
@@ -347,7 +347,11 @@ var tsMBox = dnsmessage.MustNewName("support.tailscale.com.")
// generateDNSResponse generates a DNS response for the given request. The from
// argument is the NodeID of the node that sent the request.
func (c *connector) generateDNSResponse(req *dnsmessage.Message, from tailcfg.NodeID) ([]byte, error) {
- pm, _ := c.perPeerMap.LoadOrStore(from, &perPeerState{c: c})
+ pm, ok := c.perPeerMap.LoadOrStore(from, &perPeerState{c: c})
+ if !ok {
+ // TODO(raggi): consider returning NXDOMAIN, but it is likely this result does not want to be cached.
+ return nil, fmt.Errorf("missing peer state for %s, unable to answer query: %v", from, req)
+ }
var addrs []netip.Addr
if len(req.Questions) > 0 {
switch req.Questions[0].Type {