diff --git a/cmd/tailscaled/tailscaled.go b/cmd/tailscaled/tailscaled.go index 390c6f39e..9eada2b25 100644 --- a/cmd/tailscaled/tailscaled.go +++ b/cmd/tailscaled/tailscaled.go @@ -511,7 +511,13 @@ func getLocalBackend(ctx context.Context, logf logger.Logf, logID logid.PublicID return ok } dialer.NetstackDialTCP = func(ctx context.Context, dst netip.AddrPort) (net.Conn, error) { - return ns.DialContextTCP(ctx, dst) + // Note: don't just return ns.DialContextTCP or we'll + // return an interface containing a nil pointer. + tcpConn, err := ns.DialContextTCP(ctx, dst) + if err != nil { + return nil, err + } + return tcpConn, nil } } if socksListener != nil || httpProxyListener != nil { diff --git a/tsnet/tsnet.go b/tsnet/tsnet.go index 29e122a08..3c34a94c5 100644 --- a/tsnet/tsnet.go +++ b/tsnet/tsnet.go @@ -546,7 +546,13 @@ func (s *Server) start() (reterr error) { return ok } s.dialer.NetstackDialTCP = func(ctx context.Context, dst netip.AddrPort) (net.Conn, error) { - return ns.DialContextTCP(ctx, dst) + // Note: don't just return ns.DialContextTCP or we'll + // return an interface containing a nil pointer. + tcpConn, err := ns.DialContextTCP(ctx, dst) + if err != nil { + return nil, err + } + return tcpConn, nil } if s.Store == nil {