/
usr
/
lib
/
python3.9
/
site-packages
/
dns
/
/usr/lib/python3.9/site-packages/dns
mkdir
upload
Name
Size
Mode
Actions
dnssecalgs/
-
0755
rm
quic/
-
0755
rm
rdtypes/
-
0755
rm
__pycache__/
-
0755
rm
asyncbackend.py
2796
0644
edit
dl
rm
asyncquery.py
26850
0644
edit
dl
rm
asyncresolver.py
17852
0644
edit
dl
rm
dnssec.py
40693
0644
edit
dl
rm
dnssectypes.py
1799
0644
edit
dl
rm
e164.py
3978
0644
edit
dl
rm
edns.py
15263
0644
edit
dl
rm
entropy.py
4242
0644
edit
dl
rm
enum.py
3691
0644
edit
dl
rm
exception.py
5957
0644
edit
dl
rm
flags.py
2750
0644
edit
dl
rm
grange.py
2148
0644
edit
dl
rm
immutable.py
2017
0644
edit
dl
rm
inet.py
5772
0644
edit
dl
rm
ipv4.py
2552
0644
edit
dl
rm
ipv6.py
6600
0644
edit
dl
rm
message.py
65993
0644
edit
dl
rm
name.py
42672
0644
edit
dl
rm
namedict.py
4000
0644
edit
dl
rm
nameserver.py
9909
0644
edit
dl
rm
node.py
12663
0644
edit
dl
rm
opcode.py
2730
0644
edit
dl
rm
query.py
54832
0644
edit
dl
rm
rcode.py
4156
0644
edit
dl
rm
rdata.py
29456
0644
edit
dl
rm
rdataclass.py
2984
0644
edit
dl
rm
rdataset.py
16756
0644
edit
dl
rm
rdatatype.py
7339
0644
edit
dl
rm
renderer.py
11254
0644
edit
dl
rm
resolver.py
73552
0644
edit
dl
rm
reversename.py
3828
0644
edit
dl
rm
rrset.py
9170
0644
edit
dl
rm
serial.py
3606
0644
edit
dl
rm
set.py
9088
0644
edit
dl
rm
tokenizer.py
23583
0644
edit
dl
rm
transaction.py
22636
0644
edit
dl
rm
tsig.py
11413
0644
edit
dl
rm
tsigkeyring.py
2633
0644
edit
dl
rm
ttl.py
2979
0644
edit
dl
rm
update.py
12243
0644
edit
dl
rm
version.py
1926
0644
edit
dl
rm
versioned.py
11765
0644
edit
dl
rm
win32util.py
9107
0644
edit
dl
rm
wire.py
2830
0644
edit
dl
rm
xfr.py
13273
0644
edit
dl
rm
zone.py
52086
0644
edit
dl
rm
zonefile.py
27929
0644
edit
dl
rm
zonetypes.py
690
0644
edit
dl
rm
_asyncbackend.py
2360
0644
edit
dl
rm
_asyncio_backend.py
8971
0644
edit
dl
rm
_ddr.py
5247
0644
edit
dl
rm
_features.py
2384
0644
edit
dl
rm
_immutable_ctx.py
2459
0644
edit
dl
rm
__init__.py
1663
0644
edit
dl
rm
Edit:
/usr/lib/python3.9/site-packages/dns/reversename.py
(3828B)
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license # Copyright (C) 2006-2017 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 Reverse Map Names.""" import binascii import dns.ipv4 import dns.ipv6 import dns.name ipv4_reverse_domain = dns.name.from_text("in-addr.arpa.") ipv6_reverse_domain = dns.name.from_text("ip6.arpa.") def from_address( text: str, v4_origin: dns.name.Name = ipv4_reverse_domain, v6_origin: dns.name.Name = ipv6_reverse_domain, ) -> dns.name.Name: """Convert an IPv4 or IPv6 address in textual form into a Name object whose value is the reverse-map domain name of the address. *text*, a ``str``, is an IPv4 or IPv6 address in textual form (e.g. '127.0.0.1', '::1') *v4_origin*, a ``dns.name.Name`` to append to the labels corresponding to the address if the address is an IPv4 address, instead of the default (in-addr.arpa.) *v6_origin*, a ``dns.name.Name`` to append to the labels corresponding to the address if the address is an IPv6 address, instead of the default (ip6.arpa.) Raises ``dns.exception.SyntaxError`` if the address is badly formed. Returns a ``dns.name.Name``. """ try: v6 = dns.ipv6.inet_aton(text) if dns.ipv6.is_mapped(v6): parts = ["%d" % byte for byte in v6[12:]] origin = v4_origin else: parts = [x for x in str(binascii.hexlify(v6).decode())] origin = v6_origin except Exception: parts = ["%d" % byte for byte in dns.ipv4.inet_aton(text)] origin = v4_origin return dns.name.from_text(".".join(reversed(parts)), origin=origin) def to_address( name: dns.name.Name, v4_origin: dns.name.Name = ipv4_reverse_domain, v6_origin: dns.name.Name = ipv6_reverse_domain, ) -> str: """Convert a reverse map domain name into textual address form. *name*, a ``dns.name.Name``, an IPv4 or IPv6 address in reverse-map name form. *v4_origin*, a ``dns.name.Name`` representing the top-level domain for IPv4 addresses, instead of the default (in-addr.arpa.) *v6_origin*, a ``dns.name.Name`` representing the top-level domain for IPv4 addresses, instead of the default (ip6.arpa.) Raises ``dns.exception.SyntaxError`` if the name does not have a reverse-map form. Returns a ``str``. """ if name.is_subdomain(v4_origin): name = name.relativize(v4_origin) text = b".".join(reversed(name.labels)) # run through inet_ntoa() to check syntax and make pretty. return dns.ipv4.inet_ntoa(dns.ipv4.inet_aton(text)) elif name.is_subdomain(v6_origin): name = name.relativize(v6_origin) labels = list(reversed(name.labels)) parts = [] for i in range(0, len(labels), 4): parts.append(b"".join(labels[i : i + 4])) text = b":".join(parts) # run through inet_ntoa() to check syntax and make pretty. return dns.ipv6.inet_ntoa(dns.ipv6.inet_aton(text)) else: raise dns.exception.SyntaxError("unknown reverse-map address family")
Save
cmd:
run