Description
boringtun relies on on std::time::Instant to deal with handshake timeout, session timeout, keep-alive, etc. Under the hood, std::time::Instant uses the following APIs (https://doc.rust-lang.org/std/time/struct.Instant.html#underlying-system-calls)
Windows => QueryPerformanceCounter
macOS => mach_absolute_time
Linux => clock_gettime
These timers do not exhibit the same behavior when the OS is asleep
Windows:
QueryPerformanceCounter reads the performance counter and returns the total number of ticks that have occurred since the Windows operating system was started, including the time when the machine was in a sleep state such as standby, hibernate, or connected standby.
https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
macOS:
this clock does not increment while the system is asleep.
https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time
Linux (I couldn't find any docs).
I think std::time::Instant maybe the wrong clock to use here? My main concern is macOS. After waking from sleep the timers are not properly updated.
There is already a change out for rust std::time::Instant here: rust-lang/rust#88714