From 225c40bf98a21ffe64052d5740e35cc847b25fc3 Mon Sep 17 00:00:00 2001 From: Bailetti Tommaso Date: Thu, 5 Dec 2024 15:02:59 +0100 Subject: [PATCH] fix(flashstart): fixed pinging issues (#956) Also added logging in case curl fails #955 --- packages/ns-flashstart/files/flashstart-apply | 2 +- packages/ns-flashstart/files/flashstart-auth | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/ns-flashstart/files/flashstart-apply b/packages/ns-flashstart/files/flashstart-apply index fd3e46b41..21b2c6e9c 100644 --- a/packages/ns-flashstart/files/flashstart-apply +++ b/packages/ns-flashstart/files/flashstart-apply @@ -27,7 +27,7 @@ if [ "$enabled" = "1" ]; then /etc/init.d/dnsdist restart fi /usr/share/ns-flashstart/flashstart-auth - crontab -l | grep -q '/usr/share/ns-flashstart/flashstart-auth' || echo '*/30 * * * * sleep $$(( RANDOM % 60 )); /usr/share/ns-flashstart/flashstart-auth' >> /etc/crontabs/root + crontab -l | grep -q '/usr/share/ns-flashstart/flashstart-auth' || echo '*/30 * * * * sleep $(( RANDOM % 60 )); /usr/share/ns-flashstart/flashstart-auth' >> /etc/crontabs/root else crontab -l | grep -v '/usr/share/ns-flashstart/flashstart-auth' | sort | uniq | crontab - rm -f "$conf" diff --git a/packages/ns-flashstart/files/flashstart-auth b/packages/ns-flashstart/files/flashstart-auth index 49c443364..5fe8cb7c4 100644 --- a/packages/ns-flashstart/files/flashstart-auth +++ b/packages/ns-flashstart/files/flashstart-auth @@ -12,6 +12,8 @@ from euci import EUci from nethsec import utils import subprocess +import sys +import syslog u = EUci() @@ -27,6 +29,8 @@ for wan in utils.get_all_wan_devices(u): else: id = user url = f"https://ddns.flashstart.com/nic/update?hostname=&myip=&wildcard=NOCHG&username={id}&password={password}" - cmd = ["curl", "-s", "-o", "/dev/null", "--interface", wan, url] - subprocess.run(cmd) + cmd = ["curl", "-s", "--connect-timeout", "10", "--interface", wan, url] + res = subprocess.run(cmd, capture_output=True, text=True) + if res.returncode != 0: + syslog.syslog(syslog.LOG_ERR, f'Failed to update IP for WAN {wan} -> {id} with error: {res.stdout}') counter = counter + 1