Skip to content

Commit

Permalink
moved appendix to util
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Aug 19, 2023
1 parent c9bcee2 commit 886b129
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 0 additions & 4 deletions lib/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
PROCESS_IPv6 = True

# paths are set in util (shared between addons)
APPENDIX_4 = '_v4'
APPENDIX_6 = '_v6'
CONFIG_FILE = 'dns.json'
CONFIG_FILE_KEY = 'dns'
OUT_FILE = 'dns.nft'
Expand All @@ -34,7 +32,6 @@
lines.append(
format_var(
name=var,
append=APPENDIX_4,
data=values_v4,
version=4,
)
Expand All @@ -44,7 +41,6 @@
lines.append(
format_var(
name=var,
append=APPENDIX_6,
data=values_v6,
version=6,
)
Expand Down
6 changes: 5 additions & 1 deletion lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
BASE_DIR = '/etc/nftables.d'
ADDON_DIR = '/etc/nftables.d/addons'
CONFIG_EXT = 'nft'
APPENDIX_4 = '_v4'
APPENDIX_6 = '_v6'

if not CONFIG_EXT.startswith('.'):
CONFIG_EXT = f'.{CONFIG_EXT}'
Expand All @@ -26,10 +28,12 @@
FILE_HEADER = '# Auto-Generated config - DO NOT EDIT MANUALLY!\n\n'


def format_var(name: str, data: list, version: int, append: str = None) -> str:
def format_var(name: str, data: list, version: int) -> str:
if version not in FALLBACK_VAR_VALUE:
version = 4

append = APPENDIX_4 if version == 4 else APPENDIX_6

if append not in [None, ' ', '']:
name = f'{name}_{append}'

Expand Down

0 comments on commit 886b129

Please sign in to comment.