|
|
@ -19,12 +19,23 @@ import (
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
|
|
|
|
"inet.af/netaddr"
|
|
|
|
"inet.af/netaddr"
|
|
|
|
|
|
|
|
"tailscale.com/syncs"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var disabled syncs.AtomicBool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Disable disables netns for the process.
|
|
|
|
|
|
|
|
func Disable() {
|
|
|
|
|
|
|
|
disabled.Set(true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Listener returns a new net.Listener with its Control hook func
|
|
|
|
// Listener returns a new net.Listener with its Control hook func
|
|
|
|
// initialized as necessary to run in logical network namespace that
|
|
|
|
// initialized as necessary to run in logical network namespace that
|
|
|
|
// doesn't route back into Tailscale.
|
|
|
|
// doesn't route back into Tailscale.
|
|
|
|
func Listener() *net.ListenConfig {
|
|
|
|
func Listener() *net.ListenConfig {
|
|
|
|
|
|
|
|
if disabled.Get() {
|
|
|
|
|
|
|
|
return new(net.ListenConfig)
|
|
|
|
|
|
|
|
}
|
|
|
|
return &net.ListenConfig{Control: control}
|
|
|
|
return &net.ListenConfig{Control: control}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -41,6 +52,9 @@ func NewDialer() Dialer {
|
|
|
|
// handles using a SOCKS if configured in the environment with
|
|
|
|
// handles using a SOCKS if configured in the environment with
|
|
|
|
// ALL_PROXY.
|
|
|
|
// ALL_PROXY.
|
|
|
|
func FromDialer(d *net.Dialer) Dialer {
|
|
|
|
func FromDialer(d *net.Dialer) Dialer {
|
|
|
|
|
|
|
|
if disabled.Get() {
|
|
|
|
|
|
|
|
return d
|
|
|
|
|
|
|
|
}
|
|
|
|
d.Control = control
|
|
|
|
d.Control = control
|
|
|
|
if wrapDialer != nil {
|
|
|
|
if wrapDialer != nil {
|
|
|
|
return wrapDialer(d)
|
|
|
|
return wrapDialer(d)
|
|
|
|