Skip to content

Commit 804af3d

Browse files
committed
Dont record test packets as outbound traffic, do less if debug logs arent on
1 parent a31871c commit 804af3d

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

connection_manager.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,15 @@ func (n *connectionManager) getAndResetTrafficCheck(localIndex uint32) (bool, bo
130130
}
131131

132132
func (n *connectionManager) AddTrafficWatch(localIndex uint32) {
133-
n.Out(localIndex)
133+
// Use a write lock directly because it should be incredibly rare that we are ever already tracking this index
134+
n.outLock.Lock()
135+
if _, ok := n.out[localIndex]; ok {
136+
n.inLock.Unlock()
137+
return
138+
}
139+
n.out[localIndex] = struct{}{}
134140
n.trafficTimer.Add(localIndex, n.checkInterval)
141+
n.outLock.Unlock()
135142
}
136143

137144
func (n *connectionManager) Start(ctx context.Context) {
@@ -363,15 +370,19 @@ func (n *connectionManager) makeTrafficDecision(localIndex uint32, p, nb, out []
363370
return doNothing, nil, nil
364371
}
365372

366-
hostinfo.logger(n.l).
367-
WithField("tunnelCheck", m{"state": "testing", "method": "active"}).
368-
Debug("Tunnel status")
373+
if n.l.Level >= logrus.DebugLevel {
374+
hostinfo.logger(n.l).
375+
WithField("tunnelCheck", m{"state": "testing", "method": "active"}).
376+
Debug("Tunnel status")
377+
}
369378

370379
// Send a test packet to trigger an authenticated tunnel test, this should suss out any lingering tunnel issues
371380
n.intf.SendMessageToHostInfo(header.Test, header.TestRequest, hostinfo, p, nb, out)
372381

373382
} else {
374-
hostinfo.logger(n.l).Debugf("Hostinfo sadness")
383+
if n.l.Level >= logrus.DebugLevel {
384+
hostinfo.logger(n.l).Debugf("Hostinfo sadness")
385+
}
375386
}
376387

377388
n.pendingDeletion[hostinfo.localIndexId] = struct{}{}

punchy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (p *Punchy) reload(c *config.C, initial bool) {
7575
}
7676

7777
if initial || c.HasChanged("punchy.target_all_remotes") {
78-
p.punchEverything.Store(c.GetBool("punchy.target_all_remotes", true))
78+
p.punchEverything.Store(c.GetBool("punchy.target_all_remotes", false))
7979
if !initial {
8080
p.l.WithField("target_all_remotes", p.GetTargetEverything()).Info("punchy.target_all_remotes changed")
8181
}

0 commit comments

Comments
 (0)