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

Can't parse files without ports in status.log #16

Open
stemenn opened this issue Mar 31, 2020 · 1 comment
Open

Can't parse files without ports in status.log #16

stemenn opened this issue Mar 31, 2020 · 1 comment

Comments

@stemenn
Copy link

stemenn commented Mar 31, 2020

I have an openvpn-status.log like that one:

OpenVPN CLIENT LIST
Updated,Tue Mar 31 12:14:41 2020
Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
s4-mini,xxx.xxx.xxx.xxx,3747660,15781519,Tue Mar 31 04:33:44 2020
ROUTING TABLE
Virtual Address,Common Name,Real Address,Last Ref
fd8b:ed45::1:10,s4-mini,xxx.xxx.xxx.xxx,Tue Mar 31 12:12:50 2020
10.8.1.10,s4-mini,xxx.xxx.xxx.xxx,Tue Mar 31 12:17:10 2020
GLOBAL STATS
Max bcast/mcast queue length,0
END

So there is no port given in the file. The xxx.xxx.xxx.xxx is most times an ipv4, but it can also be an ipv6.

When I try to parse the file with the parse, I get this error message:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/descriptors.py", line 31, in __set__
value = self.input_type(value)
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/utils.py", line 29, in parse_peer
host, port = peer.rsplit(':', 1)
ValueError: not enough values to unpack (expected 2, got 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/parser.py", line 84, in parse
return self._parse()
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/parser.py", line 98, in _parse
for c in self._parse_fields(Client, Status.routing_table.label)})
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/parser.py", line 96, in
status.client_list.update({
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/parser.py", line 132, in _parse_fields
setattr(instance, name, value)
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/descriptors.py", line 33, in __set__
raise AssignmentValueError(e)
openvpn_status.descriptors.AssignmentValueError: not enough values to unpack (expected 2, got 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/shortcuts.py", line 18, in parse_status
return parser.parse()
File "/usr/local/lib/python3.6/dist-packages/openvpn_status/parser.py", line 89, in parse
raise ParsingError('expected valid format: %s' % msg)
openvpn_status.parser.ParsingError: expected valid format: not enough values to unpack (expected 2, got 1)

It seems that there has to be an port in the file, but my Server ist not writing one into it.
I am using Openvpn 2.4.4 on Ubuntu

@dset0x
Copy link

dset0x commented Apr 24, 2020

I have also been hit by this.

openvpn consciously does not include a port for IPv6 addresses (for me it doesn't show them for IPv4 either when running with udp6). (https://github.com/OpenVPN/openvpn/blob/9cf7b4925a54d93fbea1cadcf3dc0e11f3ce358f/src/openvpn/mroute.c#L506)

I think this is particularly problematic because it prevents one from joining the CLIENT LIST with the ROUTING TABLE models on the IP:port. I suspect openvpn could had been using brackets (a-la curl) but I am not at all versed in IPv6 intricacies to be able to make a call. At any rate, just keep in mind that even if openvpn-status works around this, it will still break client code out there.

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

No branches or pull requests

2 participants