Your IP : 18.225.72.181
3
�b�W� � @ sX d Z ddlZddlZddlZddlZddlZejjd�Z ejjd�Z
dd� Zdd� ZdS ) a DNS 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 C s� yzt jj| �}t jj|�rXtjdkr<dd� |dd� D �}ndd� |dd� D �}t}n dd� ttj |�j
� �D �}t}W n2 tk
r� dd� t
t jj| ��D �}t}Y nX |j� t jjd j|�|d
�S )a 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
� c S s g | ]}d | �qS )z%d� )�.0�byter r �!/usr/lib/python3.6/reversename.py�
<listcomp>/ s z from_address.<locals>.<listcomp>� Nc S s g | ]}d t |� �qS )z%d)�ord)r r r r r r 1 s c S s g | ]}|�qS r r )r �xr r r r 4 s c S s g | ]}d | �qS )z%dr )r r r r r r 7 s �.)�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 r r r �from_address# s
r c C s� | j t�rD| jt�} t| j�}|j� dj|�}tjj tjj
|��S | j t�r�| jt�} t| j�}|j� g }d}t|�}x0||k r�|j
dj|||d � �� |d7 }q|W dj|�}tjj tjj
|��S tjjd��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)Zis_subdomainr Z
relativize�list�labelsr r r
r Z inet_ntoar r �len�appendr Z exception�SyntaxError)r r&