Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when parsing "connected since" field #3

Open
N-Mi opened this issue Dec 16, 2021 · 0 comments · May be fixed by #5
Open

Exception when parsing "connected since" field #3

N-Mi opened this issue Dec 16, 2021 · 0 comments · May be fixed by #5

Comments

@N-Mi
Copy link

N-Mi commented Dec 16, 2021

It seems my version of OpenVPN (2.5.1) has more fields in the client list than what is expected, which causes an exception while getting the client list from the parser object:

>>> from openvpn_status_parser import OpenVPNStatusParser
>>> import pprint
>>> parser = OpenVPNStatusParser("/tmp/status.log")
>>> pprint.pprint(parser.connected_clients)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nicolas/git/openvpn-status-parser/openvpn_status_parser/__init__.py", line 141, in connected_clients
    self._parse_file()
  File "/home/nicolas/git/openvpn-status-parser/openvpn_status_parser/__init__.py", line 120, in _parse_file
    self.title_processors[row_title](row)
  File "/home/nicolas/git/openvpn-status-parser/openvpn_status_parser/__init__.py", line 83, in _process_client_list
    self._connected_clients[row[1]]["connected_since"] = (datetime.datetime.fromtimestamp(int(row[-1])))
ValueError: invalid literal for int() with base 10: 'AES-256-CBC'

My OpenVPN server is configured with option "status-version 3".

Here is the (anonymized) status file :

TITLE	OpenVPN 2.5.1 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on May 14 2021
TIME	2021-12-16 16:13:52	1639667632
HEADER	CLIENT_LIST	Common Name	Real Address	Virtual Address	Virtual IPv6 Address	Bytes Received	Bytes Sent	Connected Since	Connected Since (time_t)	Username	Client ID	Peer ID	Data Channel Cipher
CLIENT_LIST	UNDEF	1.2.3.4:56736	10.42.42.2		67638680	45432322	2021-12-14 10:34:46	1639474486	my_user	609	0	AES-256-CBC
HEADER	ROUTING_TABLE	Virtual Address	Common Name	Real Address	Last Ref	Last Ref (time_t)
ROUTING_TABLE	96:03:2d:9d:0d:40@0	UNDEF	1.2.3.4:56736	2021-12-16 16:13:51	1639667631
GLOBAL_STATS	Max bcast/mcast queue length	1
END

The issue is caused because openvpn-status-parser is expecting the "Connected Since (time_t)" to be the last field ( row[-1])

I'll submit a PR fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant