@@ -28,8 +28,14 @@ DEFAULT_HEADERS = {
2828
2929CONST_PORT_START = 5300
3030
31+ # this wrapper is more hideous than it looks. UCI config gets read ONLY ONCE WHEN INSTANTIATED, beware of that.
3132e_uci = EUci ()
3233
34+ def __refresh_uci ():
35+ global e_uci
36+ e_uci = EUci ()
37+
38+
3339def __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
361370def 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' :
0 commit comments