$坙栞m_J�0�54燸杆w%1h吲 �動?睦�/�# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose with or without fee is hereby granted, # provided that the above copyright notice and this permission notice # appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """DNS Dynamic Update Support""" from typing import Any, List, Optional, Union import dns.message import dns.name import dns.opcode import dns.rdata import dns.rdataclass import dns.rdataset import dns.rdatatype import dns.tsig class UpdateSection(dns.enum.IntEnum): """Update sections""" ZONE = 0 PREREQ = 1 UPDATE = 2 ADDITIONAL = 3 @classmethod def _maximum(cls): return 3 class UpdateMessage(dns.message.Message): # lgtm[py/missing-equals] # ignore the mypy error here as we mean to use a different enum _section_enum = UpdateSection # type: ignore def __init__( self, zone: Optional[Union[dns.name.Name, str]] = None, rdclass: dns.rdataclass.RdataClass = dns.rdataclass.IN, keyring: Optional[Any] = None, keyname: Optional[dns.name.Name] = None, keyalgorithm: Union[dns.name.Name, str] = dns.tsig.default_algorithm, id: Optional[int] = None, ): """Initialize a new DNS Update object. See the documentation of the Message class for a complete description of the keyring dictionary. *zone*, a ``dns.name.Name``, ``str``, or ``None``, the zone which is being updated. ``None`` should only be used by dnspython's message constructors, as a zone is required for the convenience methods like ``add()``, ``replace()``, etc. *rdclass*, an ``int`` or ``str``, the class of the zone. The *keyring*, *keyname*, and *keyalgorithm* parameters are passed to ``use_tsig()``; see its documentation for details. """ super().__init__(id=id) self.flags |= dns.opcode.to_flags(dns.opcode.UPDATE) if isinstance(zone, str): zone = dns.name.from_text(zone) self.origin = zone rdclass = dns.rdataclass.RdataClass.make(rdclass) self.zone_rdclass = rdclass if self.origin: self.find_rrset( self.zone, self.origin, rdclass, dns.rdatatype.SOA, create=True, force_unique=True, ) if keyring is not None: self.use_tsig(keyring, keyname, algorithm=keyalgorithm) @property def zone(self) -> List[dns.rrset.RRset]: """The zone section.""" return self.sections[0] @zone.setter def zone(self, v): self.sections[0] = v @property def prerequisite(self) -> List[dns.rrset.RRset]: """The prerequisite section.""" return self.sections[1] @prerequisite.setter def prerequisite(self, v): self.sections[1] = v @property def update(self) -> List[dns.rrset.RRset]: """The update section.""" return self.sections[2] @update.setter def update(self, v): self.sections[2] = v def _add_rr(self, name, ttl, rd, deleting=None, section=None): """Add a single RR to the update section.""" if section is None: section = self.update covers = rd.covers() rrset = self.find_rrset( section, name, self.zone_rdclass, rd.rdtyp