mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
ipn: clear the hostinfo.Services list when prefs.ShieldsUp==true.
When shields are up, no services are available to connect to, so hide them all. This will also help them disappear from the UI menu on other nodes. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
This commit is contained in:
parent
d7429b9a8d
commit
ced9b4008a
37
ipn/local.go
37
ipn/local.go
@ -93,7 +93,7 @@ func NewLocalBackend(logf logger.Logf, logid string, store StateStore, e wgengin
|
|||||||
|
|
||||||
if b.portpoll != nil {
|
if b.portpoll != nil {
|
||||||
go b.portpoll.Run(ctx)
|
go b.portpoll.Run(ctx)
|
||||||
go b.runPoller()
|
go b.readPoller()
|
||||||
}
|
}
|
||||||
|
|
||||||
return b, nil
|
return b, nil
|
||||||
@ -370,7 +370,7 @@ func (b *LocalBackend) updateFilter(netMap *controlclient.NetworkMap) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *LocalBackend) runPoller() {
|
func (b *LocalBackend) readPoller() {
|
||||||
for {
|
for {
|
||||||
ports, ok := <-b.portpoll.C
|
ports, ok := <-b.portpoll.C
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -394,16 +394,11 @@ func (b *LocalBackend) runPoller() {
|
|||||||
// is started (by NewLocalBackend) before the Start call.
|
// is started (by NewLocalBackend) before the Start call.
|
||||||
b.hiCache = new(tailcfg.Hostinfo)
|
b.hiCache = new(tailcfg.Hostinfo)
|
||||||
}
|
}
|
||||||
|
b.hiCache.Services = sl
|
||||||
hi := b.hiCache
|
hi := b.hiCache
|
||||||
hi.Services = sl
|
|
||||||
b.hiCache = hi
|
|
||||||
cli := b.c
|
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
|
|
||||||
// b.c might not be started yet
|
b.doSetHostinfoFilterServices(hi)
|
||||||
if cli != nil {
|
|
||||||
cli.SetHostinfo(hi)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,13 +601,12 @@ func (b *LocalBackend) SetPrefs(new *Prefs) {
|
|||||||
newHi := oldHi.Clone()
|
newHi := oldHi.Clone()
|
||||||
newHi.RoutableIPs = append([]wgcfg.CIDR(nil), b.prefs.AdvertiseRoutes...)
|
newHi.RoutableIPs = append([]wgcfg.CIDR(nil), b.prefs.AdvertiseRoutes...)
|
||||||
b.hiCache = newHi
|
b.hiCache = newHi
|
||||||
cli := b.c
|
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
|
|
||||||
b.logf("SetPrefs: %v", new.Pretty())
|
b.logf("SetPrefs: %v", new.Pretty())
|
||||||
|
|
||||||
if cli != nil && !oldHi.Equal(newHi) {
|
if old.ShieldsUp != new.ShieldsUp || !oldHi.Equal(newHi) {
|
||||||
cli.SetHostinfo(newHi)
|
b.doSetHostinfoFilterServices(newHi)
|
||||||
}
|
}
|
||||||
|
|
||||||
b.updateFilter(b.netMapCache)
|
b.updateFilter(b.netMapCache)
|
||||||
@ -626,6 +620,25 @@ func (b *LocalBackend) SetPrefs(new *Prefs) {
|
|||||||
b.send(Notify{Prefs: new})
|
b.send(Notify{Prefs: new})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *LocalBackend) doSetHostinfoFilterServices(hi *tailcfg.Hostinfo) {
|
||||||
|
hi2 := *hi
|
||||||
|
prefs := b.Prefs()
|
||||||
|
if prefs != nil && prefs.ShieldsUp {
|
||||||
|
// No local services are available, since ShieldsUp will block
|
||||||
|
// them all.
|
||||||
|
hi2.Services = []tailcfg.Service{}
|
||||||
|
}
|
||||||
|
|
||||||
|
b.mu.Lock()
|
||||||
|
cli := b.c
|
||||||
|
b.mu.Unlock()
|
||||||
|
|
||||||
|
// b.c might not be started yet
|
||||||
|
if cli != nil {
|
||||||
|
cli.SetHostinfo(&hi2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Note: return value may be nil, if we haven't received a netmap yet.
|
// Note: return value may be nil, if we haven't received a netmap yet.
|
||||||
func (b *LocalBackend) NetMap() *controlclient.NetworkMap {
|
func (b *LocalBackend) NetMap() *controlclient.NetworkMap {
|
||||||
return b.netMapCache
|
return b.netMapCache
|
||||||
|
Loading…
Reference in New Issue
Block a user