diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-12-21 18:26:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-21 18:26:44 +0100 |
commit | 3a795c8d0dcf42a6daf4ecc6a2a5d8281bf5e999 (patch) | |
tree | d3ecdc969500a08b1e15ccbfa404ab80c8c34c51 /src/completion/list_openvpn_clients.py | |
parent | 36b59b0c87376e6b91bf56475343cb0ced1149fb (diff) | |
parent | 1951413f8a3e1681fa8ef5898bd9e31134080a9d (diff) | |
download | vyos-1x-3a795c8d0dcf42a6daf4ecc6a2a5d8281bf5e999.tar.gz vyos-1x-3a795c8d0dcf42a6daf4ecc6a2a5d8281bf5e999.zip |
Merge pull request #654 from DmitriyEshenko/fix-openvpn-21122020
openvpn: T3142: Change the path to tunnel status file
Diffstat (limited to 'src/completion/list_openvpn_clients.py')
-rwxr-xr-x | src/completion/list_openvpn_clients.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/completion/list_openvpn_clients.py b/src/completion/list_openvpn_clients.py index 177ac90c9..b443520ea 100755 --- a/src/completion/list_openvpn_clients.py +++ b/src/completion/list_openvpn_clients.py @@ -22,20 +22,23 @@ from vyos.ifconfig import Section def get_client_from_interface(interface): clients = [] - with open('/opt/vyatta/etc/openvpn/status/' + interface + '.status', 'r') as f: - dump = False - for line in f: - if line.startswith("Common Name,"): - dump = True - continue - if line.startswith("ROUTING TABLE"): - dump = False - continue - if dump: - # client entry in this file looks like - # client1,172.18.202.10:47495,2957,2851,Sat Aug 17 00:07:11 2019 - # we are only interested in the client name 'client1' - clients.append(line.split(',')[0]) + try: + with open('/run/openvpn/' + interface + '.status', 'r') as f: + dump = False + for line in f: + if line.startswith("Common Name,"): + dump = True + continue + if line.startswith("ROUTING TABLE"): + dump = False + continue + if dump: + # client entry in this file looks like + # client1,172.18.202.10:47495,2957,2851,Sat Aug 17 00:07:11 2019 + # we are only interested in the client name 'client1' + clients.append(line.split(',')[0]) + except: + pass return clients |