all: consistently initialize Logf when creating tsdial.Dialers

Most visible when using tsnet.Server, but could have resulted in dropped
messages in a few other places too.

Fixes #5743

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
pull/5814/head
Mihai Parparita 2 years ago committed by Mihai Parparita
parent a7efc7bd17
commit 8343b243e7

@ -375,8 +375,7 @@ func run() error {
socksListener, httpProxyListener := mustStartProxyListeners(args.socksAddr, args.httpProxyAddr) socksListener, httpProxyListener := mustStartProxyListeners(args.socksAddr, args.httpProxyAddr)
dialer := new(tsdial.Dialer) // mutated below (before used) dialer := &tsdial.Dialer{Logf: logf} // mutated below (before used)
dialer.Logf = logf
e, useNetstack, err := createEngine(logf, linkMon, dialer) e, useNetstack, err := createEngine(logf, linkMon, dialer)
if err != nil { if err != nil {
return fmt.Errorf("createEngine: %w", err) return fmt.Errorf("createEngine: %w", err)

@ -266,7 +266,7 @@ func startIPNServer(ctx context.Context, logid string) error {
if err != nil { if err != nil {
return fmt.Errorf("monitor: %w", err) return fmt.Errorf("monitor: %w", err)
} }
dialer := new(tsdial.Dialer) dialer := &tsdial.Dialer{Logf: logf}
getEngineRaw := func() (wgengine.Engine, *netstack.Impl, error) { getEngineRaw := func() (wgengine.Engine, *netstack.Impl, error) {
dev, devName, err := tstun.New(logf, "Tailscale") dev, devName, err := tstun.New(logf, "Tailscale")

@ -96,7 +96,7 @@ func newIPN(jsConfig js.Value) map[string]any {
logtail := logtail.NewLogger(c, log.Printf) logtail := logtail.NewLogger(c, log.Printf)
logf := logtail.Logf logf := logtail.Logf
dialer := new(tsdial.Dialer) dialer := &tsdial.Dialer{Logf: logf}
eng, err := wgengine.NewUserspaceEngine(logf, wgengine.Config{ eng, err := wgengine.NewUserspaceEngine(logf, wgengine.Config{
Dialer: dialer, Dialer: dialer,
}) })

@ -214,7 +214,7 @@ func NewLocalBackend(logf logger.Logf, logid string, store ipn.StateStore, diale
logf.JSON(1, "Hostinfo", hi) logf.JSON(1, "Hostinfo", hi)
envknob.LogCurrent(logf) envknob.LogCurrent(logf)
if dialer == nil { if dialer == nil {
dialer = new(tsdial.Dialer) dialer = &tsdial.Dialer{Logf: logf}
} }
osshare.SetFileSharingEnabled(false, logf) osshare.SetFileSharingEnabled(false, logf)

@ -540,7 +540,7 @@ func Cleanup(logf logger.Logf, interfaceName string) {
logf("creating dns cleanup: %v", err) logf("creating dns cleanup: %v", err)
return return
} }
dns := NewManager(logf, oscfg, nil, new(tsdial.Dialer), nil) dns := NewManager(logf, oscfg, nil, &tsdial.Dialer{Logf: logf}, nil)
if err := dns.Down(); err != nil { if err := dns.Down(); err != nil {
logf("dns down: %v", err) logf("dns down: %v", err)
} }

@ -271,7 +271,7 @@ func (s *Server) start() (reterr error) {
} }
closePool.add(s.linkMon) closePool.add(s.linkMon)
s.dialer = new(tsdial.Dialer) // mutated below (before used) s.dialer = &tsdial.Dialer{Logf: logf} // mutated below (before used)
eng, err := wgengine.NewUserspaceEngine(logf, wgengine.Config{ eng, err := wgengine.NewUserspaceEngine(logf, wgengine.Config{
ListenPort: 0, ListenPort: 0,
LinkMonitor: s.linkMon, LinkMonitor: s.linkMon,

@ -282,7 +282,7 @@ func NewUserspaceEngine(logf logger.Logf, conf Config) (_ Engine, reterr error)
conf.DNS = d conf.DNS = d
} }
if conf.Dialer == nil { if conf.Dialer == nil {
conf.Dialer = new(tsdial.Dialer) conf.Dialer = &tsdial.Dialer{Logf: logf}
} }
var tsTUNDev *tstun.Wrapper var tsTUNDev *tstun.Wrapper

Loading…
Cancel
Save