summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/ipsec-settings.py18
-rwxr-xr-xsrc/op_mode/ping.py2
2 files changed, 14 insertions, 6 deletions
diff --git a/src/conf_mode/ipsec-settings.py b/src/conf_mode/ipsec-settings.py
index cbe4ba376..7ba2284d8 100755
--- a/src/conf_mode/ipsec-settings.py
+++ b/src/conf_mode/ipsec-settings.py
@@ -224,12 +224,18 @@ def restart_ipsec():
# so we can't assume it's running and have to check and wait if needed.
# First, wait for charon to get started by the old ipsec.pl script.
- wait_for_file_write_complete(charon_pidfile, timeout=120)
-
- # Now actually restart the daemon
- wait_for_file_write_complete(charon_pidfile,
- pre_hook=(lambda: call('ipsec restart >&/dev/null')),
- timeout=120)
+ from time import sleep, time
+ from os import system
+ now = time()
+ while True:
+ if (time() - now) > 60:
+ raise OSError("Timeout waiting for the IPsec process to become responsive")
+ # There's no oficial "no-op" stroke,
+ # so we use memusage to check if charon is alive and responsive
+ res = system("ipsec stroke memusage >&/dev/null")
+ if res == 0:
+ break
+ sleep(5)
# Force configuration load
call('swanctl -q >&/dev/null')
diff --git a/src/op_mode/ping.py b/src/op_mode/ping.py
index 924a889db..610f6a05d 100755
--- a/src/op_mode/ping.py
+++ b/src/op_mode/ping.py
@@ -220,6 +220,8 @@ if __name__ == '__main__':
try:
ip = socket.gethostbyname(host)
+ except UnicodeError:
+ sys.exit(f'ping: Unknown host: {host}')
except socket.gaierror:
ip = host