ipn/local: differentiate Shields Up from Uninitialized in logs.

We were printing "Shields Up" when the netmap wasn't initialized yet,
which while technically effectively true, turned out to be confusing
when trying to debug things.

Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
pull/348/head
Avery Pennarun 5 years ago
parent 64db026c8b
commit d6c34368e8

@ -354,17 +354,21 @@ func (b *LocalBackend) Start(opts Options) error {
func (b *LocalBackend) updateFilter(netMap *controlclient.NetworkMap) { func (b *LocalBackend) updateFilter(netMap *controlclient.NetworkMap) {
// TODO(apenwarr): don't replace filter at all if unchanged. // TODO(apenwarr): don't replace filter at all if unchanged.
// TODO(apenwarr): print a diff instead of full filter. // TODO(apenwarr): print a diff instead of full filter.
if netMap == nil || b.Prefs().ShieldsUp { if netMap == nil {
// Not configured yet or shields up, block everything // Not configured yet, block everything
b.logf("netmap packet filter: (not ready yet)")
b.e.SetFilter(filter.NewAllowNone())
} else if b.Prefs().ShieldsUp {
// Shields up, block everything
b.logf("netmap packet filter: (shields up)") b.logf("netmap packet filter: (shields up)")
b.e.SetFilter(filter.NewAllowNone()) b.e.SetFilter(filter.NewAllowNone())
} else { } else {
now := time.Now() now := time.Now()
if now.Sub(b.lastFilterPrint) > 1*time.Minute { if now.Sub(b.lastFilterPrint) > 1*time.Minute {
b.logf("netmap packet filter: %v", b.netMapCache.PacketFilter) b.logf("netmap packet filter: %v", netMap.PacketFilter)
b.lastFilterPrint = now b.lastFilterPrint = now
} else { } else {
b.logf("netmap packet filter: (suppressed)") b.logf("netmap packet filter: (length %d)", len(netMap.PacketFilter))
} }
b.e.SetFilter(filter.New(netMap.PacketFilter, b.e.GetFilter())) b.e.SetFilter(filter.New(netMap.PacketFilter, b.e.GetFilter()))
} }

Loading…
Cancel
Save