Drop static NAT support

Unused and never properly tested.
This commit is contained in:
Timotej Lazar 2025-10-29 13:38:21 +01:00
parent 2c7e20bb75
commit 331adbd5e4
2 changed files with 0 additions and 13 deletions

View file

@ -119,17 +119,6 @@ def save_config():
f.write(nft_set6.format(name=name, ips=make_set(data.get('ip6', ()))))
f.write('\n')
# Print static NAT (1:1) rules.
with open(output / 'etc/nftables.d/netmap.nft', 'w', encoding='utf-8') as f:
nft_map = 'map {name} {{\n type ipv4_addr : interval ipv4_addr; flags interval; elements = {{\n{ips}\n }}\n}}\n'
def make_map(ips, reverse=False):
# return "{ from1: to1, from2: to2, … }" with possibly reversed from and to
return ',\n'.join(f"{b if reverse else a}: {a if reverse else b}" for a, b in ips)
if netmap := db.read('netmap'): # { private range: public range… }
f.write(nft_map.format(name='netmap-out', ips=make_map(netmap.items())))
f.write('\n')
f.write(nft_map.format(name='netmap-in', ips=make_map(netmap.items(), reverse=True)))
# Print dynamic NAT rules.
with open(output / 'etc/nftables.d/nat.nft', 'w', encoding='utf-8') as f:
no_nat_set = settings.get('no_nat_set')