Загрузить файлы в «venv/Lib/site-packages/dns/rdtypes/IN»
This commit is contained in:
9
venv/Lib/site-packages/dns/rdtypes/IN/HTTPS.py
Normal file
9
venv/Lib/site-packages/dns/rdtypes/IN/HTTPS.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
|
||||
|
||||
import dns.immutable
|
||||
import dns.rdtypes.svcbbase
|
||||
|
||||
|
||||
@dns.immutable.immutable
|
||||
class HTTPS(dns.rdtypes.svcbbase.SVCBBase):
|
||||
"""HTTPS record"""
|
||||
87
venv/Lib/site-packages/dns/rdtypes/IN/IPSECKEY.py
Normal file
87
venv/Lib/site-packages/dns/rdtypes/IN/IPSECKEY.py
Normal file
@@ -0,0 +1,87 @@
|
||||
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
|
||||
|
||||
# Copyright (C) 2006, 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.
|
||||
|
||||
import base64
|
||||
import struct
|
||||
|
||||
import dns.exception
|
||||
import dns.immutable
|
||||
import dns.rdata
|
||||
import dns.rdtypes.util
|
||||
|
||||
|
||||
class Gateway(dns.rdtypes.util.Gateway):
|
||||
name = "IPSECKEY gateway"
|
||||
|
||||
|
||||
@dns.immutable.immutable
|
||||
class IPSECKEY(dns.rdata.Rdata):
|
||||
"""IPSECKEY record"""
|
||||
|
||||
# see: RFC 4025
|
||||
|
||||
__slots__ = ["precedence", "gateway_type", "algorithm", "gateway", "key"]
|
||||
|
||||
def __init__(
|
||||
self, rdclass, rdtype, precedence, gateway_type, algorithm, gateway, key
|
||||
):
|
||||
super().__init__(rdclass, rdtype)
|
||||
gateway = Gateway(gateway_type, gateway)
|
||||
self.precedence = self._as_uint8(precedence)
|
||||
self.gateway_type = gateway.type
|
||||
self.algorithm = self._as_uint8(algorithm)
|
||||
self.gateway = gateway.gateway
|
||||
self.key = self._as_bytes(key)
|
||||
|
||||
def to_text(self, origin=None, relativize=True, **kw):
|
||||
gateway = Gateway(self.gateway_type, self.gateway).to_text(origin, relativize)
|
||||
key = dns.rdata._base64ify(self.key, **kw) # pyright: ignore
|
||||
return f"{self.precedence} {self.gateway_type} {self.algorithm} {gateway} {key}"
|
||||
|
||||
@classmethod
|
||||
def from_text(
|
||||
cls, rdclass, rdtype, tok, origin=None, relativize=True, relativize_to=None
|
||||
):
|
||||
precedence = tok.get_uint8()
|
||||
gateway_type = tok.get_uint8()
|
||||
algorithm = tok.get_uint8()
|
||||
gateway = Gateway.from_text(
|
||||
gateway_type, tok, origin, relativize, relativize_to
|
||||
)
|
||||
b64 = tok.concatenate_remaining_identifiers().encode()
|
||||
key = base64.b64decode(b64)
|
||||
return cls(
|
||||
rdclass, rdtype, precedence, gateway_type, algorithm, gateway.gateway, key
|
||||
)
|
||||
|
||||
def _to_wire(self, file, compress=None, origin=None, canonicalize=False):
|
||||
header = struct.pack("!BBB", self.precedence, self.gateway_type, self.algorithm)
|
||||
file.write(header)
|
||||
Gateway(self.gateway_type, self.gateway).to_wire(
|
||||
file, compress, origin, canonicalize
|
||||
)
|
||||
file.write(self.key)
|
||||
|
||||
@classmethod
|
||||
def from_wire_parser(cls, rdclass, rdtype, parser, origin=None):
|
||||
header = parser.get_struct("!BBB")
|
||||
gateway_type = header[1]
|
||||
gateway = Gateway.from_wire_parser(gateway_type, parser, origin)
|
||||
key = parser.get_remaining()
|
||||
return cls(
|
||||
rdclass, rdtype, header[0], gateway_type, header[2], gateway.gateway, key
|
||||
)
|
||||
24
venv/Lib/site-packages/dns/rdtypes/IN/KX.py
Normal file
24
venv/Lib/site-packages/dns/rdtypes/IN/KX.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# 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.
|
||||
|
||||
import dns.immutable
|
||||
import dns.rdtypes.mxbase
|
||||
|
||||
|
||||
@dns.immutable.immutable
|
||||
class KX(dns.rdtypes.mxbase.UncompressedDowncasingMX):
|
||||
"""KX record"""
|
||||
109
venv/Lib/site-packages/dns/rdtypes/IN/NAPTR.py
Normal file
109
venv/Lib/site-packages/dns/rdtypes/IN/NAPTR.py
Normal file
@@ -0,0 +1,109 @@
|
||||
# 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.
|
||||
|
||||
import struct
|
||||
|
||||
import dns.exception
|
||||
import dns.immutable
|
||||
import dns.name
|
||||
import dns.rdata
|
||||
import dns.rdtypes.util
|
||||
|
||||
|
||||
def _write_string(file, s):
|
||||
l = len(s)
|
||||
assert l < 256
|
||||
file.write(struct.pack("!B", l))
|
||||
file.write(s)
|
||||
|
||||
|
||||
@dns.immutable.immutable
|
||||
class NAPTR(dns.rdata.Rdata):
|
||||
"""NAPTR record"""
|
||||
|
||||
# see: RFC 3403
|
||||
|
||||
__slots__ = ["order", "preference", "flags", "service", "regexp", "replacement"]
|
||||
|
||||
def __init__(
|
||||
self, rdclass, rdtype, order, preference, flags, service, regexp, replacement
|
||||
):
|
||||
super().__init__(rdclass, rdtype)
|
||||
self.flags = self._as_bytes(flags, True, 255)
|
||||
self.service = self._as_bytes(service, True, 255)
|
||||
self.regexp = self._as_bytes(regexp, True, 255)
|
||||
self.order = self._as_uint16(order)
|
||||
self.preference = self._as_uint16(preference)
|
||||
self.replacement = self._as_name(replacement)
|
||||
|
||||
def to_text(self, origin=None, relativize=True, **kw):
|
||||
replacement = self.replacement.choose_relativity(origin, relativize)
|
||||
return (
|
||||
f"{self.order} {self.preference} "
|
||||
f'"{dns.rdata._escapify(self.flags)}" '
|
||||
f'"{dns.rdata._escapify(self.service)}" '
|
||||
f'"{dns.rdata._escapify(self.regexp)}" '
|
||||
f"{replacement}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_text(
|
||||
cls, rdclass, rdtype, tok, origin=None, relativize=True, relativize_to=None
|
||||
):
|
||||
order = tok.get_uint16()
|
||||
preference = tok.get_uint16()
|
||||
flags = tok.get_string()
|
||||
service = tok.get_string()
|
||||
regexp = tok.get_string()
|
||||
replacement = tok.get_name(origin, relativize, relativize_to)
|
||||
return cls(
|
||||
rdclass, rdtype, order, preference, flags, service, regexp, replacement
|
||||
)
|
||||
|
||||
def _to_wire(self, file, compress=None, origin=None, canonicalize=False):
|
||||
two_ints = struct.pack("!HH", self.order, self.preference)
|
||||
file.write(two_ints)
|
||||
_write_string(file, self.flags)
|
||||
_write_string(file, self.service)
|
||||
_write_string(file, self.regexp)
|
||||
self.replacement.to_wire(file, compress, origin, canonicalize)
|
||||
|
||||
@classmethod
|
||||
def from_wire_parser(cls, rdclass, rdtype, parser, origin=None):
|
||||
(order, preference) = parser.get_struct("!HH")
|
||||
strings = []
|
||||
for _ in range(3):
|
||||
s = parser.get_counted_bytes()
|
||||
strings.append(s)
|
||||
replacement = parser.get_name(origin)
|
||||
return cls(
|
||||
rdclass,
|
||||
rdtype,
|
||||
order,
|
||||
preference,
|
||||
strings[0],
|
||||
strings[1],
|
||||
strings[2],
|
||||
replacement,
|
||||
)
|
||||
|
||||
def _processing_priority(self):
|
||||
return (self.order, self.preference)
|
||||
|
||||
@classmethod
|
||||
def _processing_order(cls, iterable):
|
||||
return dns.rdtypes.util.priority_processing_order(iterable)
|
||||
60
venv/Lib/site-packages/dns/rdtypes/IN/NSAP.py
Normal file
60
venv/Lib/site-packages/dns/rdtypes/IN/NSAP.py
Normal file
@@ -0,0 +1,60 @@
|
||||
# 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.
|
||||
|
||||
import binascii
|
||||
|
||||
import dns.exception
|
||||
import dns.immutable
|
||||
import dns.rdata
|
||||
import dns.tokenizer
|
||||
|
||||
|
||||
@dns.immutable.immutable
|
||||
class NSAP(dns.rdata.Rdata):
|
||||
"""NSAP record."""
|
||||
|
||||
# see: RFC 1706
|
||||
|
||||
__slots__ = ["address"]
|
||||
|
||||
def __init__(self, rdclass, rdtype, address):
|
||||
super().__init__(rdclass, rdtype)
|
||||
self.address = self._as_bytes(address)
|
||||
|
||||
def to_text(self, origin=None, relativize=True, **kw):
|
||||
return f"0x{binascii.hexlify(self.address).decode()}"
|
||||
|
||||
@classmethod
|
||||
def from_text(
|
||||
cls, rdclass, rdtype, tok, origin=None, relativize=True, relativize_to=None
|
||||
):
|
||||
address = tok.get_string()
|
||||
if address[0:2] != "0x":
|
||||
raise dns.exception.SyntaxError("string does not start with 0x")
|
||||
address = address[2:].replace(".", "")
|
||||
if len(address) % 2 != 0:
|
||||
raise dns.exception.SyntaxError("hexstring has odd length")
|
||||
address = binascii.unhexlify(address.encode())
|
||||
return cls(rdclass, rdtype, address)
|
||||
|
||||
def _to_wire(self, file, compress=None, origin=None, canonicalize=False):
|
||||
file.write(self.address)
|
||||
|
||||
@classmethod
|
||||
def from_wire_parser(cls, rdclass, rdtype, parser, origin=None):
|
||||
address = parser.get_remaining()
|
||||
return cls(rdclass, rdtype, address)
|
||||
Reference in New Issue
Block a user