Skip to content

Commit bb65814

Browse files
committed
Keep DERP always direct
1 parent aa6f5b2 commit bb65814

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

derp/derphttp/derphttp_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ func (c *Client) _DialRegionTLS(ctx context.Context, reg *tailcfg.DERPRegion) (t
697697
}
698698

699699
func (c *Client) dialContext(ctx context.Context, proto, addr string) (net.Conn, error) {
700-
return netns.NewDialer(c.logf, c.netMon).DialContext(ctx, proto, addr)
700+
return netns.NewDialerAlwaysDirect(c.logf, c.netMon).DialContext(ctx, proto, addr)
701701
}
702702

703703
// shouldDialProto reports whether an explicitly provided IPv4 or IPv6

logpolicy/logpolicy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ func dialContext(ctx context.Context, netw, addr string, netMon *netmon.Monitor,
768768
nd := netns.FromDialer(logf, netMon, &net.Dialer{
769769
Timeout: 30 * time.Second,
770770
KeepAlive: netknob.PlatformTCPKeepAlive(),
771-
})
771+
}, false)
772772
t0 := time.Now()
773773
c, err := nd.DialContext(ctx, netw, addr)
774774
d := time.Since(t0).Round(time.Millisecond)

net/netns/netns.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,27 @@ func NewDialer(logf logger.Logf, netMon *netmon.Monitor) Dialer {
7676
}
7777
return FromDialer(logf, netMon, &net.Dialer{
7878
KeepAlive: netknob.PlatformTCPKeepAlive(),
79-
})
79+
}, false)
80+
}
81+
82+
func NewDialerAlwaysDirect(logf logger.Logf, netMon *netmon.Monitor) Dialer {
83+
if netMon == nil {
84+
panic("netns.NewDialer called with nil netMon")
85+
}
86+
return FromDialer(logf, netMon, &net.Dialer{
87+
KeepAlive: netknob.PlatformTCPKeepAlive(),
88+
}, true)
8089
}
8190

8291
// FromDialer returns sets d.Control as necessary to run in a logical
8392
// network namespace that doesn't route back into Tailscale. It also
8493
// handles using a SOCKS if configured in the environment with
8594
// ALL_PROXY.
86-
func FromDialer(logf logger.Logf, netMon *netmon.Monitor, d *net.Dialer) Dialer {
95+
func FromDialer(logf logger.Logf, netMon *netmon.Monitor, d *net.Dialer, ad bool) Dialer {
8796
if netMon == nil {
8897
panic("netns.FromDialer called with nil netMon")
8998
}
90-
if dialer := netMon.Dialer(); dialer != nil {
99+
if dialer := netMon.Dialer(); dialer != nil && !ad {
91100
return dialerWrapper{dialer}
92101
}
93102
if disabled.Load() {

0 commit comments

Comments
 (0)