diff --git a/web/system.py b/web/system.py index a5e130c..8d2d699 100644 --- a/web/system.py +++ b/web/system.py @@ -42,15 +42,6 @@ def run(fun, args=()): fun(*args) multiprocessing.Process(target=task).start() -# For a network named 'xyzzy-foo', return xyzzy. Used for creating -# ipsets for office-* and server-* networks. -def network_group(name): - match name.split('-'): - case group, _: - return group - case _: - return None - def ipset_add(ipsets, name, ip=None, ip6=None): ipsets[name].update(ip or ()) ipsets[f'{name}/6'].update(ip6 or ()) @@ -95,11 +86,10 @@ def save_config(): # Populate IP sets. ipsets = collections.defaultdict(set) + # Sets corresponding to VLANs in NetBox. Prefixes for these sets are configured on firewall nodes with ansible. for name, network in db.read('networks').items(): - if group := network_group(name): - ipset_add(ipsets, group, network.get('ip'), network.get('ip6')) - ipset_add(ipsets, name, network.get('ip'), network.get('ip6')) - + ipset_add(ipsets, name) + # Sets defined by user in friwall app. for name, network in db.read('ipsets').items(): ipset_add(ipsets, name, network.get('ip'), network.get('ip6')) @@ -110,8 +100,6 @@ def save_config(): ip4 = [f'{ip}/32'] ip6 = [f'{key["ip6"]}'] if key.get('ip6') else None for network in user_networks.get(key.get('user', ''), ()): - if group := network_group(network): - ipset_add(ipsets, group, ip4, ip6) ipset_add(ipsets, network, ip4, ip6) # Create config files.