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

Fix some bugs #298

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions openpyn/openpyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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"]

Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions openpyn/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down