From a5c4de07b0512518d07aee2624c4ff314d09b778 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 2 Apr 2023 13:23:40 +0200 Subject: [PATCH] VPN: OpenVPN: Connection Status - missing mapping for client stats, closes https://github.com/opnsense/core/issues/6464 --- src/opnsense/scripts/openvpn/ovpn_status.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/opnsense/scripts/openvpn/ovpn_status.py b/src/opnsense/scripts/openvpn/ovpn_status.py index 7d6613364..cdd7d17df 100755 --- a/src/opnsense/scripts/openvpn/ovpn_status.py +++ b/src/opnsense/scripts/openvpn/ovpn_status.py @@ -63,11 +63,15 @@ def ovpn_status(filename): return {'status': 'failed'} header_def = [] + client_fieldnames = {'read_bytes': 'bytes_received', 'write_bytes': 'bytes_sent'} target_struct = None for line in buffer.split('\n'): if line.startswith('TCP/UDP'): line = line.split(',') - response[line[0][8:].replace(' ', '_')] = line[1].strip() + fieldname = line[0][8:].replace(' ', '_') + if fieldname in client_fieldnames: + fieldname = client_fieldnames[fieldname] + response[fieldname] = line[1].strip() continue line = line.split('\t') if line[0] == 'HEADER': @@ -100,7 +104,7 @@ def ovpn_state(filename): response['timestamp'] = int(tmp[0]) response['status'] = tmp[1].lower() response['virtual_address'] = tmp[3] if len(tmp) > 3 else "" - response['remote_host'] = tmp[4] if len(tmp) > 4 else "" + response['real_address'] = tmp[4] if len(tmp) > 4 else "" return response