mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 15:32:38 -07:00
Bump dnspython from 2.2.1 to 2.3.0 (#1975)
* Bump dnspython from 2.2.1 to 2.3.0 Bumps [dnspython](https://github.com/rthalley/dnspython) from 2.2.1 to 2.3.0. - [Release notes](https://github.com/rthalley/dnspython/releases) - [Changelog](https://github.com/rthalley/dnspython/blob/master/doc/whatsnew.rst) - [Commits](https://github.com/rthalley/dnspython/compare/v2.2.1...v2.3.0) --- updated-dependencies: - dependency-name: dnspython dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update dnspython==2.3.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
6910079330
commit
32c06a8b72
137 changed files with 7699 additions and 4277 deletions
|
@ -2,16 +2,17 @@
|
|||
|
||||
"""DNS Versioned Zones."""
|
||||
|
||||
from typing import Callable, Deque, Optional, Set, Union
|
||||
|
||||
import collections
|
||||
try:
|
||||
import threading as _threading
|
||||
except ImportError: # pragma: no cover
|
||||
import dummy_threading as _threading # type: ignore
|
||||
import threading
|
||||
|
||||
import dns.exception
|
||||
import dns.immutable
|
||||
import dns.name
|
||||
import dns.node
|
||||
import dns.rdataclass
|
||||
import dns.rdataset
|
||||
import dns.rdatatype
|
||||
import dns.rdtypes.ANY.SOA
|
||||
import dns.zone
|
||||
|
@ -30,16 +31,27 @@ ImmutableVersion = dns.zone.ImmutableVersion
|
|||
Transaction = dns.zone.Transaction
|
||||
|
||||
|
||||
class Zone(dns.zone.Zone):
|
||||
class Zone(dns.zone.Zone): # lgtm[py/missing-equals]
|
||||
|
||||
__slots__ = ['_versions', '_versions_lock', '_write_txn',
|
||||
'_write_waiters', '_write_event', '_pruning_policy',
|
||||
'_readers']
|
||||
__slots__ = [
|
||||
"_versions",
|
||||
"_versions_lock",
|
||||
"_write_txn",
|
||||
"_write_waiters",
|
||||
"_write_event",
|
||||
"_pruning_policy",
|
||||
"_readers",
|
||||
]
|
||||
|
||||
node_factory = Node
|
||||
|
||||
def __init__(self, origin, rdclass=dns.rdataclass.IN, relativize=True,
|
||||
pruning_policy=None):
|
||||
def __init__(
|
||||
self,
|
||||
origin: Optional[Union[dns.name.Name, str]],
|
||||
rdclass: dns.rdataclass.RdataClass = dns.rdataclass.IN,
|
||||
relativize: bool = True,
|
||||
pruning_policy: Optional[Callable[["Zone", Version], Optional[bool]]] = None,
|
||||
):
|
||||
"""Initialize a versioned zone object.
|
||||
|
||||
*origin* is the origin of the zone. It may be a ``dns.name.Name``,
|
||||
|
@ -51,28 +63,30 @@ class Zone(dns.zone.Zone):
|
|||
*relativize*, a ``bool``, determine's whether domain names are
|
||||
relativized to the zone's origin. The default is ``True``.
|
||||
|
||||
*pruning policy*, a function taking a `Version` and returning
|
||||
a `bool`, or `None`. Should the version be pruned? If `None`,
|
||||
*pruning policy*, a function taking a ``Zone`` and a ``Version`` and returning
|
||||
a ``bool``, or ``None``. Should the version be pruned? If ``None``,
|
||||
the default policy, which retains one version is used.
|
||||
"""
|
||||
super().__init__(origin, rdclass, relativize)
|
||||
self._versions = collections.deque()
|
||||
self._version_lock = _threading.Lock()
|
||||
self._versions: Deque[Version] = collections.deque()
|
||||
self._version_lock = threading.Lock()
|
||||
if pruning_policy is None:
|
||||
self._pruning_policy = self._default_pruning_policy
|
||||
else:
|
||||
self._pruning_policy = pruning_policy
|
||||
self._write_txn = None
|
||||
self._write_event = None
|
||||
self._write_waiters = collections.deque()
|
||||
self._readers = set()
|
||||
self._commit_version_unlocked(None,
|
||||
WritableVersion(self, replacement=True),
|
||||
origin)
|
||||
self._write_txn: Optional[Transaction] = None
|
||||
self._write_event: Optional[threading.Event] = None
|
||||
self._write_waiters: Deque[threading.Event] = collections.deque()
|
||||
self._readers: Set[Transaction] = set()
|
||||
self._commit_version_unlocked(
|
||||
None, WritableVersion(self, replacement=True), origin
|
||||
)
|
||||
|
||||
def reader(self, id=None, serial=None): # pylint: disable=arguments-differ
|
||||
def reader(
|
||||
self, id: Optional[int] = None, serial: Optional[int] = None
|
||||
) -> Transaction: # pylint: disable=arguments-differ
|
||||
if id is not None and serial is not None:
|
||||
raise ValueError('cannot specify both id and serial')
|
||||
raise ValueError("cannot specify both id and serial")
|
||||
with self._version_lock:
|
||||
if id is not None:
|
||||
version = None
|
||||
|
@ -81,11 +95,12 @@ class Zone(dns.zone.Zone):
|
|||
version = v
|
||||
break
|
||||
if version is None:
|
||||
raise KeyError('version not found')
|
||||
raise KeyError("version not found")
|
||||
elif serial is not None:
|
||||
if self.relativize:
|
||||
oname = dns.name.empty
|
||||
else:
|
||||
assert self.origin is not None
|
||||
oname = self.origin
|
||||
version = None
|
||||
for v in reversed(self._versions):
|
||||
|
@ -96,14 +111,14 @@ class Zone(dns.zone.Zone):
|
|||
version = v
|
||||
break
|
||||
if version is None:
|
||||
raise KeyError('serial not found')
|
||||
raise KeyError("serial not found")
|
||||
else:
|
||||
version = self._versions[-1]
|
||||
txn = Transaction(self, False, version)
|
||||
self._readers.add(txn)
|
||||
return txn
|
||||
|
||||
def writer(self, replacement=False):
|
||||
def writer(self, replacement: bool = False) -> Transaction:
|
||||
event = None
|
||||
while True:
|
||||
with self._version_lock:
|
||||
|
@ -117,15 +132,16 @@ class Zone(dns.zone.Zone):
|
|||
# give up the lock, so that we hold the lock as
|
||||
# short a time as possible. This is why we call
|
||||
# _setup_version() below.
|
||||
self._write_txn = Transaction(self, replacement,
|
||||
make_immutable=True)
|
||||
self._write_txn = Transaction(
|
||||
self, replacement, make_immutable=True
|
||||
)
|
||||
# give up our exclusive right to make a Transaction
|
||||
self._write_event = None
|
||||
break
|
||||
# Someone else is writing already, so we will have to
|
||||
# wait, but we want to do the actual wait outside the
|
||||
# lock.
|
||||
event = _threading.Event()
|
||||
event = threading.Event()
|
||||
self._write_waiters.append(event)
|
||||
# wait (note we gave up the lock!)
|
||||
#
|
||||
|
@ -159,6 +175,7 @@ class Zone(dns.zone.Zone):
|
|||
# pylint: disable=unused-argument
|
||||
def _default_pruning_policy(self, zone, version):
|
||||
return True
|
||||
|
||||
# pylint: enable=unused-argument
|
||||
|
||||
def _prune_versions_unlocked(self):
|
||||
|
@ -174,25 +191,32 @@ class Zone(dns.zone.Zone):
|
|||
least_kept = min(txn.version.id for txn in self._readers)
|
||||
else:
|
||||
least_kept = self._versions[-1].id
|
||||
while self._versions[0].id < least_kept and \
|
||||
self._pruning_policy(self, self._versions[0]):
|
||||
while self._versions[0].id < least_kept and self._pruning_policy(
|
||||
self, self._versions[0]
|
||||
):
|
||||
self._versions.popleft()
|
||||
|
||||
def set_max_versions(self, max_versions):
|
||||
def set_max_versions(self, max_versions: Optional[int]) -> None:
|
||||
"""Set a pruning policy that retains up to the specified number
|
||||
of versions
|
||||
"""
|
||||
if max_versions is not None and max_versions < 1:
|
||||
raise ValueError('max versions must be at least 1')
|
||||
raise ValueError("max versions must be at least 1")
|
||||
if max_versions is None:
|
||||
def policy(*_):
|
||||
|
||||
def policy(zone, _): # pylint: disable=unused-argument
|
||||
return False
|
||||
|
||||
else:
|
||||
|
||||
def policy(zone, _):
|
||||
return len(zone._versions) > max_versions
|
||||
|
||||
self.set_pruning_policy(policy)
|
||||
|
||||
def set_pruning_policy(self, policy):
|
||||
def set_pruning_policy(
|
||||
self, policy: Optional[Callable[["Zone", Version], Optional[bool]]]
|
||||
) -> None:
|
||||
"""Set the pruning policy for the zone.
|
||||
|
||||
The *policy* function takes a `Version` and returns `True` if
|
||||
|
@ -245,30 +269,52 @@ class Zone(dns.zone.Zone):
|
|||
id = 1
|
||||
return id
|
||||
|
||||
def find_node(self, name, create=False):
|
||||
def find_node(
|
||||
self, name: Union[dns.name.Name, str], create: bool = False
|
||||
) -> dns.node.Node:
|
||||
if create:
|
||||
raise UseTransaction
|
||||
return super().find_node(name)
|
||||
|
||||
def delete_node(self, name):
|
||||
def delete_node(self, name: Union[dns.name.Name, str]) -> None:
|
||||
raise UseTransaction
|
||||
|
||||
def find_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE,
|
||||
create=False):
|
||||
def find_rdataset(
|
||||
self,
|
||||
name: Union[dns.name.Name, str],
|
||||
rdtype: Union[dns.rdatatype.RdataType, str],
|
||||
covers: Union[dns.rdatatype.RdataType, str] = dns.rdatatype.NONE,
|
||||
create: bool = False,
|
||||
) -> dns.rdataset.Rdataset:
|
||||
if create:
|
||||
raise UseTransaction
|
||||
rdataset = super().find_rdataset(name, rdtype, covers)
|
||||
return dns.rdataset.ImmutableRdataset(rdataset)
|
||||
|
||||
def get_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE,
|
||||
create=False):
|
||||
def get_rdataset(
|
||||
self,
|
||||
name: Union[dns.name.Name, str],
|
||||
rdtype: Union[dns.rdatatype.RdataType, str],
|
||||
covers: Union[dns.rdatatype.RdataType, str] = dns.rdatatype.NONE,
|
||||
create: bool = False,
|
||||
) -> Optional[dns.rdataset.Rdataset]:
|
||||
if create:
|
||||
raise UseTransaction
|
||||
rdataset = super().get_rdataset(name, rdtype, covers)
|
||||
return dns.rdataset.ImmutableRdataset(rdataset)
|
||||
if rdataset is not None:
|
||||
return dns.rdataset.ImmutableRdataset(rdataset)
|
||||
else:
|
||||
return None
|
||||
|
||||
def delete_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE):
|
||||
def delete_rdataset(
|
||||
self,
|
||||
name: Union[dns.name.Name, str],
|
||||
rdtype: Union[dns.rdatatype.RdataType, str],
|
||||
covers: Union[dns.rdatatype.RdataType, str] = dns.rdatatype.NONE,
|
||||
) -> None:
|
||||
raise UseTransaction
|
||||
|
||||
def replace_rdataset(self, name, replacement):
|
||||
def replace_rdataset(
|
||||
self, name: Union[dns.name.Name, str], replacement: dns.rdataset.Rdataset
|
||||
) -> None:
|
||||
raise UseTransaction
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue