diff options
author | morpheus65535 <[email protected]> | 2022-11-07 13:06:49 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2022-11-07 13:08:27 -0500 |
commit | bbe2483e21c2c1549ceeed16f021f9581b899f70 (patch) | |
tree | bcc2bef2f55789ec6e6c64809c07fb4f4d3d9c86 /libs/dns | |
parent | 708fbfcd8ec0620647975be39a1f6acbbf08f767 (diff) | |
download | bazarr-bbe2483e21c2c1549ceeed16f021f9581b899f70.tar.gz bazarr-bbe2483e21c2c1549ceeed16f021f9581b899f70.zip |
Updated vendored dependencies.
Diffstat (limited to 'libs/dns')
-rw-r--r-- | libs/dns/_immutable_attr.py | 2 | ||||
-rw-r--r-- | libs/dns/asyncquery.pyi | 6 | ||||
-rw-r--r-- | libs/dns/dnssec.py | 2 | ||||
-rw-r--r-- | libs/dns/exception.py | 2 | ||||
-rw-r--r-- | libs/dns/exception.pyi | 2 | ||||
-rw-r--r-- | libs/dns/message.py | 2 | ||||
-rw-r--r-- | libs/dns/query.py | 4 | ||||
-rw-r--r-- | libs/dns/rdata.py | 2 | ||||
-rw-r--r-- | libs/dns/rdataset.py | 2 | ||||
-rw-r--r-- | libs/dns/rdtypes/ANY/TKEY.py | 2 | ||||
-rw-r--r-- | libs/dns/rdtypes/ANY/__init__.py | 4 | ||||
-rw-r--r-- | libs/dns/rdtypes/svcbbase.py | 2 | ||||
-rw-r--r-- | libs/dns/rdtypes/txtbase.pyi | 8 | ||||
-rw-r--r-- | libs/dns/renderer.py | 4 | ||||
-rw-r--r-- | libs/dns/resolver.py | 10 | ||||
-rw-r--r-- | libs/dns/resolver.pyi | 7 | ||||
-rw-r--r-- | libs/dns/tokenizer.py | 7 | ||||
-rw-r--r-- | libs/dns/transaction.py | 13 | ||||
-rw-r--r-- | libs/dns/tsigkeyring.py | 1 | ||||
-rw-r--r-- | libs/dns/version.py | 2 | ||||
-rw-r--r-- | libs/dns/versioned.py | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | libs/dns/win32util.py | 0 | ||||
-rw-r--r-- | libs/dns/zone.py | 30 |
23 files changed, 87 insertions, 29 deletions
diff --git a/libs/dns/_immutable_attr.py b/libs/dns/_immutable_attr.py index f7b9f8b0b..4d89be905 100644 --- a/libs/dns/_immutable_attr.py +++ b/libs/dns/_immutable_attr.py @@ -49,7 +49,7 @@ def _immutable_init(f): f(*args, **kwargs) finally: if not previous: - # If we started the initialzation, establish immutability + # If we started the initialization, establish immutability # by removing the attribute that allows mutation object.__delattr__(args[0], '_immutable_init') nf.__signature__ = inspect.signature(f) diff --git a/libs/dns/asyncquery.pyi b/libs/dns/asyncquery.pyi index 21ef60dd4..a03434c2c 100644 --- a/libs/dns/asyncquery.pyi +++ b/libs/dns/asyncquery.pyi @@ -19,7 +19,7 @@ async def udp(q : message.Message, where : str, one_rr_per_rrset : Optional[bool] = False, ignore_trailing : Optional[bool] = False, sock : Optional[asyncbackend.DatagramSocket] = None, - backend : Optional[asyncbackend.Backend]) -> message.Message: + backend : Optional[asyncbackend.Backend] = None) -> message.Message: pass async def tcp(q : message.Message, where : str, timeout : float = None, port=53, @@ -28,7 +28,7 @@ async def tcp(q : message.Message, where : str, timeout : float = None, port=53, one_rr_per_rrset : Optional[bool] = False, ignore_trailing : Optional[bool] = False, sock : Optional[asyncbackend.StreamSocket] = None, - backend : Optional[asyncbackend.Backend]) -> message.Message: + backend : Optional[asyncbackend.Backend] = None) -> message.Message: pass async def tls(q : message.Message, where : str, @@ -37,7 +37,7 @@ async def tls(q : message.Message, where : str, one_rr_per_rrset : Optional[bool] = False, ignore_trailing : Optional[bool] = False, sock : Optional[asyncbackend.StreamSocket] = None, - backend : Optional[asyncbackend.Backend], + backend : Optional[asyncbackend.Backend] = None, ssl_context: Optional[ssl.SSLContext] = None, server_hostname: Optional[str] = None) -> message.Message: pass diff --git a/libs/dns/dnssec.py b/libs/dns/dnssec.py index 6e9946f4f..dee4e6181 100644 --- a/libs/dns/dnssec.py +++ b/libs/dns/dnssec.py @@ -108,7 +108,7 @@ def key_id(key): return total & 0xffff class DSDigest(dns.enum.IntEnum): - """DNSSEC Delgation Signer Digest Algorithm""" + """DNSSEC Delegation Signer Digest Algorithm""" SHA1 = 1 SHA256 = 2 diff --git a/libs/dns/exception.py b/libs/dns/exception.py index 939237349..083938215 100644 --- a/libs/dns/exception.py +++ b/libs/dns/exception.py @@ -125,7 +125,7 @@ class TooBig(DNSException): class Timeout(DNSException): """The DNS operation timed out.""" supp_kwargs = {'timeout'} - fmt = "The DNS operation timed out after {timeout} seconds" + fmt = "The DNS operation timed out after {timeout:.3f} seconds" class ExceptionWrapper: diff --git a/libs/dns/exception.pyi b/libs/dns/exception.pyi index b29bfbea1..dc5712649 100644 --- a/libs/dns/exception.pyi +++ b/libs/dns/exception.pyi @@ -8,3 +8,5 @@ class DNSException(Exception): class SyntaxError(DNSException): ... class FormError(DNSException): ... class Timeout(DNSException): ... +class TooBig(DNSException): ... +class UnexpectedEnd(SyntaxError): ... diff --git a/libs/dns/message.py b/libs/dns/message.py index 1e67a17b8..c2751a90c 100644 --- a/libs/dns/message.py +++ b/libs/dns/message.py @@ -509,7 +509,7 @@ class Message: expected to return a key. *keyname*, a ``dns.name.Name``, ``str`` or ``None``, the name of - thes TSIG key to use; defaults to ``None``. If *keyring* is a + this TSIG key to use; defaults to ``None``. If *keyring* is a ``dict``, the key must be defined in it. If *keyring* is a ``dns.tsig.Key``, this is ignored. diff --git a/libs/dns/query.py b/libs/dns/query.py index fbf76d8bc..6d924b5fe 100644 --- a/libs/dns/query.py +++ b/libs/dns/query.py @@ -1085,10 +1085,10 @@ def inbound_xfr(where, txn_manager, query=None, *udp_mode*, a ``dns.query.UDPMode``, determines how UDP is used for IXFRs. The default is ``dns.UDPMode.NEVER``, i.e. only use - TCP. Other possibilites are ``dns.UDPMode.TRY_FIRST``, which + TCP. Other possibilities are ``dns.UDPMode.TRY_FIRST``, which means "try UDP but fallback to TCP if needed", and ``dns.UDPMode.ONLY``, which means "try UDP and raise - ``dns.xfr.UseTCP`` if it does not succeeed. + ``dns.xfr.UseTCP`` if it does not succeed. Raises on errors. """ diff --git a/libs/dns/rdata.py b/libs/dns/rdata.py index 624063e00..6b5b5c5a3 100644 --- a/libs/dns/rdata.py +++ b/libs/dns/rdata.py @@ -557,7 +557,7 @@ class GenericRdata(Rdata): raise dns.exception.SyntaxError( r'generic rdata does not start with \#') length = tok.get_int() - hex = tok.concatenate_remaining_identifiers().encode() + hex = tok.concatenate_remaining_identifiers(True).encode() data = binascii.unhexlify(hex) if len(data) != length: raise dns.exception.SyntaxError( diff --git a/libs/dns/rdataset.py b/libs/dns/rdataset.py index e69ee2325..579bc9649 100644 --- a/libs/dns/rdataset.py +++ b/libs/dns/rdataset.py @@ -312,7 +312,7 @@ class Rdataset(dns.set.Set): def processing_order(self): """Return rdatas in a valid processing order according to the type's specification. For example, MX records are in preference order from - lowest to highest preferences, with items of the same perference + lowest to highest preferences, with items of the same preference shuffled. For types that do not define a processing order, the rdatas are diff --git a/libs/dns/rdtypes/ANY/TKEY.py b/libs/dns/rdtypes/ANY/TKEY.py index f8c473723..861fc4e35 100644 --- a/libs/dns/rdtypes/ANY/TKEY.py +++ b/libs/dns/rdtypes/ANY/TKEY.py @@ -63,7 +63,7 @@ class TKEY(dns.rdata.Rdata): error = tok.get_uint16() key_b64 = tok.get_string().encode() key = base64.b64decode(key_b64) - other_b64 = tok.concatenate_remaining_identifiers().encode() + other_b64 = tok.concatenate_remaining_identifiers(True).encode() other = base64.b64decode(other_b64) return cls(rdclass, rdtype, algorithm, inception, expiration, mode, diff --git a/libs/dns/rdtypes/ANY/__init__.py b/libs/dns/rdtypes/ANY/__init__.py index 6c56baffd..2cadcde3a 100644 --- a/libs/dns/rdtypes/ANY/__init__.py +++ b/libs/dns/rdtypes/ANY/__init__.py @@ -37,8 +37,12 @@ __all__ = [ 'HINFO', 'HIP', 'ISDN', + 'L32', + 'L64', 'LOC', + 'LP', 'MX', + 'NID', 'NINFO', 'NS', 'NSEC', diff --git a/libs/dns/rdtypes/svcbbase.py b/libs/dns/rdtypes/svcbbase.py index 09d7a52ba..3362571c4 100644 --- a/libs/dns/rdtypes/svcbbase.py +++ b/libs/dns/rdtypes/svcbbase.py @@ -435,7 +435,7 @@ class SVCBBase(dns.rdata.Rdata): if not isinstance(v, Param) and v is not None: raise ValueError("not a Param") self.params = dns.immutable.Dict(params) - # Make sure any paramater listed as mandatory is present in the + # Make sure any parameter listed as mandatory is present in the # record. mandatory = params.get(ParamKey.MANDATORY) if mandatory: diff --git a/libs/dns/rdtypes/txtbase.pyi b/libs/dns/rdtypes/txtbase.pyi index af447d500..f8d5df987 100644 --- a/libs/dns/rdtypes/txtbase.pyi +++ b/libs/dns/rdtypes/txtbase.pyi @@ -1,6 +1,12 @@ +import typing from .. import rdata class TXTBase(rdata.Rdata): - ... + strings: typing.Tuple[bytes, ...] + + def __init__(self, rdclass: int, rdtype: int, strings: typing.Iterable[bytes]) -> None: + ... + def to_text(self, origin: typing.Any, relativize: bool, **kw: typing.Any) -> str: + ... class TXT(TXTBase): ... diff --git a/libs/dns/renderer.py b/libs/dns/renderer.py index 72f0f7a8a..4e4391cd2 100644 --- a/libs/dns/renderer.py +++ b/libs/dns/renderer.py @@ -49,8 +49,8 @@ class Renderer: r.add_rrset(dns.renderer.ANSWER, rrset_2) r.add_rrset(dns.renderer.AUTHORITY, ns_rrset) r.add_edns(0, 0, 4096) - r.add_rrset(dns.renderer.ADDTIONAL, ad_rrset_1) - r.add_rrset(dns.renderer.ADDTIONAL, ad_rrset_2) + r.add_rrset(dns.renderer.ADDITIONAL, ad_rrset_1) + r.add_rrset(dns.renderer.ADDITIONAL, ad_rrset_2) r.write_header() r.add_tsig(keyname, secret, 300, 1, 0, '', request_mac) wire = r.get_wire() diff --git a/libs/dns/resolver.py b/libs/dns/resolver.py index 166f84921..7da7a6139 100644 --- a/libs/dns/resolver.py +++ b/libs/dns/resolver.py @@ -145,7 +145,7 @@ class LifetimeTimeout(dns.exception.Timeout): """The resolution lifetime expired.""" msg = "The resolution lifetime expired." - fmt = "%s after {timeout} seconds: {errors}" % msg[:-1] + fmt = "%s after {timeout:.3f} seconds: {errors}" % msg[:-1] supp_kwargs = {'timeout', 'errors'} def _fmt_kwargs(self, **kwargs): @@ -1018,7 +1018,7 @@ class Resolver(BaseResolver): *source_port*, an ``int``, the port from which to send the message. *lifetime*, a ``float``, how many seconds a query should run - before timing out. + before timing out. *search*, a ``bool`` or ``None``, determines whether the search list configured in the system's resolver configuration @@ -1101,7 +1101,7 @@ class Resolver(BaseResolver): """Query nameservers to find the answer to the question. This method calls resolve() with ``search=True``, and is - provided for backwards compatbility with prior versions of + provided for backwards compatibility with prior versions of dnspython. See the documentation for the resolve() method for further details. """ @@ -1200,7 +1200,7 @@ def query(qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN, """Query nameservers to find the answer to the question. This method calls resolve() with ``search=True``, and is - provided for backwards compatbility with prior versions of + provided for backwards compatibility with prior versions of dnspython. See the documentation for the resolve() method for further details. """ @@ -1253,7 +1253,7 @@ def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None, root servers in your network and they are misconfigured.) Raises ``dns.resolver.LifetimeTimeout`` if the answer could not be - found in the alotted lifetime. + found in the allotted lifetime. Returns a ``dns.name.Name``. """ diff --git a/libs/dns/resolver.pyi b/libs/dns/resolver.pyi index 6da21f125..348df4da4 100644 --- a/libs/dns/resolver.pyi +++ b/libs/dns/resolver.pyi @@ -25,7 +25,7 @@ def query(qname : str, rdtype : Union[int,str] = 0, tcp=False, source=None, raise_on_no_answer=True, source_port=0, lifetime : Optional[float]=None): ... -def resolve_address(self, ipaddr: str, *args: Any, **kwargs: Optional[Dict]): +def resolve_address(ipaddr: str, *args: Any, **kwargs: Optional[Dict]): ... class LRUCache: def __init__(self, max_size=1000): @@ -59,3 +59,8 @@ class Resolver: raise_on_no_answer=True, source_port : int = 0, lifetime : Optional[float]=None): ... +default_resolver: typing.Optional[Resolver] +def reset_default_resolver() -> None: + ... +def get_default_resolver() -> Resolver: + ... diff --git a/libs/dns/tokenizer.py b/libs/dns/tokenizer.py index 7ddc7a968..cb6a6302d 100644 --- a/libs/dns/tokenizer.py +++ b/libs/dns/tokenizer.py @@ -600,9 +600,12 @@ class Tokenizer: break return tokens - def concatenate_remaining_identifiers(self): + def concatenate_remaining_identifiers(self, allow_empty=False): """Read the remaining tokens on the line, which should be identifiers. + Raises dns.exception.SyntaxError if there are no remaining tokens, + unless `allow_empty=True` is given. + Raises dns.exception.SyntaxError if a token is seen that is not an identifier. @@ -618,6 +621,8 @@ class Tokenizer: if not token.is_identifier(): raise dns.exception.SyntaxError s += token.value + if not (allow_empty or s): + raise dns.exception.SyntaxError('expecting another identifier') return s def as_name(self, token, origin=None, relativize=False, relativize_to=None): diff --git a/libs/dns/transaction.py b/libs/dns/transaction.py index ae7417edb..d72549243 100644 --- a/libs/dns/transaction.py +++ b/libs/dns/transaction.py @@ -389,7 +389,7 @@ class Transaction: if rdataset.rdclass != self.manager.get_class(): raise ValueError(f'{method} has objects of wrong RdataClass') if rdataset.rdtype == dns.rdatatype.SOA: - (_, _, origin) = self.manager.origin_information() + (_, _, origin) = self._origin_information() if name != origin: raise ValueError(f'{method} has non-origin SOA') self._raise_if_not_empty(method, args) @@ -560,7 +560,7 @@ class Transaction: *commit*, a bool. If ``True``, commit the transaction, otherwise roll it back. - If committing adn the commit fails, then roll back and raise an + If committing and the commit fails, then roll back and raise an exception. """ raise NotImplementedError # pragma: no cover @@ -585,3 +585,12 @@ class Transaction: Returns a node or ``None``. """ raise NotImplementedError # pragma: no cover + + # + # Low-level API with a default implementation, in case a subclass needs + # to override. + # + + def _origin_information(self): + # This is only used by _add() + return self.manager.origin_information() diff --git a/libs/dns/tsigkeyring.py b/libs/dns/tsigkeyring.py index 47a1f79fa..788581c91 100644 --- a/libs/dns/tsigkeyring.py +++ b/libs/dns/tsigkeyring.py @@ -20,6 +20,7 @@ import base64 import dns.name +import dns.tsig def from_text(textring): diff --git a/libs/dns/version.py b/libs/dns/version.py index 745a5c7fc..65017872a 100644 --- a/libs/dns/version.py +++ b/libs/dns/version.py @@ -22,7 +22,7 @@ MAJOR = 2 #: MINOR MINOR = 2 #: MICRO -MICRO = 0 +MICRO = 1 #: RELEASELEVEL RELEASELEVEL = 0x0f #: SERIAL diff --git a/libs/dns/versioned.py b/libs/dns/versioned.py index 42f2c8140..8b6c275fd 100644 --- a/libs/dns/versioned.py +++ b/libs/dns/versioned.py @@ -131,7 +131,7 @@ class Zone(dns.zone.Zone): # # We only wake one sleeper at a time, so it's important # that no event waiter can exit this method (e.g. via - # cancelation) without returning a transaction or waking + # cancellation) without returning a transaction or waking # someone else up. # # This is not a problem with Threading module threads as diff --git a/libs/dns/win32util.py b/libs/dns/win32util.py index 745317a39..745317a39 100755..100644 --- a/libs/dns/win32util.py +++ b/libs/dns/win32util.py diff --git a/libs/dns/zone.py b/libs/dns/zone.py index 2e7314461..5a649404f 100644 --- a/libs/dns/zone.py +++ b/libs/dns/zone.py @@ -183,6 +183,11 @@ class Zone(dns.transaction.TransactionManager): "name parameter must be a subdomain of the zone origin") if self.relativize: name = name.relativize(self.origin) + elif not self.relativize: + # We have a relative name in a non-relative zone, so derelativize. + if self.origin is None: + raise KeyError('no zone origin is defined') + name = name.derelativize(self.origin) return name def __getitem__(self, key): @@ -870,11 +875,20 @@ class Version: def _validate_name(self, name): if name.is_absolute(): - if not name.is_subdomain(self.zone.origin): + if self.origin is None: + # This should probably never happen as other code (e.g. + # _rr_line) will notice the lack of an origin before us, but + # we check just in case! + raise KeyError('no zone origin is defined') + if not name.is_subdomain(self.origin): raise KeyError("name is not a subdomain of the zone origin") if self.zone.relativize: - # XXXRTH should it be an error if self.origin is still None? name = name.relativize(self.origin) + elif not self.zone.relativize: + # We have a relative name in a non-relative zone, so derelativize. + if self.origin is None: + raise KeyError('no zone origin is defined') + name = name.derelativize(self.origin) return name def get_node(self, name): @@ -1030,6 +1044,18 @@ class Transaction(dns.transaction.Transaction): def _get_node(self, name): return self.version.get_node(name) + def _origin_information(self): + (absolute, relativize, effective) = self.manager.origin_information() + if absolute is None and self.version.origin is not None: + # No origin has been committed yet, but we've learned one as part of + # this txn. Use it. + absolute = self.version.origin + if relativize: + effective = dns.name.empty + else: + effective = absolute + return (absolute, relativize, effective) + def from_text(text, origin=None, rdclass=dns.rdataclass.IN, relativize=True, zone_factory=Zone, filename=None, |