defguard icon indicating copy to clipboard operation
defguard copied to clipboard

Simplify VPN client disconnect process

Open wojcik91 opened this issue 3 months ago • 2 comments
trafficstars

Currently we have at least 3 places where a determination is made whether a VPN client is connected/disconnected:

  • peer stats in network overview
  • when receiving network stats in order to generate connected/disconnected events for the activity log
  • in the periodic peer disconnect for MFA-enabled locations

Some of those use different time thresholds and run at different times, so they can generate conflicting results.

We should migrate to a unified solution that would handle all of those use-cases.

My proposal is to put all of this logic into a dedicated service whose purpose it would be to handle wireguard peer stats updates. Aside from determining whether a client is connected or not (and storing those sessions in the DB) we could also use it to pre-process incoming stats to avoid using expensive views for generating traffic stats.

wojcik91 avatar Jul 22 '25 11:07 wojcik91