Skip to content

Commit 658b43b

Browse files
authored
fix(flashstart): fix euci sync issue and disabled WAN DHCP resolver (#1250)
1 parent a0c7000 commit 658b43b

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

packages/ns-flashstart/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ uci commit flashstart
4040
reload_config
4141
```
4242

43+
## Debug mode
44+
45+
The daemon can be run in various logging levels, to set the levels you can:
46+
47+
```
48+
uci set flashstart.global.log_level="debug"
49+
uci commit flashstart
50+
reload_config
51+
```
52+
53+
To check for the logging levels available, please refer to the CLI utility help:
54+
55+
```
56+
ns-flashstart --help
57+
```
58+
4359
## CLI utility
4460

4561
The script `/usr/sbin/ns-flashstart` can be used to manage the client from command line. To see the

packages/ns-flashstart/files/ns-flashstart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ DEFAULT_HEADERS = {
2828

2929
CONST_PORT_START = 5300
3030

31+
# this wrapper is more hideous than it looks. UCI config gets read ONLY ONCE WHEN INSTANTIATED, beware of that.
3132
e_uci = EUci()
3233

34+
def __refresh_uci():
35+
global e_uci
36+
e_uci = EUci()
37+
38+
3339
def __get_client() -> requests.Session:
3440
session = requests.Session()
3541
session.headers.update(DEFAULT_HEADERS)
@@ -215,6 +221,9 @@ def __add_profile(port, profile):
215221
e_uci.set('dhcp', profile['id'], 'ns_flashstart_profile', profile["name"])
216222
e_uci.set('dhcp', profile['id'], 'ns_flashstart_dns_code', profile["dns_code"])
217223
e_uci.set('dhcp', profile['id'], 'port', port)
224+
e_uci.set('dhcp', profile['id'], 'noresolv', True)
225+
e_uci.set('dhcp', profile['id'], 'max_ttl', 60)
226+
e_uci.set('dhcp', profile['id'], 'max_cache_ttl', 60)
218227
# sets always get replaced, checking before replacing
219228
custom_servers = list(e_uci.get('flashstart', 'global', 'custom_servers', list=True, dtype=str, default=[]))
220229
servers = sorted(custom_servers + profile['servers'])
@@ -359,9 +368,9 @@ def __sync_pro_plus_profiles():
359368

360369

361370
def sync():
362-
__sync_host_sets()
363371
if e_uci.get('flashstart', 'global', 'proplus', default=False, dtype=bool):
364372
logging.debug('Syncing pro+ profiles')
373+
__sync_host_sets()
365374
__sync_pro_plus_profiles()
366375
else:
367376
logging.debug('Syncing pro profiles')
@@ -419,7 +428,7 @@ def ping():
419428
cmd = ["curl", "-s", "--connect-timeout", "10", "--interface", wan, url]
420429
res = subprocess.run(cmd, capture_output=True, text=True)
421430
if res.returncode != 0:
422-
raise Exception(f'Failed to update IP for WAN {wan} -> {wan_id} with error: {res.stdout}')
431+
logging.warning(f'Failed to update IP for WAN {wan} -> {wan_id} with error: {res.stdout}')
423432
counter = counter + 1
424433

425434

@@ -495,6 +504,8 @@ def main():
495504
except Exception as e:
496505
logging.error(f'Unexpected error: {e}')
497506
event_handler.wait(wait_time)
507+
# re-init the UCI object to avoid issues with the config being changed
508+
__refresh_uci()
498509
# remove the config
499510
disable()
500511
case 'ping':

packages/ns-flashstart/files/ns-flashstart.init

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ USE_PROCD=1
1010

1111
start_service() {
1212
config_load flashstart
13-
local enabled
13+
local enabled log_level
1414
config_get enabled global enabled
15+
config_get log_level global log_level "warning"
1516

1617
if [ "$enabled" != "1" ]; then
1718
return 0
1819
fi
1920
procd_open_instance
20-
procd_set_param command /usr/sbin/ns-flashstart daemon
21+
procd_set_param command /usr/sbin/ns-flashstart --log-level "$log_level" daemon
2122
procd_set_param stdout 1
2223
procd_set_param stderr 1
2324
procd_set_param respawn 3600 60 0

packages/ns-flashstart/files/uci-default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ then
4747
done
4848
# set default
4949
uci -q set flashstart.global.proplus=0
50+
uci -q set flashstart.global.log_level=warning
5051
uci commit flashstart
5152
fi

0 commit comments

Comments
 (0)