Browse Source

Move _NetworkValueBaseFilter down with it's children

pull/1094/head
Ross McFarland 2 years ago
parent
commit
de3ec8e094
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
1 changed files with 29 additions and 29 deletions
  1. +29
    -29
      octodns/processor/filter.py

+ 29
- 29
octodns/processor/filter.py View File

@ -127,35 +127,6 @@ class _NameBaseFilter(BaseProcessor):
process_target_zone = _process
class _NetworkValueBaseFilter(BaseProcessor):
def __init__(self, name, _list):
super().__init__(name)
self.networks = []
for value in _list:
try:
self.networks.append(ip_network(value))
except ValueError:
raise ValueError(f'{value} is not a valid CIDR to use')
def _process(self, zone, *args, **kwargs):
for record in zone.records:
if record._type not in ['A', 'AAAA']:
continue
ips = [ip_address(value) for value in record.values]
if any(
ip in network for ip, network in product(ips, self.networks)
):
self.matches(zone, record)
else:
self.doesnt_match(zone, record)
return zone
process_source_zone = _process
process_target_zone = _process
class NameAllowlistFilter(_NameBaseFilter, AllowsMixin):
'''Only manage records with names that match the provider patterns
@ -220,6 +191,35 @@ class NameRejectlistFilter(_NameBaseFilter, RejectsMixin):
super().__init__(name, rejectlist)
class _NetworkValueBaseFilter(BaseProcessor):
def __init__(self, name, _list):
super().__init__(name)
self.networks = []
for value in _list:
try:
self.networks.append(ip_network(value))
except ValueError:
raise ValueError(f'{value} is not a valid CIDR to use')
def _process(self, zone, *args, **kwargs):
for record in zone.records:
if record._type not in ['A', 'AAAA']:
continue
ips = [ip_address(value) for value in record.values]
if any(
ip in network for ip, network in product(ips, self.networks)
):
self.matches(zone, record)
else:
self.doesnt_match(zone, record)
return zone
process_source_zone = _process
process_target_zone = _process
class NetworkValueAllowlistFilter(_NetworkValueBaseFilter, AllowsMixin):
'''Only manage A and AAAA records with values that match the provider patterns
All other types will be left as-is.


Loading…
Cancel
Save