mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 11:41:39 +00:00
wgengine/magicsock: log better with less spam on transition to stopped state
Required a minor test update too, which now needs a private key to get far enough to test the thing being tested.
This commit is contained in:
parent
69f3ceeb7c
commit
fe68841dc7
@ -1788,13 +1788,16 @@ func (c *Conn) SetPrivateKey(privateKey wgcfg.PrivateKey) error {
|
|||||||
if oldKey.IsZero() {
|
if oldKey.IsZero() {
|
||||||
c.logf("magicsock: SetPrivateKey called (init)")
|
c.logf("magicsock: SetPrivateKey called (init)")
|
||||||
go c.ReSTUN("set-private-key")
|
go c.ReSTUN("set-private-key")
|
||||||
|
} else if newKey.IsZero() {
|
||||||
|
c.logf("magicsock: SetPrivateKey called (zeroed)")
|
||||||
|
c.closeAllDerpLocked("zero-private-key")
|
||||||
} else {
|
} else {
|
||||||
c.logf("magicsock: SetPrivateKey called (changed")
|
c.logf("magicsock: SetPrivateKey called (changed)")
|
||||||
|
c.closeAllDerpLocked("new-private-key")
|
||||||
}
|
}
|
||||||
c.closeAllDerpLocked("new-private-key")
|
|
||||||
|
|
||||||
// Key changed. Close existing DERP connections and reconnect to home.
|
// Key changed. Close existing DERP connections and reconnect to home.
|
||||||
if c.myDerp != 0 {
|
if c.myDerp != 0 && !newKey.IsZero() {
|
||||||
c.logf("magicsock: private key changed, reconnecting to home derp-%d", c.myDerp)
|
c.logf("magicsock: private key changed, reconnecting to home derp-%d", c.myDerp)
|
||||||
c.goDerpConnect(c.myDerp)
|
c.goDerpConnect(c.myDerp)
|
||||||
}
|
}
|
||||||
@ -1844,7 +1847,9 @@ func (c *Conn) SetDERPMap(dm *tailcfg.DERPMap) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
go c.ReSTUN("derp-map-update")
|
if c.started {
|
||||||
|
go c.ReSTUN("derp-map-update")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func nodesEqual(x, y []*tailcfg.Node) bool {
|
func nodesEqual(x, y []*tailcfg.Node) bool {
|
||||||
@ -2152,6 +2157,10 @@ func (c *Conn) ReSTUN(why string) {
|
|||||||
// raced with a shutdown.
|
// raced with a shutdown.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if c.privateKey.IsZero() {
|
||||||
|
c.logf("magicsock: ReSTUN(%q) ignored; no private key", why)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if c.endpointsUpdateActive {
|
if c.endpointsUpdateActive {
|
||||||
if c.wantEndpointsUpdate != why {
|
if c.wantEndpointsUpdate != why {
|
||||||
@ -2242,8 +2251,12 @@ func (c *Conn) Rebind() {
|
|||||||
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
c.closeAllDerpLocked("rebind")
|
c.closeAllDerpLocked("rebind")
|
||||||
|
haveKey := !c.privateKey.IsZero()
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
c.goDerpConnect(c.myDerp)
|
|
||||||
|
if haveKey {
|
||||||
|
c.goDerpConnect(c.myDerp)
|
||||||
|
}
|
||||||
c.resetAddrSetStates()
|
c.resetAddrSetStates()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,8 +215,9 @@ func TestNewConn(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
conn.Start()
|
|
||||||
conn.SetDERPMap(stuntest.DERPMapOf(stunAddr.String()))
|
conn.SetDERPMap(stuntest.DERPMapOf(stunAddr.String()))
|
||||||
|
conn.SetPrivateKey(wgcfg.PrivateKey(key.NewPrivate()))
|
||||||
|
conn.Start()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
var pkt [64 << 10]byte
|
var pkt [64 << 10]byte
|
||||||
|
Loading…
x
Reference in New Issue
Block a user