Your IP : 18.223.170.253


Current Path : /lib64/python3.8/__pycache__/
Upload File :
Current File : //lib64/python3.8/__pycache__/ipaddress.cpython-38.opt-2.pyc

U

e5d��@s�dZddlZdZdZGdd�de�ZGdd�de�Zd	d
�Zd<dd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�ZGd"d#�d#�ZejGd$d%�d%e��ZejGd&d'�d'e��ZGd(d)�d)�ZGd*d+�d+ee�ZGd,d-�d-e�ZGd.d/�d/ee�ZGd0d1�d1�Zee_Gd2d3�d3�ZGd4d5�d5ee�ZGd6d7�d7e�ZGd8d9�d9ee�Z Gd:d;�d;�Z!e!e_dS)=z1.0�N� �c@seZdZdS)�AddressValueErrorN��__name__�
__module__�__qualname__�r	r	�!/usr/lib64/python3.8/ipaddress.pyrsrc@seZdZdS)�NetmaskValueErrorNrr	r	r	r
rsrc	CsXz
t|�WSttfk
r"YnXz
t|�WSttfk
rFYnXtd|��dS)Nz0%r does not appear to be an IPv4 or IPv6 address)�IPv4Addressrr�IPv6Address�
ValueError��addressr	r	r
�
ip_addresss

�rTc	Cs\zt||�WSttfk
r$YnXzt||�WSttfk
rJYnXtd|��dS)Nz0%r does not appear to be an IPv4 or IPv6 network)�IPv4Networkrr�IPv6Networkr)r�strictr	r	r
�
ip_network9s�rc	CsXz
t|�WSttfk
r"YnXz
t|�WSttfk
rFYnXtd|��dS)Nz2%r does not appear to be an IPv4 or IPv6 interface)�
IPv4Interfacerr�
IPv6Interfacerrr	r	r
�ip_interfaceWs

�rcCs0z|�dd�WStk
r*td��YnXdS)N��bigz&Address negative or too large for IPv4��to_bytes�
OverflowErrorrrr	r	r
�v4_int_to_packedzsrcCs0z|�dd�WStk
r*td��YnXdS)N�rz&Address negative or too large for IPv6rrr	r	r
�v6_int_to_packed�s
r cCs*t|��d�}t|�dkr&td|��|S)N�/�zOnly one '/' permitted in %r)�str�split�lenr)r�addrr	r	r
�_split_optional_netmask�sr'ccsNt|�}t|�}}|D]&}|j|jdkr:||fV|}|}q||fVdS�N�)�iter�next�_ip)�	addresses�it�first�last�ipr	r	r
�_find_address_range�s

r2cCs$|dkr|St|||d@���S)Nrr))�min�
bit_length)Znumber�bitsr	r	r
�_count_righthand_zero_bits�sr6ccs�t|t�rt|t�std��|j|jkr8td||f��||krHtd��|jdkrXt}n|jdkrht}ntd��|j}|j}|j}||kr�t	t
||�||d��d�}||||f�}|V|d|>7}|d|jkr�q�q�dS)Nz1first and last must be IP addresses, not networks�%%s and %s are not of the same versionz*last IP address must be greater than firstr�zunknown IP versionr))
�
isinstance�_BaseAddress�	TypeError�versionrrr�_max_prefixlenr,r3r6r4�	_ALL_ONES)r/r0r1Zip_bitsZ	first_intZlast_intZnbits�netr	r	r
�summarize_address_range�s8
��


�r@ccs�t|�}i}|rV|��}|��}|�|�}|dkr<|||<q||kr||=|�|�qd}t|���D]$}|dk	r�|j|jkr�qf|V|}qfdS�N)�list�pop�supernet�get�append�sorted�values�broadcast_address)r-Zto_merge�subnetsr?rDZexistingr0r	r	r
�_collapse_addresses_internals$

rKc	Cs0g}g}g}|D]�}t|t�rR|rF|dj|jkrFtd||df��|�|�q|j|jkr�|r�|dj|jkr�td||df��z|�|j�Wq�tk
r�|�|j	�Yq�Xq|r�|dj|jkr�td||df��|�|�qt
t|��}|�r$t|�D]\}}|�
t||���qt||�S)N���r7)r9r:�_versionr;rF�
_prefixlenr=r1�AttributeError�network_addressrG�setr2�extendr@rK)r-ZaddrsZipsZnetsr1r/r0r	r	r
�collapse_addresses2s@
���rScCs(t|t�r|��St|t�r$|��StSrA)r9�_BaseNetwork�_get_networks_keyr:�_get_address_key�NotImplemented)�objr	r	r
�get_mixed_type_keyhs


rYc@s�eZdZdZedd��Zedd��Zedd��Zedd	��Zd
d�Z	dd
�Z
edd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zdd�ZdS)�_IPAddressBaser	cCs|��SrA)�_explode_shorthand_ip_string��selfr	r	r
�exploded�sz_IPAddressBase.explodedcCst|�SrA�r#r\r	r	r
�
compressed�sz_IPAddressBase.compressedcCs|��SrA)�_reverse_pointerr\r	r	r
�reverse_pointer�s	z_IPAddressBase.reverse_pointercCsdt|�f}t|��dS)Nz%200s has no version specified��type�NotImplementedError�r]�msgr	r	r
r<�sz_IPAddressBase.versioncCsF|dkrd}t|||jf��||jkrBd}t|||j|jf��dS)Nrz-%d (< 0) is not permitted as an IPv%d addressz2%d (>= 2**%d) is not permitted as an IPv%d address)rrMr>r=)r]rrgr	r	r
�_check_int_address�s

�z!_IPAddressBase._check_int_addresscCs.t|�}||kr*d}t|||||jf��dS)Nz6%r (len %d != %d) is not permitted as an IPv%d address)r%rrM)r]rZexpected_lenZaddress_lenrgr	r	r
�_check_packed_address�s�z$_IPAddressBase._check_packed_addresscCs|j|j|?ASrA)r>)�cls�	prefixlenr	r	r
�_ip_int_from_prefix�sz"_IPAddressBase._ip_int_from_prefixc	Cs\t||j�}|j|}||?}d|>d}||krX|jd}|�|d�}d}t||��|S)Nr)�rz&Netmask pattern %r mixes zeroes & ones)r6r=rr)	rj�ip_intZtrailing_zeroesrkZleading_onesZall_onesZbyteslenZdetailsrgr	r	r
�_prefix_from_ip_int�s
�

z"_IPAddressBase._prefix_from_ip_intcCsd|}t|�d�dS)Nz%r is not a valid netmask)r)rjZnetmask_strrgr	r	r
�_report_invalid_netmask�sz&_IPAddressBase._report_invalid_netmaskcCsl|��r|��s|�|�zt|�}Wntk
rD|�|�YnXd|kr\|jkshn|�|�|S�Nr)�isascii�isdigitrp�intrr=)rjZ
prefixlen_strrkr	r	r
�_prefix_from_prefix_string�s

z)_IPAddressBase._prefix_from_prefix_stringcCs�z|�|�}Wntk
r,|�|�YnXz|�|�WStk
rNYnX||jN}z|�|�WStk
r�|�|�YnXdSrA)�_ip_int_from_stringrrprorr>)rj�ip_strrnr	r	r
�_prefix_from_ip_string�s
z%_IPAddressBase._prefix_from_ip_stringcCsHt|ttf�r||jfSt|t�s*t|�}t|�dkr:|S|d|jfS)Nr)r)r9�bytesrtr=�tupler'r%)rjrr	r	r
�_split_addr_prefixs

z!_IPAddressBase._split_addr_prefixcCs|jt|�ffSrA)�	__class__r#r\r	r	r
�
__reduce__/sz_IPAddressBase.__reduce__N)rrr�	__slots__�propertyr^r`rbr<rhri�classmethodrlrorprurxr{r}r	r	r	r
rZ�s0




	




!
rZc@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)r:r	cCs|jSrA�r,r\r	r	r
�__int__>sz_BaseAddress.__int__cCs8z|j|jko|j|jkWStk
r2tYSXdSrA)r,rMrOrW�r]�otherr	r	r
�__eq__As
�z_BaseAddress.__eq__cCsFt|t�stS|j|jkr*td||f��|j|jkrB|j|jkSdS�Nr7F)r9r:rWrMr;r,r�r	r	r
�__lt__Hs
�z_BaseAddress.__lt__cCs t|t�stS|�t|�|�SrA�r9rtrWr|r�r	r	r
�__add__Ts
z_BaseAddress.__add__cCs t|t�stS|�t|�|�SrAr�r�r	r	r
�__sub__Ys
z_BaseAddress.__sub__cCsd|jjt|�fS�Nz%s(%r)�r|rr#r\r	r	r
�__repr__^sz_BaseAddress.__repr__cCst|�|j��SrA)r#�_string_from_ip_intr,r\r	r	r
�__str__asz_BaseAddress.__str__cCsttt|j���SrA)�hash�hexrtr,r\r	r	r
�__hash__dsz_BaseAddress.__hash__cCs
|j|fSrA�rMr\r	r	r
rVgsz_BaseAddress._get_address_keycCs|j|jffSrA)r|r,r\r	r	r
r}jsz_BaseAddress.__reduce__N)rrrr~r�r�r�r�r�r�r�r�rVr}r	r	r	r
r:3s	r:c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jdd��Ze
jdd��Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zed#d$��Zd%d&�Zd'd(�Zd)d*�ZdEd-d.�ZdFd/d0�Zed1d2��Zed3d4��Zd5d6�Z d7d8�Z!ed9d:��Z"ed;d<��Z#ed=d>��Z$ed?d@��Z%edAdB��Z&edCdD��Z'd,S)GrTcCsd|jjt|�fSr�r�r\r	r	r
r�vsz_BaseNetwork.__repr__cCsd|j|jfS�N�%s/%d)rPrkr\r	r	r
r�ysz_BaseNetwork.__str__ccs8t|j�}t|j�}t|d|�D]}|�|�Vq"dSr(�rtrPrI�range�_address_class�r]�network�	broadcast�xr	r	r
�hosts|s

z_BaseNetwork.hostsccs8t|j�}t|j�}t||d�D]}|�|�Vq"dSr(r�r�r	r	r
�__iter__�s

z_BaseNetwork.__iter__cCslt|j�}t|j�}|dkr>|||kr0td��|�||�S|d7}|||krZtd��|�||�SdS)Nrzaddress out of ranger))rtrPrI�
IndexErrorr�)r]�nr�r�r	r	r
�__getitem__�s

z_BaseNetwork.__getitem__cCs^t|t�stS|j|jkr*td||f��|j|jkrB|j|jkS|j|jkrZ|j|jkSdSr�)r9rTrWrMr;rP�netmaskr�r	r	r
r��s
�z_BaseNetwork.__lt__cCsLz.|j|jko,|j|jko,t|j�t|j�kWStk
rFtYSXdSrA)rMrPrtr�rOrWr�r	r	r
r��s
��z_BaseNetwork.__eq__cCstt|j�t|j�A�SrA)r�rtrPr�r\r	r	r
r��sz_BaseNetwork.__hash__cCs8|j|jkrdSt|t�rdS|j|jj@|jjkSdS�NF)rMr9rTr,r�rPr�r	r	r
�__contains__�s

z_BaseNetwork.__contains__cCs(|j|kp&|j|kp&|j|kp&|j|kSrA)rPrIr�r	r	r
�overlaps�s



�z_BaseNetwork.overlapscCs|�t|j�t|j�B�SrA)r�rtrP�hostmaskr\r	r	r
rI�s�z_BaseNetwork.broadcast_addresscCs|�t|j�|jA�SrA)r�rtr�r>r\r	r	r
r��sz_BaseNetwork.hostmaskcCsd|j|jfSr�)rPrNr\r	r	r
�with_prefixlen�sz_BaseNetwork.with_prefixlencCsd|j|jfS�N�%s/%s)rPr�r\r	r	r
�with_netmask�sz_BaseNetwork.with_netmaskcCsd|j|jfSr�)rPr�r\r	r	r
�
with_hostmask�sz_BaseNetwork.with_hostmaskcCst|j�t|j�dSr()rtrIrPr\r	r	r
�
num_addresses�sz_BaseNetwork.num_addressescCsdt|�f}t|��dS)Nz%%200s has no associated address classrcrfr	r	r
r��sz_BaseNetwork._address_classcCs|jSrA)rNr\r	r	r
rk�sz_BaseNetwork.prefixlenccs|j|jkstd||f��t|t�s2td|��|�|�sLtd||f��||krXdS|�d|j|jf�}|�	�\}}||kr�||kr�|�|�r�|V|�	�\}}qz|�|�r�|V|�	�\}}qzt
d|||f��qz||kr�|Vn"||kr�|Vnt
d|||f��dS)Nr7z%s is not a network objectz%s not contained in %sr�z3Error performing exclusion: s1: %s s2: %s other: %s)rMr;r9rT�	subnet_ofrr|rPrkrJ�AssertionError)r]r��s1�s2r	r	r
�address_exclude�s@$�


�

��z_BaseNetwork.address_excludecCs`|j|jkrtd||f��|j|jkr,dS|j|jkr<dS|j|jkrLdS|j|jkr\dSdS)Nz"%s and %s are not of the same typerLr)r)rMr;rPr�r�r	r	r
�compare_networks6s!�z_BaseNetwork.compare_networkscCs|j|j|jfSrA)rMrPr�r\r	r	r
rUfsz_BaseNetwork._get_networks_keyr)Nc	cs�|j|jkr|VdS|dk	rJ||jkr0td��|dkr@td��||j}|dkrZtd��|j|}||jkr~td||f��t|j�}t|j�d}t|j�d|?}t|||�D]}|�||f�}|Vq�dS)Nznew prefix must be longerr)�(cannot set prefixlen_diff and new_prefixrzprefix length diff must be > 0z0prefix length diff %d is invalid for netblock %s)	rNr=rrtrPrIr�r�r|)	r]�prefixlen_diff�
new_prefix�
new_prefixlen�start�end�stepZnew_addrZcurrentr	r	r
rJps2



��
z_BaseNetwork.subnetscCs�|jdkr|S|dk	rB||jkr(td��|dkr8td��|j|}|j|}|dkrftd|j|f��|�t|j�t|j�|>@|f�S)Nrznew prefix must be shorterr)r�z;current prefixlen is %d, cannot have a prefixlen_diff of %d)rNrrkr|rtrPr�)r]r�r�r�r	r	r
rD�s&



���z_BaseNetwork.supernetcCs|jjo|jjSrA)rP�is_multicastrIr\r	r	r
r��s	�z_BaseNetwork.is_multicastcCshz:|j|jkr"t|�d|�d���|j|jko8|j|jkWStk
rbtd|�d|����YnXdS)Nz and z are not of the same versionz*Unable to test subnet containment between )rMr;rPrIrO)�a�br	r	r
�
_is_subnet_of�s
�z_BaseNetwork._is_subnet_ofcCs|�||�SrA�r�r�r	r	r
r��sz_BaseNetwork.subnet_ofcCs|�||�SrAr�r�r	r	r
�supernet_of�sz_BaseNetwork.supernet_ofcCs|jjo|jjSrA)rP�is_reservedrIr\r	r	r
r��s	�z_BaseNetwork.is_reservedcCs|jjo|jjSrA)rP�
is_link_localrIr\r	r	r
r��s�z_BaseNetwork.is_link_localcCs|jjo|jjSrA)rP�
is_privaterIr\r	r	r
r�s	�z_BaseNetwork.is_privatecCs|jSrA�r�r\r	r	r
�	is_globals	z_BaseNetwork.is_globalcCs|jjo|jjSrA)rP�is_unspecifiedrIr\r	r	r
r�s	�z_BaseNetwork.is_unspecifiedcCs|jjo|jjSrA)rP�is_loopbackrIr\r	r	r
r�(s	�z_BaseNetwork.is_loopback)r)N)r)N)(rrrr�r�r�r�r�r�r�r�r�r��	functools�cached_propertyrIr�rr�r�r�r�r�rkr�r�rUrJrDr��staticmethodr�r�r�r�r�r�r�r�r�r	r	r	r
rTnsb








K0

5
)








rTc@s�eZdZdZdZdedZeZiZdd�Z	e
dd��Ze
d	d
��Ze
dd��Z
e
d
d��Zdd�Zedd��Zedd��ZdS)�_BaseV4r	rr"r)cCst|�SrAr_r\r	r	r
r[Hsz$_BaseV4._explode_shorthand_ip_stringcCs�||jkr�t|t�r<|}d|kr.|jksjn|�|�n.z|�|�}Wntk
rh|�|�}YnXt|�	|��}||f|j|<|j|Srq)
�_netmask_cacher9rtr=rprurrxrrl�rj�argrkr�r	r	r
�
_make_netmaskKs	

z_BaseV4._make_netmaskc
Cs~|std��|�d�}t|�dkr.td|��zt�t|j|�d�WStk
rx}ztd||f�d�W5d}~XYnXdS)N�Address cannot be empty�.rzExpected 4 octets in %rr�%s in %r)rr$r%rt�
from_bytes�map�_parse_octetr)rjrwZoctets�excr	r	r
rves
z_BaseV4._ip_int_from_stringcCs�|std��|��r|��s,d}t||��t|�dkrHd}t||��|dkrl|ddkrld}t||��t|d�}|d	kr�td
|��|S)NzEmpty octet not permittedz#Only decimal digits permitted in %r�z$At most 3 characters permitted in %r�0rz%Leading zeros are not permitted in %r�
�zOctet %d (> 255) not permitted)rrrrsr%rt)rjZ	octet_strrgZ	octet_intr	r	r
r�s
z_BaseV4._parse_octetcCsd�tt|�dd���S)Nr�rr)�joinr�r#r)rjrnr	r	r
r��sz_BaseV4._string_from_ip_intcCs&t|��d�ddd�}d�|�dS)Nr�rLz
.in-addr.arpa)r#r$r�)r]Zreverse_octetsr	r	r
ra�sz_BaseV4._reverse_pointercCs|jSrA�r=r\r	r	r
�
max_prefixlen�sz_BaseV4.max_prefixlencCs|jSrAr�r\r	r	r
r<�sz_BaseV4.versionN)rrrr~rM�
IPV4LENGTHr>r=r�r[r�r�rvr�r�rarr�r<r	r	r	r
r�5s&	


#
	
r�c@s�eZdZdZdd�Zedd��Zedd��Zee�	�dd	���Z
ee�	�d
d���Zedd
��Zedd��Z
edd��Zedd��ZdS)r�r,�__weakref__cCsrt|t�r|�|�||_dSt|t�rF|�|d�t�|d�|_dSt|�}d|krbtd|��|�	|�|_dS)Nrrr!�Unexpected '/' in %r�
r9rtrhr,ryrir�r#rrv�r]rZaddr_strr	r	r
�__init__�s


zIPv4Address.__init__cCs
t|j�SrA)rr,r\r	r	r
�packed�szIPv4Address.packedcCs||jjkSrA)�
_constants�_reserved_networkr\r	r	r
r��s	zIPv4Address.is_reservedcst�fdd��jjD��S)Nc3s|]}�|kVqdSrAr	��.0r?r\r	r
�	<genexpr>sz)IPv4Address.is_private.<locals>.<genexpr>��anyr��_private_networksr\r	r\r
r��s
zIPv4Address.is_privatecCs||jjko|jSrA)r��_public_networkr�r\r	r	r
r�szIPv4Address.is_globalcCs||jjkSrA�r��_multicast_networkr\r	r	r
r�s	zIPv4Address.is_multicastcCs||jjkSrA)r��_unspecified_addressr\r	r	r
r�s	zIPv4Address.is_unspecifiedcCs||jjkSrA)r��_loopback_networkr\r	r	r
r�"szIPv4Address.is_loopbackcCs||jjkSrA�r��_linklocal_networkr\r	r	r
r�,szIPv4Address.is_link_localN)rrrr~r�rr�r�r��	lru_cacher�r�r�r�r�r�r	r	r	r
r�s(#








	rc@sxeZdZdd�Zejdd��Zdd�Zdd�Zd	d
�Z	dd�Z
ejZe
d
d��Ze
dd��Ze
dd��Ze
dd��ZdS)rcCsD|�|�\}}t�||�t||fdd�|_|jj|_|jj|_dS�NF)r)r{rr�rr�r�rN�r]rr&�maskr	r	r
r�9s

zIPv4Interface.__init__cCs|jjSrA�r�r�r\r	r	r
r�AszIPv4Interface.hostmaskcCsd|�|j�|jfSr��r�r,rNr\r	r	r
r�Es�zIPv4Interface.__str__cCsFt�||�}|r|tkr|Sz|j|jkWStk
r@YdSXdSr�)rr�rWr�rO�r]r�Z
address_equalr	r	r
r�IszIPv4Interface.__eq__cCsRt�||�}|tkrtSz|j|jkp4|j|jko4|WStk
rLYdSXdSr�)rr�rWr�rO�r]r�Zaddress_lessr	r	r
r�Us�zIPv4Interface.__lt__cCst|j|jt|jj�f�SrA�r�r,rNrtr�rPr\r	r	r
r�aszIPv4Interface.__hash__cCs
t|j�SrA)rr,r\r	r	r
r1fszIPv4Interface.ipcCsd|�|j�|jfSr�r�r\r	r	r
r�js�zIPv4Interface.with_prefixlencCsd|�|j�|jfSr��r�r,r�r\r	r	r
r�os�zIPv4Interface.with_netmaskcCsd|�|j�|jfSr��r�r,r�r\r	r	r
r�ts�zIPv4Interface.with_hostmaskN)rrrr�r�r�r�r�r�r�r�rZr}rr1r�r�r�r	r	r	r
r7s 



rc@s.eZdZeZddd�Zee��dd���Z	dS)rTcs�|�|�\�}t��|_|�|�\|_|_t|j�}|t|j�@|krl|rXtd|��nt|t|j�@�|_|j|jdkr�|j	|_
n|j|jkr��fdd�|_
dS)N�%s has host bits setr)cs
t��gSrA)rr	�r&r	r
�<lambda>��z&IPv4Network.__init__.<locals>.<lambda>)r{rrPr�r�rNrtrr=r�r��r]rrr�r�r	rr
r��s#

�
zIPv4Network.__init__cCs&|jtd�ko|jtd�ko$|jS)N�
100.64.0.0/10)rPrrIr�r\r	r	r
r��s

��zIPv4Network.is_globalN)T)
rrrrr�r�rr�r�r�r	r	r	r
rzs


4rc@s�eZdZed�Zed�Zed�Zed�Zed�ed�ed�ed�ed�ed�ed	�ed
�ed�ed�ed
�ed�ed�ed�gZed�Z	e
d�ZdS)�_IPv4Constantsz169.254.0.0/16z127.0.0.0/8z224.0.0.0/4rz	0.0.0.0/8z
10.0.0.0/8z
172.16.0.0/12z192.0.0.0/29z192.0.0.170/31z192.0.2.0/24z192.168.0.0/16z
198.18.0.0/15z198.51.100.0/24z203.0.113.0/24z240.0.0.0/4z255.255.255.255/32z0.0.0.0N)rrrrr�r�r�r�r�r�rr�r	r	r	r
r�s*�rc@s�eZdZdZdZdedZdZed�Z	eZ
iZedd��Z
ed	d
��Zedd��Zed
d��Zeddd��Zdd�Zdd�Zedd��Zedd��ZdS)�_BaseV6r	r8r"r)rmZ0123456789ABCDEFabcdefcCsl||jkrbt|t�r<|}d|kr.|jksFn|�|�n
|�|�}t|�|��}||f|j|<|j|Srq)r�r9rtr=rprur
rlr�r	r	r
r�s	


z_BaseV6._make_netmaskc
Cs�|std��|�d�}d}t|�|kr:d||f}t|��d|dkr�zt|���j}Wn4tk
r�}ztd||f�d�W5d}~XYnX|�d|d	?d
@�|�d|d
@�|jd}t|�|kr�d|d|f}t|��d}tdt|�d�D]*}	||	s�|dk	�r d
|}t|��|	}q�|dk	�r�|}
t|�|d}|d�sl|
d8}
|
�rld}t||��|d�s�|d8}|�r�d}t||��|j|
|}|dk�r2d}t||jd|f��njt|�|jk�r�d}t||j|f��|d�sd}t||��|d�s"d}t||��t|�}
d}d}znd}
t|
�D] }	|
d	K}
|
|�	||	�O}
�q@|
d	|K}
t|d�D] }	|
d	K}
|
|�	||	�O}
�qz|
WSt
k
�r�}ztd||f�d�W5d}~XYnXdS)Nr��:r�z At least %d parts expected in %rr�rLr��%xr�r)z!At most %d colons permitted in %rz At most one '::' permitted in %rrz0Leading ':' only permitted as part of '::' in %rz1Trailing ':' only permitted as part of '::' in %rz/Expected at most %d other parts with '::' in %rz,Exactly %d parts expected without '::' in %r)rr$r%rrCr,rF�
_HEXTET_COUNTr��
_parse_hextetr)rjrw�partsZ
_min_partsrgZipv4_intr�Z
_max_partsZ
skip_index�iZparts_hiZparts_loZ
parts_skippedrnr	r	r
rvs�
$







z_BaseV6._ip_int_from_stringcCs>|j�|�std|��t|�dkr4d}t||��t|d�S)NzOnly hex digits permitted in %rrz$At most 4 characters permitted in %rr)�_HEX_DIGITS�
issupersetrr%rt)rjZ
hextet_strrgr	r	r
r~sz_BaseV6._parse_hextetc	Cs�d}d}d}d}t|�D]>\}}|dkrN|d7}|dkr<|}||krV|}|}qd}d}q|dkr�||}|t|�kr~|dg7}dg|||�<|dkr�dg|}|S)NrLrr�r)�)�	enumerater%)	rj�hextetsZbest_doublecolon_startZbest_doublecolon_lenZdoublecolon_startZdoublecolon_len�indexZhextetZbest_doublecolon_endr	r	r
�_compress_hextets�s0�

z_BaseV6._compress_hextetsNcsZ|dkrt|j�}||jkr$td��d|��fdd�tddd�D�}|�|�}d�|�S)	NzIPv6 address is too large�%032xcs&g|]}dt�||d�d��qS)rrr)rt�r�r��Zhex_strr	r
�
<listcomp>�sz/_BaseV6._string_from_ip_int.<locals>.<listcomp>rrrr)rtr,r>rr�rr�)rjrnrr	rr
r��s


z_BaseV6._string_from_ip_intcs�t|t�rt|j�}nt|t�r,t|j�}nt|�}|�|�}d|��fdd�tddd�D�}t|ttf�r�dd�	|�|j
fSd�	|�S)	Nrcsg|]}�||d��qS)rr	rrr	r
r�sz8_BaseV6._explode_shorthand_ip_string.<locals>.<listcomp>rrrr�r)r9rr#rPrr1rvr�rTr�rN)r]rwrnrr	rr
r[�s



z$_BaseV6._explode_shorthand_ip_stringcCs&|jddd��dd�}d�|�dS)NrLrrr�z	.ip6.arpa)r^�replacer�)r]Z
reverse_charsr	r	r
ra�sz_BaseV6._reverse_pointercCs|jSrAr�r\r	r	r
r�sz_BaseV6.max_prefixlencCs|jSrAr�r\r	r	r
r<sz_BaseV6.version)N)rrrr~rM�
IPV6LENGTHr>r
�	frozensetrr=r�r�r�rvrrr�r[rarr�r<r	r	r	r
r�s.	

g

/	
rc@s�eZdZdZdd�Zedd��Zedd��Zedd	��Zed
d��Z	edd
��Z
ee��dd���Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��ZdS)r
r�cCsrt|t�r|�|�||_dSt|t�rF|�|d�t�|d�|_dSt|�}d|krbtd|��|�	|�|_dS)Nrrr!r�r�r�r	r	r
r�s


zIPv6Address.__init__cCs
t|j�SrA)r r,r\r	r	r
r�6szIPv6Address.packedcCs||jjkSrAr�r\r	r	r
r�;s	zIPv6Address.is_multicastcst�fdd��jjD��S)Nc3s|]}�|kVqdSrAr	rr\r	r
r�Osz*IPv6Address.is_reserved.<locals>.<genexpr>)r�r��_reserved_networksr\r	r\r
r�Fs	zIPv6Address.is_reservedcCs||jjkSrAr�r\r	r	r
r�QszIPv6Address.is_link_localcCs||jjkSrA)r��_sitelocal_networkr\r	r	r
�
is_site_local[szIPv6Address.is_site_localcst�fdd��jjD��S)Nc3s|]}�|kVqdSrAr	r�r\r	r
r�ssz)IPv6Address.is_private.<locals>.<genexpr>r�r\r	r\r
r�is
zIPv6Address.is_privatecCs|jSrAr�r\r	r	r
r�us	zIPv6Address.is_globalcCs
|jdkSrqr�r\r	r	r
r��s	zIPv6Address.is_unspecifiedcCs
|jdkSr(r�r\r	r	r
r��s	zIPv6Address.is_loopbackcCs |jd?dkrdSt|jd@�S)Nrr	����r,rr\r	r	r
�ipv4_mapped�s	zIPv6Address.ipv4_mappedcCs4|jd?dkrdSt|jd?d@�t|jd@�fS)N�`i �@rr r\r	r	r
�teredo�s

�zIPv6Address.teredocCs$|jd?dkrdSt|jd?d@�S)N�pi �Prr r\r	r	r
�	sixtofour�s	zIPv6Address.sixtofourN)rrrr~r�rr�r�r�r�rr�r�r�r�r�r�r!r$r'r	r	r	r
r
s6$





	










r
c@s�eZdZdd�Zejdd��Zdd�Zdd�Zd	d
�Z	dd�Z
ejZe
d
d��Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd��ZdS)rcCsD|�|�\}}t�||�t||fdd�|_|jj|_|jj|_dSr�)r{r
r�rr�r�rNr�r	r	r
r��s

zIPv6Interface.__init__cCs|jjSrAr�r\r	r	r
r��szIPv6Interface.hostmaskcCsd|�|j�|jfSr�r�r\r	r	r
r��s�zIPv6Interface.__str__cCsFt�||�}|r|tkr|Sz|j|jkWStk
r@YdSXdSr�)r
r�rWr�rOr�r	r	r
r��szIPv6Interface.__eq__cCsRt�||�}|tkrtSz|j|jkp4|j|jko4|WStk
rLYdSXdSr�)r
r�rWr�rOr�r	r	r
r��s�zIPv6Interface.__lt__cCst|j|jt|jj�f�SrAr�r\r	r	r
r��szIPv6Interface.__hash__cCs
t|j�SrA)r
r,r\r	r	r
r1�szIPv6Interface.ipcCsd|�|j�|jfSr�r�r\r	r	r
r��s�zIPv6Interface.with_prefixlencCsd|�|j�|jfSr�r�r\r	r	r
r��s�zIPv6Interface.with_netmaskcCsd|�|j�|jfSr�r�r\r	r	r
r��s�zIPv6Interface.with_hostmaskcCs|jdko|jjSrq)r,r�r�r\r	r	r
r�szIPv6Interface.is_unspecifiedcCs|jdko|jjSr()r,r�r�r\r	r	r
r�szIPv6Interface.is_loopbackN)rrrr�r�r�r�r�r�r�r�rZr}rr1r�r�r�r�r�r	r	r	r
r�s(





rc@s.eZdZeZd	dd�Zdd�Zedd��ZdS)
rTcs�|�|�\�}t��|_|�|�\|_|_t|j�}|t|j�@|krl|rXtd|��nt|t|j�@�|_|j|jdkr�|j	|_
n|j|jkr��fdd�|_
dS)Nr�r)cs
t��gSrA)r
r	rr	r
rIrz&IPv6Network.__init__.<locals>.<lambda>)r{r
rPr�r�rNrtrr=r�r�rr	rr
r�s

�
zIPv6Network.__init__ccs<t|j�}t|j�}t|d|d�D]}|�|�Vq&dSr(r�r�r	r	r
r�Ks

zIPv6Network.hostscCs|jjo|jjSrA)rPrrIr\r	r	r
rWs�zIPv6Network.is_site_localN)T)	rrrr
r�r�r�rrr	r	r	r
rs

0rc@s�eZdZed�Zed�Zed�ed�ed�ed�ed�ed�ed	�ed
�ed�ed�g
Zed�ed
�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�gZed�ZdS)�_IPv6Constantsz	fe80::/10zff00::/8z::1/128z::/128z
::ffff:0:0/96z100::/64z	2001::/23z2001:2::/48z
2001:db8::/32z2001:10::/28zfc00::/7z::/8z100::/8z200::/7z400::/6z800::/5z1000::/4z4000::/3z6000::/3z8000::/3zA000::/3zC000::/3zE000::/4zF000::/5zF800::/6zFE00::/9z	fec0::/10N)	rrrrr�r�r�rrr	r	r	r
r(gs<��r()T)"�__version__r�r�rrrrrrrrr r'r2r6r@rKrSrYrZ�total_orderingr:rTr�rrrrr�rr
rrr(r	r	r	r
�<module>sT
#7163:IuCR 5K\!

?>