mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
wgengine/magicsock: don't mutexly reach inside Conn to tweak DERP settings.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
f6dd2128d9
commit
fdee5fb639
@ -124,6 +124,8 @@ type Options struct {
|
|||||||
// EndpointsFunc optionally provides a func to be called when
|
// EndpointsFunc optionally provides a func to be called when
|
||||||
// endpoints change. The called func does not own the slice.
|
// endpoints change. The called func does not own the slice.
|
||||||
EndpointsFunc func(endpoint []string)
|
EndpointsFunc func(endpoint []string)
|
||||||
|
|
||||||
|
derpTLSConfig *tls.Config // normally nil; used by tests
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Options) endpointsFunc() func([]string) {
|
func (o *Options) endpointsFunc() func([]string) {
|
||||||
@ -173,6 +175,7 @@ func Listen(opts Options) (*Conn, error) {
|
|||||||
wantDerp: true,
|
wantDerp: true,
|
||||||
derpRecvCh: make(chan derpReadResult),
|
derpRecvCh: make(chan derpReadResult),
|
||||||
udpRecvCh: make(chan udpReadResult),
|
udpRecvCh: make(chan udpReadResult),
|
||||||
|
derpTLSConfig: opts.derpTLSConfig,
|
||||||
}
|
}
|
||||||
c.ignoreSTUNPackets()
|
c.ignoreSTUNPackets()
|
||||||
c.pconn.Reset(packetConn.(*net.UDPConn))
|
c.pconn.Reset(packetConn.(*net.UDPConn))
|
||||||
|
@ -308,32 +308,26 @@ func TestTwoDevicePing(t *testing.T) {
|
|||||||
EndpointsFunc: func(eps []string) {
|
EndpointsFunc: func(eps []string) {
|
||||||
epCh1 <- eps
|
epCh1 <- eps
|
||||||
},
|
},
|
||||||
|
derpTLSConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer conn1.Close()
|
defer conn1.Close()
|
||||||
|
|
||||||
conn1.derpMu.Lock()
|
|
||||||
conn1.derpTLSConfig = &tls.Config{InsecureSkipVerify: true}
|
|
||||||
conn1.derpMu.Unlock()
|
|
||||||
|
|
||||||
epCh2 := make(chan []string, 16)
|
epCh2 := make(chan []string, 16)
|
||||||
conn2, err := Listen(Options{
|
conn2, err := Listen(Options{
|
||||||
STUN: []string{stunAddr.String()},
|
STUN: []string{stunAddr.String()},
|
||||||
EndpointsFunc: func(eps []string) {
|
EndpointsFunc: func(eps []string) {
|
||||||
epCh2 <- eps
|
epCh2 <- eps
|
||||||
},
|
},
|
||||||
|
derpTLSConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer conn2.Close()
|
defer conn2.Close()
|
||||||
|
|
||||||
conn2.derpMu.Lock()
|
|
||||||
conn2.derpTLSConfig = &tls.Config{InsecureSkipVerify: true}
|
|
||||||
conn2.derpMu.Unlock()
|
|
||||||
|
|
||||||
ports := []uint16{conn1.LocalPort(), conn2.LocalPort()}
|
ports := []uint16{conn1.LocalPort(), conn2.LocalPort()}
|
||||||
cfgs := makeConfigs(t, ports)
|
cfgs := makeConfigs(t, ports)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user