Skip to content

Commit

Permalink
move util to dns-addon-repo
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Dec 20, 2024
1 parent 1478e22 commit 7a44e4c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
PROCESS_IPv6 = True

# paths are set in util (shared between addons)
CONFIG_FILE = 'failover.json'
CONFIG_FILE_KEY = 'failover'
OUT_FILE = 'failover.nft'
KEY = 'failover'
TIMEOUT = 2 # sec
PROCESS_PROTOS = ['ip4']
if PROCESS_IPv6:
Expand All @@ -28,10 +26,10 @@ def _is_reachable(ip: str, port: (str, int), ip_proto: str) -> bool:
return s.connect_ex((ip, port)) == 0


CONFIG = load_config(file=CONFIG_FILE, key=CONFIG_FILE_KEY)
CONFIG = load_config(KEY)

if CONFIG is None or len(CONFIG) == 0:
raise SystemExit(f"Config file could not be loaded: '{CONFIG_FILE}'!")
raise SystemExit('Failover Config-file could not be loaded!')


lines = []
Expand Down Expand Up @@ -86,4 +84,4 @@ def _is_reachable(ip: str, port: (str, int), ip_proto: str) -> bool:
)
)

validate_and_write(lines=lines, file=OUT_FILE, key=CONFIG_FILE_KEY)
validate_and_write(lines=lines, key=KEY)

0 comments on commit 7a44e4c

Please sign in to comment.