From 015fba50ca51280d139001affde4b1f1ceedc749 Mon Sep 17 00:00:00 2001 From: Slawomir Koszewski Date: Mon, 26 Oct 2026 02:10:38 +0100 Subject: [PATCH] fix: the status gives the number of connected OpenVPN clients at most 5 seconds old instead of up to a minute. --- README.md | 2 +- debian-package/debian/changelog | 9 +++++++++ debian-package/src/usr/lib/vpn-router/vpnrouter.py | 3 +++ .../src/usr/lib/vpn-router/vpnrouter_status.py | 3 +++ .../share/vpn-router/templates/openvpn-server.conf.j2 | 2 ++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e6f513a..d0c459e 100644 --- a/README.md +++ b/README.md @@ -885,7 +885,7 @@ The status holds the state of `vpn-router-setup`, `slapd` and each PostgreSQL cl `vpn-router-manager` when that package is installed, of `strongswan` when site-to-site or road-warrior access is configured, of `wg-quick@wg0` when WireGuard is, and of `openvpn-server@vpn-router` when OpenVPN is; the number of connected -OpenVPN clients, from the server's status file, which OpenVPN rewrites every minute; the package version and, +OpenVPN clients, from the server's status file, which OpenVPN rewrites every 5 seconds; the package version and, as `manager_version`, the installed version of `vpn-router-manager` (`null`, shown as not installed, without it); whether Docker is installed, and when it is, the state of `docker.service` and of `vpn-router-docker` (the Docker rules), which do not change `status`; as `site_to_site`, the number of site-to-site diff --git a/debian-package/debian/changelog b/debian-package/debian/changelog index 49e208b..e9f9516 100644 --- a/debian-package/debian/changelog +++ b/debian-package/debian/changelog @@ -1,3 +1,12 @@ +vpn-router (0.24.1-1) unstable; urgency=medium + + fix: the status gives the number of connected OpenVPN clients at most 5 seconds old instead of up to a minute. + + * The OpenVPN server writes its status file every 5 seconds, so a + refresh of the status shows clients that connected or left since. + + -- Slawomir Koszewski Mon, 02 Nov 2026 23:30:00 +0100 + vpn-router (0.24.0-1) unstable; urgency=medium feature: /remote-access of the web service shows and changes the settings of IKEv2 road-warrior, OpenVPN and WireGuard access and whether each runs, for the Router Manager's Remote access page. diff --git a/debian-package/src/usr/lib/vpn-router/vpnrouter.py b/debian-package/src/usr/lib/vpn-router/vpnrouter.py index 1f59543..6f028d7 100644 --- a/debian-package/src/usr/lib/vpn-router/vpnrouter.py +++ b/debian-package/src/usr/lib/vpn-router/vpnrouter.py @@ -26,6 +26,7 @@ if str(LIB_DIR) not in sys.path: import vpnrouter_ldap import vpnrouter_pki import vpnrouter_platforms +import vpnrouter_status from vpnrouter_net import DEFAULT_LISTEN, LISTEN_CHOICES, LOOPBACK, ConfigError, detect_interfaces, interface_addresses, ip_output CONFIG_FILE = pathlib.Path('/etc/vpn-router/vpn-router.json') @@ -896,6 +897,8 @@ def build_context(cfg, public_ip=None): 'openvpn_protocol': _get(cfg, 'openvpn', 'protocol'), 'openvpn_device': OPENVPN_DEVICE, 'openvpn_ldap_conf': str(OPENVPN_LDAP), + 'openvpn_status': vpnrouter_status.OPENVPN_STATUS, + 'openvpn_status_seconds': vpnrouter_status.OPENVPN_STATUS_SECONDS, 'p2s_dns_list': _split_list(_join(local_addrs, _split_list(extras['EXTRA_P2S_DNS']))), 'openvpn_ca': str(vpnrouter_pki.OPENVPN_CA), 'openvpn_crl': str(vpnrouter_pki.OPENVPN_CRL), diff --git a/debian-package/src/usr/lib/vpn-router/vpnrouter_status.py b/debian-package/src/usr/lib/vpn-router/vpnrouter_status.py index 4c73054..6c3fa56 100644 --- a/debian-package/src/usr/lib/vpn-router/vpnrouter_status.py +++ b/debian-package/src/usr/lib/vpn-router/vpnrouter_status.py @@ -12,6 +12,9 @@ COMMAND_TIMEOUT = 5 OPENVPN_STATUS = '/run/openvpn-server/status-vpn-router.log' +#: Seconds between two writes of OPENVPN_STATUS by the OpenVPN server, whose configuration sets it (OpenVPN's default is 60). +OPENVPN_STATUS_SECONDS = 5 + #: Seconds since its last handshake within which a WireGuard peer counts as connected. WIREGUARD_CONNECTED_SECONDS = 180 diff --git a/debian-package/src/usr/share/vpn-router/templates/openvpn-server.conf.j2 b/debian-package/src/usr/share/vpn-router/templates/openvpn-server.conf.j2 index 11736d7..061ad8f 100644 --- a/debian-package/src/usr/share/vpn-router/templates/openvpn-server.conf.j2 +++ b/debian-package/src/usr/share/vpn-router/templates/openvpn-server.conf.j2 @@ -24,6 +24,8 @@ push "route {{ network }} {{ netmask }}" push "dhcp-option DNS {{ address }}" {% endfor -%} +status {{ openvpn_status }} {{ openvpn_status_seconds }} + keepalive 10 120 {% if openvpn_protocol == 'udp' -%} explicit-exit-notify 1