Your IP : 18.222.91.173


Current Path : /usr/lib/python3.6/site-packages/dns/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dns/__pycache__/reversename.cpython-36.pyc

3

�b�W��@sXdZddlZddlZddlZddlZddlZejjd�Z	ejjd�Z
dd�Zdd�ZdS)	aDNS Reverse Map Names.

@var ipv4_reverse_domain: The DNS IPv4 reverse-map domain, in-addr.arpa.
@type ipv4_reverse_domain: dns.name.Name object
@var ipv6_reverse_domain: The DNS IPv6 reverse-map domain, ip6.arpa.
@type ipv6_reverse_domain: dns.name.Name object
�Nz
in-addr.arpa.z	ip6.arpa.cCs�yztjj|�}tjj|�rXtjdkr<dd�|dd�D�}ndd�|dd�D�}t}n dd�ttj	|�j
��D�}t}Wn2tk
r�dd�t
tjj|��D�}t}YnX|j�tjjd	j|�|d
�S)aConvert 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
    �cSsg|]}d|�qS)z%d�)�.0�byterr�!/usr/lib/python3.6/reversename.py�
<listcomp>/sz from_address.<locals>.<listcomp>�NcSsg|]}dt|��qS)z%d)�ord)rrrrrr1scSsg|]}|�qSrr)r�xrrrr4scSsg|]}d|�qS)z%dr)rrrrrr7s�.)�origin)r)�dns�ipv6�	inet_atonZ	is_mapped�sys�version_info�ipv4_reverse_domain�str�binasciiZhexlify�decode�ipv6_reverse_domain�	Exception�	bytearray�ipv4�reverse�name�	from_text�join)�textZv6�partsrrrr�from_address#s

r cCs�|jt�rD|jt�}t|j�}|j�dj|�}tjj	tjj
|��S|jt�r�|jt�}t|j�}|j�g}d}t|�}x0||kr�|j
dj|||d���|d7}q|Wdj|�}tjj	tjj
|��Stjjd��dS)z�Convert a reverse map domain name into textual address form.
    @param name: an IPv4 or IPv6 address in reverse-map form.
    @type name: dns.name.Name object
    @rtype: str
    �.r���:z"unknown reverse-map address familyN)Zis_subdomainrZ
relativize�list�labelsrrr
rZ	inet_ntoarr�len�appendrZ	exception�SyntaxError)rr&rr�i�lrrr�
to_address>s&








r,)
�__doc__rrZdns.namer
Zdns.ipv6Zdns.ipv4rrrrr r,rrrr�<module>s

?>