diff --git a/lib/dns.py b/lib/dns.py index 8d09d53..c56d4f7 100644 --- a/lib/dns.py +++ b/lib/dns.py @@ -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' @@ -34,7 +32,6 @@ lines.append( format_var( name=var, - append=APPENDIX_4, data=values_v4, version=4, ) @@ -44,7 +41,6 @@ lines.append( format_var( name=var, - append=APPENDIX_6, data=values_v6, version=6, ) diff --git a/lib/util.py b/lib/util.py index 2b38c30..375b29e 100644 --- a/lib/util.py +++ b/lib/util.py @@ -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}' @@ -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}'