From 3265d215498dd18ab25f444f7385aecccb34fed7 Mon Sep 17 00:00:00 2001 From: Leonard Slass Date: Wed, 31 May 2023 15:01:41 +0200 Subject: [PATCH 1/4] support pull-filter syntax --- openpyn/openpyn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpyn/openpyn.py b/openpyn/openpyn.py index 40dee23..cabfef5 100644 --- a/openpyn/openpyn.py +++ b/openpyn/openpyn.py @@ -100,7 +100,7 @@ def parse_args(argv: List[str]) -> argparse.Namespace: '--no-redirect-gateway', dest='no_redirect', help='Don\'t set --redirect-gateway', action='store_true') openvpn_internal_options.add_argument( '-o', '--openvpn-options', dest='openvpn_options', type=str, help='Pass through OpenVPN \ - options, e.g. openpyn uk -o \'--status /var/log/status.log --log /var/log/log.log\'') + options, e.g. openpyn uk -o \'--redirect-gateway --pull-filter ignore "redirect-gateway def1"\'') connect_options = parser.add_argument_group("Connect Options", "Connect To A Specific Server Or Any In A Country; TCP or UDP") @@ -1356,7 +1356,7 @@ def run_openvpn(*args): "--status", "{}/openvpn-status".format(log_folder), "30", "--config", vpn_config_file, *args, - ] + openvpn_options.split() + ] + shlex.split(openvpn_options) completed = subprocess.run(cmdline, check=True) # "killall openvpn" - the default signal sent is SIGTERM From d192c64f2ed5a75ca9940265552c3918f4af72f7 Mon Sep 17 00:00:00 2001 From: Leonard Slass Date: Wed, 31 May 2023 15:03:55 +0200 Subject: [PATCH 2/4] don't localize ping interval it fails on french locale --- openpyn/openpyn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpyn/openpyn.py b/openpyn/openpyn.py index cabfef5..e6a23fe 100644 --- a/openpyn/openpyn.py +++ b/openpyn/openpyn.py @@ -813,7 +813,7 @@ def ping_servers(better_servers_list: List, stats: bool) -> List: ping_supports_option_i = True # older ping command doesn't support "-i" try: - subprocess.check_output(["ping", "-n", "-i", locale.str(0.2), "-c", "2", "8.8.8.8"], stderr=subprocess.DEVNULL) + subprocess.check_output(["ping", "-n", "-i", "0.2", "-c", "2", "8.8.8.8"], stderr=subprocess.DEVNULL) except subprocess.CalledProcessError: # when Exception, the processes issued error, "option is not supported" ping_supports_option_i = False From 57cf5879061cdbebdf72b003df5f088008f1f91d Mon Sep 17 00:00:00 2001 From: Leonard Slass Date: Wed, 31 May 2023 15:08:32 +0200 Subject: [PATCH 3/4] wait for DNS to be available in systemd it's better than sleeping which does not work --- openpyn/systemd.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openpyn/systemd.py b/openpyn/systemd.py index 85526f7..fa77af2 100644 --- a/openpyn/systemd.py +++ b/openpyn/systemd.py @@ -32,16 +32,14 @@ def update_service(openpyn_options: str, run=False) -> None: openpyn_options = openpyn_options.replace("-d ", "") openpyn_options = openpyn_options.replace("--daemon", "") openpyn_location = shutil.which("openpyn") - sleep_location = shutil.which("sleep") service_text = ( "[Unit]\nDescription=NordVPN connection manager\nWants=network-online.target\n" + "After=network-online.target\nAfter=multi-user.target\n[Service]\nType=simple\nUser=root\n" + "WorkingDirectory=" + __basefilepath__ - + "\nExecStartPre=" - + sleep_location - + " 5\nExecStart=" + + "\nExecStartPre=/bin/sh -c 'until host google.com; do sleep 1; done'" + + "\nExecStart=" + openpyn_location + " " + openpyn_options From 59e3660b9311065eabe1d025d8057088a9db3ef1 Mon Sep 17 00:00:00 2001 From: Leonard Slass Date: Wed, 31 May 2023 15:20:11 +0200 Subject: [PATCH 4/4] Remove other localization of ping time --- openpyn/openpyn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpyn/openpyn.py b/openpyn/openpyn.py index e6a23fe..60f939a 100644 --- a/openpyn/openpyn.py +++ b/openpyn/openpyn.py @@ -822,7 +822,7 @@ def ping_servers(better_servers_list: List, stats: bool) -> List: " slow" ) if ping_supports_option_i is True: - ping_subprocess_command = ["ping", "-n", "-i", locale.str(0.2), "-c", "5", "dns_placeholder"] + ping_subprocess_command = ["ping", "-n", "-i", "0.2", "-c", "5", "dns_placeholder"] else: ping_subprocess_command = ["ping", "-c", "5", "dns_placeholder"]