mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-22 12:58:37 +00:00
controlclient: do not send duplicate hostinfo/netinfo
This should never happen, so log when it does so we can fix it. Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
parent
48d7ee1c6a
commit
2f8719741e
@ -496,7 +496,12 @@ func (c *Client) SetHostinfo(hi *tailcfg.Hostinfo) {
|
|||||||
if hi == nil {
|
if hi == nil {
|
||||||
panic("nil Hostinfo")
|
panic("nil Hostinfo")
|
||||||
}
|
}
|
||||||
c.direct.SetHostinfo(hi)
|
if !c.direct.SetHostinfo(hi) {
|
||||||
|
c.logf("[unexpected] duplicate Hostinfo: %v", hi)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.logf("Hostinfo: %v", hi)
|
||||||
|
|
||||||
// Send new Hostinfo to server
|
// Send new Hostinfo to server
|
||||||
c.cancelMapSafely()
|
c.cancelMapSafely()
|
||||||
}
|
}
|
||||||
@ -505,7 +510,12 @@ func (c *Client) SetNetInfo(ni *tailcfg.NetInfo) {
|
|||||||
if ni == nil {
|
if ni == nil {
|
||||||
panic("nil NetInfo")
|
panic("nil NetInfo")
|
||||||
}
|
}
|
||||||
c.direct.SetNetInfo(ni)
|
if !c.direct.SetNetInfo(ni) {
|
||||||
|
c.logf("[unexpected] duplicate NetInfo: %v", ni)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.logf("NetInfo: %v", ni)
|
||||||
|
|
||||||
// Send new Hostinfo (which includes NetInfo) to server
|
// Send new Hostinfo (which includes NetInfo) to server
|
||||||
c.cancelMapSafely()
|
c.cancelMapSafely()
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -149,21 +150,24 @@ func NewHostinfo() *tailcfg.Hostinfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetHostinfo clones the provided Hostinfo and remembers it for the
|
// SetHostinfo clones the provided Hostinfo and remembers it for the
|
||||||
// next update.
|
// next update. It reports whether the Hostinfo has changed.
|
||||||
func (c *Direct) SetHostinfo(hi *tailcfg.Hostinfo) {
|
func (c *Direct) SetHostinfo(hi *tailcfg.Hostinfo) bool {
|
||||||
if hi == nil {
|
if hi == nil {
|
||||||
panic("nil Hostinfo")
|
panic("nil Hostinfo")
|
||||||
}
|
}
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
c.logf("Hostinfo: %v\n", hi)
|
if hi.Equal(c.hostinfo) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
c.hostinfo = hi.Clone()
|
c.hostinfo = hi.Clone()
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNetInfo clones the provided NetInfo and remembers it for the
|
// SetNetInfo clones the provided NetInfo and remembers it for the
|
||||||
// next update.
|
// next update. It reports whether the NetInfo has changed.
|
||||||
func (c *Direct) SetNetInfo(ni *tailcfg.NetInfo) {
|
func (c *Direct) SetNetInfo(ni *tailcfg.NetInfo) bool {
|
||||||
if ni == nil {
|
if ni == nil {
|
||||||
panic("nil NetInfo")
|
panic("nil NetInfo")
|
||||||
}
|
}
|
||||||
@ -172,10 +176,13 @@ func (c *Direct) SetNetInfo(ni *tailcfg.NetInfo) {
|
|||||||
|
|
||||||
if c.hostinfo == nil {
|
if c.hostinfo == nil {
|
||||||
c.logf("[unexpected] SetNetInfo called with no HostInfo; ignoring NetInfo update: %+v", ni)
|
c.logf("[unexpected] SetNetInfo called with no HostInfo; ignoring NetInfo update: %+v", ni)
|
||||||
return
|
return false
|
||||||
|
}
|
||||||
|
if reflect.DeepEqual(ni, c.hostinfo.NetInfo) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
c.logf("NetInfo: %v\n", ni)
|
|
||||||
c.hostinfo.NetInfo = ni.Clone()
|
c.hostinfo.NetInfo = ni.Clone()
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Direct) GetPersist() Persist {
|
func (c *Direct) GetPersist() Persist {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user