Skip to content

Fix compatibility with newer Python and OpenVPN versions #50

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

Merged
merged 5 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__author__ = "duc_tin"
__copyright__ = "Copyright 2015+, duc_tin"
__license__ = "GPLv2"
__version__ = "1.25"
__version__ = "1.26"
__maintainer__ = "duc_tin"
__email__ = "[email protected]"

Expand Down Expand Up @@ -170,7 +170,7 @@ def get_input(s, option):
class Setting:
def __init__(self, path):
self.path = path
self.parser = configparser.SafeConfigParser()
self.parser = configparser.ConfigParser()

self.proxy = OrderedDict([('use_proxy', 'no'), ('address', ''),
('port', ''),
Expand Down
14 changes: 7 additions & 7 deletions ui_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__author__ = "duc_tin"
__copyright__ = "Copyright 2015+, duc_tin"
__license__ = "GPLv2"
__version__ = "1.25"
__version__ = "1.26"
__maintainer__ = "duc_tin"
__email__ = "[email protected]"

Expand Down Expand Up @@ -88,7 +88,7 @@ def __init__(self, key=None, value=''):

self.pile = urwid.Pile([ping, speed, uptime, score], focus_item=default[self.chosen])
fill = urwid.LineBox(urwid.Filler(self.pile))
self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))
super().__init__(urwid.AttrWrap(fill, 'popbg'))

def item_callback(self, Button, data=None):
self.chosen = self.pile.focus.label
Expand Down Expand Up @@ -117,7 +117,7 @@ def __init__(self, key=None, value=''):

self.pile = urwid.Pile([info]+filter_)
fill = urwid.LineBox(urwid.Filler(self.pile))
self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))
super().__init__(urwid.AttrWrap(fill, 'popbg'))

self.chosen = value

Expand Down Expand Up @@ -199,7 +199,7 @@ def __init__(self, key=None, value=('', '')):

self.pile = urwid.Pile(widgets)
fill = urwid.LineBox(urwid.Filler(self.pile))
self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))
super().__init__(urwid.AttrWrap(fill, 'popbg'))

self.chosen = value

Expand Down Expand Up @@ -265,7 +265,7 @@ def __init__(self, key=None, value=('', '')):

self.pile = urwid.Pile(widgets)
fill = urwid.LineBox(urwid.Filler(self.pile))
self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))
super().__init__(urwid.AttrWrap(fill, 'popbg'))

self.chosen = value

Expand All @@ -292,14 +292,14 @@ class AddPopUp(urwid.PopUpLauncher):
signals = ['done']

def __init__(self, target_widget, popup, value, trigger, size):
self.__super.__init__(target_widget)
super().__init__(target_widget)
self.popup = popup(key=trigger, value=value)
self.trigger = trigger
self.size = size
self.result = value

def create_pop_up(self):
# this method must be exist due to its blank content in original class
# this method must exist due to its blank content in original class
urwid.connect_signal(self.popup, 'close', self.close_pop)
return self.popup

Expand Down
4 changes: 2 additions & 2 deletions vpnproxy_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__author__ = "duc_tin"
__copyright__ = "Copyright 2015+, duc_tin"
__license__ = "GPLv2"
__version__ = "1.36"
__version__ = "1.37"
__maintainer__ = "duc_tin"
__email__ = "[email protected]"

Expand Down Expand Up @@ -291,7 +291,7 @@ def vpn_manager(ovpn):
"""
global dns, verbose, dropped_time

command = ['openvpn', '--config', ovpn]
command = ['openvpn', '--data-ciphers', 'AES-256-GCM:AES-128-GCM:AES-128-CBC:CHACHA20-POLY1305', '--config', ovpn]
p = Popen(command, stdout=PIPE, stdin=PIPE, universal_newlines=True)
try:
while p.poll() is None:
Expand Down
8 changes: 4 additions & 4 deletions vpnproxy_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__author__ = "duc_tin"
__copyright__ = "Copyright 2015+, duc_tin"
__license__ = "GPLv2"
__version__ = "1.5"
__version__ = "1.6"
__maintainer__ = "duc_tin"
__email__ = "[email protected]"

Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(self, data):
self.logPolicy = data[11]
self.config_data = base64.b64decode(data[-1]).decode()
self.proto = 'tcp' if '\r\nproto tcp\r\n' in self.config_data else 'udp'
port = re.findall('remote .+ \d+', self.config_data)
port = re.findall(r'remote .+ \d+', self.config_data)
if not port:
self.port = '0'
else:
Expand Down Expand Up @@ -490,7 +490,7 @@ def vpn_connect(self, chosen):
vpn_file.close()

ovpn = vpn_file.name
command = ['openvpn', '--config', ovpn]
command = ['openvpn', '--data-ciphers', 'AES-256-GCM:AES-128-GCM:AES-128-CBC:CHACHA20-POLY1305', '--config', ovpn]
p = Popen(command, stdout=PIPE, stderr=PIPE, bufsize=1, close_fds=ON_POSIX, universal_newlines=True)
q = Queue()
t = Thread(target=self.vpn_output, args=(p.stdout, q))
Expand All @@ -510,7 +510,7 @@ def vpn_cleanup(self, status_code=0):

# make sure openvpn did close its device
tuntap = Popen(['ip', 'tuntap'], stdout=PIPE, universal_newlines=True).communicate()[0]
devices = re.findall('tun\d+', tuntap)
devices = re.findall(r'tun\d+', tuntap)
for dev in devices:
call(('ip link delete ' + dev).split())

Expand Down