import dns.name
from dns.name import Name
from dns.node import Node
+import dns.rdata
from dns.rdata import Rdata
from dns.rdataclass import RdataClass
from dns.rdatatype import RdataType
self.aliases = []
- self.zone = dns.zone.Zone(origin=self.name, rdclass=RdataClass.IN)
+ self.zone = Zone(origin=self.name, rdclass=RdataClass.IN)
self.update_soa()
@property
def dump(self, file: Optional[TextIO] = None) -> None:
# Could use self.zone.to_file(sys.stdout), but we want better formatting
file = file or sys.stdout
+ assert file is not None
file.write(self.zone_header())
file.write(f'$TTL\t\t{self.config.default_ttl}\n\n')
last_name = None
rds_aaaa = node.get_rdataset(RdataClass.IN, RdataType.AAAA)
if rds_a or rds_aaaa:
mx_rds = node.get_rdataset(RdataClass.IN, RdataType.MX, create=True)
+ assert mx_rds is not None
if not mx_rds:
mx_rds.add(
dns.rdtypes.ANY.MX.MX(RdataClass.IN, RdataType.MX, 0, dns.name.root),
primary_server: IPAddress
secondary_file: Path
- def __init__(self, *args, primary_server=IPAddress, **kwargs) -> None:
+ def __init__(self, *args, primary_server: IPAddress, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.zone_type = ZoneType.secondary
self.primary_server = primary_server
class NscZoneAlias(NscZone):
alias_for: NscZonePrimary
- def __init__(self, *args, alias_for=NscZonePrimary, **kwargs) -> None:
+ def __init__(self, *args, alias_for: NscZonePrimary, **kwargs) -> None:
assert isinstance(alias_for, NscZonePrimary)
super().__init__(*args, **kwargs)
self.zone_type = ZoneType.alias
alias_for: Optional[NscZonePrimary] = None,
secondary_to: str | IPAddress | None = None,
inherit_config: Optional[NscZoneConfig] = None,
- **kwargs) -> Zone:
+ **kwargs) -> NscZone:
if inherit_config is None:
inherit_config = self.default_zone_config
from enum import Enum, auto
from ipaddress import ip_address, IPv4Address, IPv6Address, ip_network, IPv4Network, IPv6Network
from datetime import timedelta
-from typing import Any, List, Optional
+from typing import Any, List
IPAddress = IPv4Address | IPv6Address