moby / vpnkit

A toolkit for embedding VPN capabilities in your application
Apache License 2.0
1.1k stars 187 forks source link

Base idle time calculations on a CPU counter, not a wall clock #527

Closed djs55 closed 3 years ago

djs55 commented 3 years ago

Previously we used the wall clock via Unix.gettimeofday() to compute the idle time for "endpoints" (remote destinations). When a laptop wakes from sleep, the wall clock jumps forward and suddenly all the endpoints are idle and the connections are dropped.

This patch switches to a monotonic clock which is driven by a CPU counter. The counter is paused while the computer sleeps and therefore does not jump forwards on wake.

This patch also adds a log message whenever an "endpoint" is deleted, to make debugging problems easier.

Signed-off-by: David Scott dave@recoil.org