mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-24 01:31:55 +00:00
wgengine/magicsock: remove Start method from Conn.
Over time, other magicsock refactors have made Start effectively a no-op, except that some other functions choose to panic if called before Start. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
committed by
Dave Anderson
parent
1a899344bd
commit
4c27e2fa22
@@ -276,8 +276,7 @@ type Conn struct {
|
||||
mu sync.Mutex
|
||||
muCond *sync.Cond
|
||||
|
||||
started bool // Start was called
|
||||
closed bool // Close was called
|
||||
closed bool // Close was called
|
||||
|
||||
// derpCleanupTimer is the timer that fires to occasionally clean
|
||||
// up idle DERP connections. It's only used when there is a non-home
|
||||
@@ -546,17 +545,6 @@ func NewConn(opts Options) (*Conn, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *Conn) Start() {
|
||||
c.mu.Lock()
|
||||
if c.started {
|
||||
panic("duplicate Start call")
|
||||
}
|
||||
c.started = true
|
||||
c.mu.Unlock()
|
||||
|
||||
c.ReSTUN("initial")
|
||||
}
|
||||
|
||||
// ignoreSTUNPackets sets a STUN packet processing func that does nothing.
|
||||
func (c *Conn) ignoreSTUNPackets() {
|
||||
c.stunReceiveFunc.Store(func([]byte, netaddr.IPPort) {})
|
||||
@@ -1981,9 +1969,7 @@ func (c *Conn) SetPrivateKey(privateKey wgkey.Private) error {
|
||||
if oldKey.IsZero() {
|
||||
c.everHadKey = true
|
||||
c.logf("magicsock: SetPrivateKey called (init)")
|
||||
if c.started {
|
||||
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")
|
||||
@@ -2050,9 +2036,7 @@ func (c *Conn) SetDERPMap(dm *tailcfg.DERPMap) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.started {
|
||||
go c.ReSTUN("derp-map-update")
|
||||
}
|
||||
go c.ReSTUN("derp-map-update")
|
||||
}
|
||||
|
||||
func nodesEqual(x, y []*tailcfg.Node) bool {
|
||||
@@ -2476,9 +2460,6 @@ func (c *Conn) onPortMapChanged() { c.ReSTUN("portmap-changed") }
|
||||
func (c *Conn) ReSTUN(why string) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if !c.started {
|
||||
panic("call to ReSTUN before Start")
|
||||
}
|
||||
if c.closed {
|
||||
// raced with a shutdown.
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user