Skip to content

Commit

Permalink
cmd/tailscale/cli: create netmon in debug ts2021
Browse files Browse the repository at this point in the history
Otherwise we'll see a panic if we hit the dnsfallback code and try to
call NewDialer with a nil NetMon.

Updates tailscale#14161

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I81c6e72376599b341cb58c37134c2a948b97cf5f
  • Loading branch information
andrew-d committed Nov 21, 2024
1 parent 70d1241 commit af4c3a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/tailscale/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"tailscale.com/hostinfo"
"tailscale.com/internal/noiseconn"
"tailscale.com/ipn"
"tailscale.com/net/netmon"
"tailscale.com/net/tsaddr"
"tailscale.com/net/tshttpproxy"
"tailscale.com/paths"
Expand Down Expand Up @@ -850,6 +851,11 @@ func runTS2021(ctx context.Context, args []string) error {
logf = log.Printf
}

netMon, err := netmon.New(logger.WithPrefix(logf, "netmon: "))
if err != nil {
return fmt.Errorf("creating netmon: %w", err)
}

noiseDialer := &controlhttp.Dialer{
Hostname: ts2021Args.host,
HTTPPort: "80",
Expand All @@ -859,6 +865,7 @@ func runTS2021(ctx context.Context, args []string) error {
ProtocolVersion: uint16(ts2021Args.version),
Dialer: dialFunc,
Logf: logf,
NetMon: netMon,
}
const tries = 2
for i := range tries {
Expand Down
2 changes: 2 additions & 0 deletions control/controlhttp/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ type Dialer struct {
// dropped.
Logf logger.Logf

// NetMon is the [netmon.Monitor] to use for this Dialer. It must be
// non-nil.
NetMon *netmon.Monitor

// HealthTracker, if non-nil, is the health tracker to use.
Expand Down

0 comments on commit af4c3a4

Please sign in to comment.