Skip to content

Commit

Permalink
fix(ns-flashstart): preserve WAN order (#957)
Browse files Browse the repository at this point in the history
Changes on the registration script:

- preserve WAN order: make sure that the same id is always
  associated to the same WAN
- fix registration for PPPoE WANs: previously curl was
  using the underlying eth interface instead of the ppp one


#955
  • Loading branch information
gsanchietti authored Dec 6, 2024
1 parent 225c40b commit 5a0e30d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/ns-flashstart/files/flashstart-auth
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#

from euci import EUci
from nethsec import utils
import subprocess
import sys
import syslog
Expand All @@ -22,8 +21,18 @@ if not u.get("flashstart", "global", "enabled", default=False):

user = u.get("flashstart", "global", "username", default="")
password = u.get("flashstart", "global", "password", default="")

# Get WAN devices from fw4 to get the real device names, including pppx interfaces for PPPoE
wan_devices = set()
res = subprocess.run(["/sbin/fw4", "zone", "wan"], capture_output=True, text=True)
if res.returncode != 0:
syslog.syslog(syslog.LOG_ERR, f'Failed to get WAN devices with error: {res.stdout}')
sys.exit(1)
wan_devices.update([line.strip() for line in res.stdout.splitlines() if line.strip()])

# Order the devices to make sure to not mix ids for the same device
counter = 0
for wan in utils.get_all_wan_devices(u):
for wan in sorted(wan_devices):
if counter > 0:
id = f"{user}-{counter}"
else:
Expand Down

0 comments on commit 5a0e30d

Please sign in to comment.