From ed6d841d2d28ab65fbfb8ec62c7170e4e412d79f Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Mon, 26 Dec 2005 01:44:30 +0000 Subject: go back to reversename --- dns/__init__.py | 2 +- dns/reversemap.py | 39 --------------------------------------- dns/reversename.py | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 40 deletions(-) delete mode 100644 dns/reversemap.py create mode 100644 dns/reversename.py diff --git a/dns/__init__.py b/dns/__init__.py index 2b88824..5d4ee2c 100644 --- a/dns/__init__.py +++ b/dns/__init__.py @@ -35,7 +35,7 @@ __all__ = [ 'rdatatype', 'renderer', 'resolver', - 'reversemap', + 'reversename', 'rrset', 'set', 'tokenizer', diff --git a/dns/reversemap.py b/dns/reversemap.py deleted file mode 100644 index 2a4998f..0000000 --- a/dns/reversemap.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2005 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 dns.name -import dns.ipv6 -import dns.ipv4 - -def from_text(text): - """Convert an IPv4 or IPv6 address in textual form into a Name object whose - value is the reverse-map domain name of the address. - @param text: an IPv4 or IPv6 address in textual form (e.g. '127.0.0.1', - '::1') - @type text: str - @rtype: dns.name.Name object - """ - - try: - parts = list(dns.ipv6.inet_aton(text).encode('hex_codec')) - suffix = 'ip6.arpa.' - except: - parts = ['%d' % ord(byte) for byte in dns.ipv4.inet_aton(text)] - suffix = 'in-addr.arpa.' - parts.reverse() - parts.append(suffix) - return dns.name.from_text('.'.join(parts)) diff --git a/dns/reversename.py b/dns/reversename.py new file mode 100644 index 0000000..2a4998f --- /dev/null +++ b/dns/reversename.py @@ -0,0 +1,39 @@ +# Copyright (C) 2005 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 dns.name +import dns.ipv6 +import dns.ipv4 + +def from_text(text): + """Convert an IPv4 or IPv6 address in textual form into a Name object whose + value is the reverse-map domain name of the address. + @param text: an IPv4 or IPv6 address in textual form (e.g. '127.0.0.1', + '::1') + @type text: str + @rtype: dns.name.Name object + """ + + try: + parts = list(dns.ipv6.inet_aton(text).encode('hex_codec')) + suffix = 'ip6.arpa.' + except: + parts = ['%d' % ord(byte) for byte in dns.ipv4.inet_aton(text)] + suffix = 'in-addr.arpa.' + parts.reverse() + parts.append(suffix) + return dns.name.from_text('.'.join(parts)) -- cgit v1.2.1