Skip to content

Commit 0c5aecb

Browse files
committed
ipn/wg: enforce min refresh interval
1 parent 7d94591 commit 0c5aecb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

intra/ipn/wgproxy.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ const (
8282

8383
FAST = x.WGFAST
8484

85-
refreshInterval = 2 * time.Minute
85+
refreshInterval = 2 * time.Minute // refresh interval between onNotOKs
86+
minRefreshInterval = 5 * time.Second // hard refresh interval; roughly one re-send handshake timeout
8687

8788
noviaid = ""
8889
)
@@ -362,7 +363,13 @@ func (w *wgproxy) Refresh() (err error) {
362363
// TODO: skip on s == TUP?
363364
if w.tooyoung() {
364365
log.VV("proxy: wg: %s refresh skipped; too young; status(%s)", w.tag(), pxstatus(status))
365-
return
366+
return // TODO: err?
367+
}
368+
369+
lastRefresh := w.latestRefresh.Load()
370+
if now()-lastRefresh < minRefreshInterval.Milliseconds() {
371+
log.VV("proxy: wg: %s refresh skipped; done recently; status(%s)", w.tag(), pxstatus(status))
372+
return // TODO: err?
366373
}
367374

368375
w.latestRefresh.Store(now())

0 commit comments

Comments
 (0)