ojarva / openvpn-status-parser

Parser for openvpn status file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImportError: cannot import name OpenVPNStatusParser

ondrj opened this issue · comments

Hello, when I try to run following script on my VPS, I got "ImportError: cannot import name OpenVPNStatusParser"
Any idea where the problem could be?

Thanks in advance.
Here's my code:

`import re
from subprocess import *
from openvpn_status_parser import OpenVPNStatusParser

PORTS = [5555, 9876, 38388]
REGEX_PATTERN = re.compile(r'\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}')

parser = OpenVPNStatusParser("/etc/openvpn/openvpn-status.log")

vpn_list = []
for row in parser.connected_clients:
real_address = parser.connected_clients[row]['Real Address']
for match in re.findall(REGEX_PATTERN, real_address):
vpn_list.append(match)

adb_devices_output = check_output(["adb", "devices"])

adb_list = []
for match in re.findall(REGEX_PATTERN, adb_devices_output):
adb_list.append(match)

print( 'VPN "%s"' % vpn_list)
print( 'ADB "%s"' % adb_list)

diff_list = list(set(vpn_list) - set(adb_list))
print( 'DIFF "%s"' % diff_list)

for ip in diff_list:
for port in PORTS:
ip_with_port = ip + ':' + str(port)
result = check_output(["adb", "connect", ip_with_port])
if 'connected' in result:
print( 'Connected %s' % ip_with_port)
break
else:
print( 'Failed to connect %s' % ip_with_port)`

Note that I have installed openvpn-status-parser via pip on Linux.

Hi @ondrj ,

It has been a while, sorry about that 🤦

I guess it is safe to say this issue is no longer relevant. However, I just published a new version (0.0.3) with no functional changes (but a bunch of modernization things). At least for me that works fine.