From 35a8fca379189d596341e487b3c595aabb97bea2 Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Mon, 29 Jul 2024 13:49:30 -0400 Subject: [PATCH] cmd/tailscale/cli: release portmap after netcheck Updates #12954 Signed-off-by: Andrew Dunham Change-Id: Ic14f037b48a79b1263b140c6699579b466d89310 --- cmd/tailscale/cli/netcheck.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/tailscale/cli/netcheck.go b/cmd/tailscale/cli/netcheck.go index 2fbc9d919..682cd99a3 100644 --- a/cmd/tailscale/cli/netcheck.go +++ b/cmd/tailscale/cli/netcheck.go @@ -52,9 +52,15 @@ func runNetcheck(ctx context.Context, args []string) error { if err != nil { return err } + + // Ensure that we close the portmapper after running a netcheck; this + // will release any port mappings created. + pm := portmapper.NewClient(logf, netMon, nil, nil, nil) + defer pm.Close() + c := &netcheck.Client{ NetMon: netMon, - PortMapper: portmapper.NewClient(logf, netMon, nil, nil, nil), + PortMapper: pm, UseDNSCache: false, // always resolve, don't cache } if netcheckArgs.verbose {