%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/netaddr/ip/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/netaddr/ip/__pycache__/__init__.cpython-312.pyc

�

�C�^����dZddlZddlmZmZmZmZmZm	Z	m
Z
mZmZm
Z
ddlmZmZddlmZmZmZmZmZmZGd�de�ZGd�d	e�ZGd
�de�ZdGd�ZGd
�dee�ZGd�dee�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&dHd�Z'd�Z(d�Z)d�Z*d�Z+ed�Z,ed�ed�ed�ed �ed!�ed"�e d#d$�fZ-ed%�Z.ed&�Z/ed'�Z0ed(�ed)�ed*�ed+�ed,�ed-�e d.d/�e d0d1�fe,e0fzZ1ed2�Z2ed3�ed4�fZ3ed5�Z4ed6�Z5ed7�ed8�ed9�ed:�ed;�ed<�ed=�ed>�ed?�ed@�edA�edB�edC�edD�edE�edF�fZ6y)Iz9Routines for IPv4 and IPv6 addresses, subnets and ranges.�N)
�AddrFormatError�AddrConversionError�num_bits�
DictDotLookup�NOHOST�N�	INET_PTON�P�ZEROFILL�Z)�ipv4�ipv6)�_sys_maxint�
_iter_next�_iter_range�_is_str�	_int_type�	_str_typec��eZdZdZdZd�Zd�Zed�ed��Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed��Zed��Zy)�BaseIPzi
    An abstract base class for common operations shared between various IP
    related subclasses.

    )�_value�_module�__weakref__c� �d|_d|_y)zConstructor.N)rr��selfs �5/usr/lib/python3/dist-packages/netaddr/ip/__init__.py�__init__zBaseIP.__init__s��������c���t|t�stdt|�z��d|cxkr|jj
ks$nt
d|jjz��||_y)N�int argument expected, not %srz&value out of bounds for an %s address!)	�
isinstancer�	TypeError�typer�max_intr�family_namer�r�values  r�
_set_valuezBaseIP._set_value sa���%��+��;�d�5�k�I�J�J��E�1�T�\�\�1�1�1�!�"J��,�,�*�*�#+�,�
,���rc��|jS�N�rrs r�<lambda>zBaseIP.<lambda>(s
��$�+�+�rz?a positive integer representing the value of IP address/subnet.��docc��tS�zP
        :return: a key tuple that uniquely identifies this IP address.
        ��NotImplementedrs r�keyz
BaseIP.key+s
���rc��tS)zg
        :return: A key tuple used to compare and sort this `IPAddress`
            correctly.
        r2rs r�sort_keyzBaseIP.sort_key1s
��
�rc�4�t|j��S)zM
        :return: A hash value uniquely indentifying this IP object.
        )�hashr4rs r�__hash__zBaseIP.__hash__8s���D�H�H�J��rc�|�	|j�|j�k(S#ttf$r	tcYSwxYw)z�
        :param other: an `IPAddress` or `IPNetwork` object.

        :return: ``True`` if this `IPAddress` or `IPNetwork` object is
            equivalent to ``other``, ``False`` otherwise.
        �r4�AttributeErrorr#r3�r�others  r�__eq__z
BaseIP.__eq__>�8��	"��8�8�:�����,�,���	�*�	"�!�!�	"��� #�;�;c�|�	|j�|j�k7S#ttf$r	tcYSwxYw)z�
        :param other: an `IPAddress` or `IPNetwork` object.

        :return: ``True`` if this `IPAddress` or `IPNetwork` object is
            not equivalent to ``other``, ``False`` otherwise.
        r;r=s  r�__ne__z
BaseIP.__ne__Jr@rAc�|�	|j�|j�kS#ttf$r	tcYSwxYw)z�
        :param other: an `IPAddress` or `IPNetwork` object.

        :return: ``True`` if this `IPAddress` or `IPNetwork` object is
            less than ``other``, ``False`` otherwise.
        �r6r<r#r3r=s  r�__lt__z
BaseIP.__lt__V�9��	"��=�=�?�U�^�^�%5�5�5���	�*�	"�!�!�	"�rAc�|�	|j�|j�kS#ttf$r	tcYSwxYw)z�
        :param other: an `IPAddress` or `IPNetwork` object.

        :return: ``True`` if this `IPAddress` or `IPNetwork` object is
            less than or equal to ``other``, ``False`` otherwise.
        rEr=s  r�__le__z
BaseIP.__le__b�9��	"��=�=�?�e�n�n�&6�6�6���	�*�	"�!�!�	"�rAc�|�	|j�|j�kDS#ttf$r	tcYSwxYw)z�
        :param other: an `IPAddress` or `IPNetwork` object.

        :return: ``True`` if this `IPAddress` or `IPNetwork` object is
            greater than ``other``, ``False`` otherwise.
        rEr=s  r�__gt__z
BaseIP.__gt__nrGrAc�|�	|j�|j�k\S#ttf$r	tcYSwxYw)z�
        :param other: an `IPAddress` or `IPNetwork` object.

        :return: ``True`` if this `IPAddress` or `IPNetwork` object is
            greater than or equal to ``other``, ``False`` otherwise.
        rEr=s  r�__ge__z
BaseIP.__ge__zrJrAc�$�|j�S)z<:return: ``True`` if this IP is unicast, ``False`` otherwise)�is_multicastrs r�
is_unicastzBaseIP.is_unicast�s���$�$�&�&�&rc�p�|jtk(r|tvS|jtk(r|tvSy)z>:return: ``True`` if this IP is multicast, ``False`` otherwiseN)r�_ipv4�IPV4_MULTICAST�_ipv6�IPV6_MULTICASTrs rrPzBaseIP.is_multicast�s5���<�<�5� ��>�)�)�
�\�\�U�
"��>�)�)�#rc��|jjdk(r|tvS|jjdk(r	|tk(Sy)z�
        :return: ``True`` if this IP is loopback address (not for network
            transmission), ``False`` otherwise.
            References: RFC 3330 and 4291.
        ��N)r�version�
IPV4_LOOPBACK�
IPV6_LOOPBACKrs r�is_loopbackzBaseIP.is_loopback�sC���<�<���1�$��=�(�(�
�\�\�
!�
!�Q�
&��=�(�(�'rc���|jjdk(rtD]}||vs�yn*|jjdk(rtD]}||vs�y|j	�ryy)z�
        :return: ``True`` if this IP is for internal/private use only
            (i.e. non-public), ``False`` otherwise. Reference: RFCs 1918,
            3330, 4193, 3879 and 2365.
        rXTrYF)rrZ�IPV4_PRIVATE�IPV6_PRIVATE�
is_link_local�r�cidrs  r�
is_privatezBaseIP.is_private�sp���<�<���1�$�$�
 ���4�<��
 ��\�\�
!�
!�Q�
&�$�
 ���4�<��
 ������rc��|jjdk(r|tvS|jjdk(r|tvSy)z�
        :return: ``True`` if this IP is link-local address ``False`` otherwise.
            Reference: RFCs 3927 and 4291.
        rXrYN)rrZ�IPV4_LINK_LOCAL�IPV6_LINK_LOCALrs rrazBaseIP.is_link_local�sC��
�<�<���1�$��?�*�*�
�\�\�
!�
!�Q�
&��?�*�*�'rc��|jjdk(rtD]}||vs�yy|jjdk(rtD]}||vs�yy)z�
        :return: ``True`` if this IP is in IANA reserved range, ``False``
            otherwise. Reference: RFCs 3330 and 3171.
        rXTrYF)rrZ�
IPV4_RESERVED�
IPV6_RESERVEDrbs  r�is_reservedzBaseIP.is_reserved�sf��
�<�<���1�$�%�
 ���4�<��
 ��	�\�\�
!�
!�Q�
&�%�
 ���4�<��
 �rc�\�|jjdk(xr|jdz	dk(S)zp
        :return: ``True`` if this IP is IPv4-compatible IPv6 address, ``False``
            otherwise.
        rY� i���rrZrrs r�is_ipv4_mappedzBaseIP.is_ipv4_mapped�s,��
�|�|�#�#�q�(�J�d�k�k�R�.?�F�-J�Jrc�\�|jjdk(xr|jdz	dk(S)zl
        :return: ``True`` if this IP is IPv4-mapped IPv6 address, ``False``
            otherwise.
        rYrmrrnrs r�is_ipv4_compatzBaseIP.is_ipv4_compat�s,��
�|�|�#�#�q�(�E�d�k�k�R�.?�A�-E�Erc�0�ddlm}t||��S)z~
        A record dict containing IANA registration details for this IP address
        if available, None otherwise.
        r)�query)�netaddr.ip.ianarsr)rrss  r�infozBaseIP.info�s��	*��U�4�[�)�)rc�.�|jjS)z6the IP protocol version represented by this IP object.)rrZrs rrZzBaseIP.version�s���|�|�#�#�#rN)�__name__�
__module__�__qualname__�__doc__�	__slots__rr)�propertyr(r4r6r9r?rCrFrIrLrNrQrPr]rdrarkrorqrurZ�rrrrs����
5�I��
�
�-�z�M�
O�E��� �
"�
"�
"�
"�
"�
"�'�*�	)��(+�
�K�F��*��*��$��$rrc�*��eZdZdZdZd&�fd�	Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
e
Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd'd�Zed��Zed��Zed��Zed��Zd�Zd(d�Z d'd�Z!d�Z"d�Z#d �Z$d!�Z%d"�Z&d#�Z'e'Z(d$�Z)d%�Z*�xZ+S))�	IPAddressz�
    An individual IPv4 or IPv6 address without a net mask or subnet prefix.

    To support these and other network based operations, see `IPNetwork`.

    r}c���tt|��t|t�rI|�$||j
jk7rtd��|j|_|j
|_y|�0|dk(rt|_n|dk(rt|_ntd|z��t|�r&d|vr"td|jjz��|j
��t|t�r�	dt|�cxkrtj krnnt|�|_t|_nNtj t|�cxkrtj krnnt|�|_t|_n1ttfD]"}	|j#||�|_||_n|j
�t%d	|z��yt|�r#	|j
j#||�|_ydt|�cxkr|j
j krnnt|�|_yt%d|����#t$rY��wxYw#Y��xYw#t$$r%t%d
||j
jfz��wxYw)a�
        Constructor.

        :param addr: an IPv4 or IPv6 address which may be represented in an
            accepted string format, as an unsigned integer or as another
            IPAddress object (copy construction).

        :param version: (optional) optimizes version detection if specified
            and distinguishes between IPv4 and IPv6 for addresses with an
            equivalent integer value.

        :param flags: (optional) decides which rules are applied to the
            interpretation of the addr value. Supported constants are
            INET_PTON and ZEROFILL. See the netaddr.core docs for further
            details.

        Nz1cannot switch IP versions using copy constructor!rXrY�%r is an invalid IP version!�/zQ%s() does not support netmasks or subnet prefixes! See documentation for details.rz+failed to detect a valid IP address from %rzbase address %r is not IPv%dzbad address format: )�superrrr"rrrZ�
ValueErrorrrSrUr�	__class__rwr�intr%�
str_to_intr)r�addrrZ�flags�moduler�s     �rrzIPAddress.__init__�sE���$	�i��'�)��d�F�#��"�w�$�,�,�2F�2F�'F� �"(�)�)��+�+�D�K��<�<�D�L��"��a�<�#(�D�L���\�#(�D�L�$�%C�g�%M�N�N��t�}���� �"@��n�n�-�-�".�/�/��|�|�#��d�I�.����D�	�:�U�]�]�:�*-�d�)�D�K�+0�D�L�"�]�]�S��Y�G�%�-�-�G�*-�d�)�D�K�+0�D�L��#(��,�"��"�*0�*;�*;�D�%�*H�D�K�,2�D�L�!�"��<�<�'�)�+*�,0�+1�2�2�(�
�4�=�<�&*�l�l�&=�&=�d�E�&J���
�C��I�=����)=�)=�=�&)�$�i���-�$�.P�Q�Q��7&�����%�$��+�<�-�.L�#�T�\�\�%9�%9�:�/;�<�<�<�s+�-BI�
I�!I�	I
�I
�I�.Jc�F�|j|jjfS)z1:returns: Pickled state of an `IPAddress` object.)rrrZrs r�__getstate__zIPAddress.__getstate__As���{�{�D�L�L�0�0�0�0rc��|\}}||_|dk(rt|_y|dk(rt|_yt	dt|�z��)zT
        :param state: data used to unpickle a pickled `IPAddress` object.

        rXrYz&unpickling failed for object state: %sN)rrSrrUr��str)r�stater(rZs    r�__setstate__zIPAddress.__setstate__EsL��
���w�����a�<� �D�L�
��\� �D�L��E��e�*���
rc�Z�|j�s|jjS|jdk(ry|j}d}|dkDr|dzdk(rn|dz
}|dz}|dkDr�|jj|z
}d|cxkr|jjksnt	d|z��|S)z�
        @return: If this IP is a valid netmask, the number of non-zero
            bits are returned, otherwise it returns the width in bits for
            the IP address version.
        r�z+Unexpected mask length %d for address type!)�
is_netmaskr�widthrr�)r�i_val�numbits�mask_lengths    r�netmask_bitszIPAddress.netmask_bitsVs������ ��<�<�%�%�%��;�;�!����������a�i��q�y�A�~���q�L�G��a�K�E�	�a�i��l�l�(�(�7�2���K�5�4�<�<�#5�#5�5��J����
��rc�6�|jdz}||dz
zdk(S)zV
        :return: ``True`` if this IP address host mask, ``False`` otherwise.
        r�rr,�r�int_vals  r�is_hostmaskzIPAddress.is_hostmaskus%���+�+��/���7�Q�;�'�1�,�-rc�d�|j|jjzdz}||dz
zdk(S)zY
        :return: ``True`` if this IP address network mask, ``False`` otherwise.
        r�r)rrr%r�s  rr�zIPAddress.is_netmask|s5���;�;����!5�!5�5��:���7�Q�;�'�1�,�-rc��t|j|z�}d|cxkr|jjkrnt	d��||_|St	d��)z�
        Increases the numerical value of this IPAddress by num.

        An IndexError is raised if result exceeds maximum IP address value or
        is less than zero.

        :param num: size of IP address increment.
        r�)result outside valid IP address boundary!�r�rrr%�
IndexError�r�num�	new_values   r�__iadd__zIPAddress.__iadd__��V������c�)�*�	��	�1�T�\�\�1�1�1��D�E�E�$�D�K��K��D�E�Erc��t|j|z
�}d|cxkr|jjkrnt	d��||_|St	d��)z�
        Decreases the numerical value of this IPAddress by num.

        An IndexError is raised if result is less than zero or exceeds maximum
        IP address value.

        :param num: size of IP address decrement.
        rr�r�r�s   r�__isub__zIPAddress.__isub__�r�rc���t|j|z�}d|cxkr|jjkr3nt
d��|j	||jj
�St
d��)a
        Add the numerical value of this IP address to num and provide the
        result as a new IPAddress object.

        :param num: size of IP address increase.

        :return: a new IPAddress object with its numerical value increased by num.
        rr��r�rrr%r�rZr�r�s   r�__add__zIPAddress.__add__��c������c�)�*�	��	�1�T�\�\�1�1�1��D�E�E��>�>�)�T�\�\�-A�-A�B�B��D�E�Erc���t|j|z
�}d|cxkr|jjkr3nt
d��|j	||jj
�St
d��)a
        Subtract the numerical value of this IP address from num providing
        the result as a new IPAddress object.

        :param num: size of IP address decrease.

        :return: a new IPAddress object with its numerical value decreased by num.
        rr�r�r�s   r�__sub__zIPAddress.__sub__�r�rc���t||jz
�}d|cxkr|jjkr3nt
d��|j	||jj
�St
d��)a
        Subtract num (lvalue) from the numerical value of this IP address
        (rvalue) providing the result as a new IPAddress object.

        :param num: size of IP address decrease.

        :return: a new IPAddress object with its numerical value decreased by num.
        rr�r�r�s   r�__rsub__zIPAddress.__rsub__�sc����d�k�k�)�*�	��	�1�T�\�\�1�1�1��D�E�E��>�>�)�T�\�\�-A�-A�B�B��D�E�Erc�F�|jj|jfSr1rnrs rr4z
IPAddress.key�s���|�|�#�#�T�[�[�0�0rc�p�|jj|j|jjfS)zI:return: A key tuple used to compare and sort this `IPAddress` correctly.)rrZrr�rs rr6zIPAddress.sort_key�s'���|�|�#�#�T�[�[�$�,�,�2D�2D�D�Drc��|jS�z<:return: the value of this IP address as an unsigned integerr,rs r�__int__zIPAddress.__int__�����{�{�rc��|jSr�r,rs r�__long__zIPAddress.__long__�r�rc�@�|jdk(ryd|jzS)z;:return: an octal string representation of this IP address.r�0z0%or,rs r�__oct__zIPAddress.__oct__�s"���;�;�!����t�{�{�"�"rc� �d|jzS)z@:return: a hexadecimal string representation of this IP address.z0x%xr,rs r�__hex__zIPAddress.__hex__�s������#�#rc��|jS)zx
        :return: return the integer value of this IP address when called by             hex(), oct() or bin().
        r,rs r�	__index__zIPAddress.__index__�s���{�{�rc�h�|jj|jjdzd�S)zt 
        :return: a bytes object equivalent to this IP address. In network
        byte order, big-endian.
        ��big)r�to_bytesrr�rs r�	__bytes__zIPAddress.__bytes__�s*���{�{�#�#�D�L�L�$6�$6��$9�5�A�Arc�N�|jj|j|�S)z�
        :param word_sep: (optional) the separator to insert between words.
            Default: None - use default separator for address type.

        :return: the value of this IP address as a binary digit string.)r�int_to_bitsr)r�word_seps  r�bitszIPAddress.bits�s���|�|�'�'����X�>�>rc�L�|jj|j�S)z7The value of this IP address as a packed binary string.)r�
int_to_packedrrs r�packedzIPAddress.packeds���|�|�)�)�$�+�+�6�6rc�L�|jj|j�S)zx
        A list of unsigned integer words (octets for IPv4, hextets for IPv6)
        found in this IP address.
        )r�int_to_wordsrrs r�wordszIPAddress.wordss���|�|�(�(����5�5rc�L�|jj|j�S)z�
        The value of this IP adddress in standard Python binary
        representational form (0bxxx). A back port of the format provided by
        the builtin bin() function found in Python 2.6.x and higher.
        )r�
int_to_binrrs r�binz
IPAddress.bins���|�|�&�&�t�{�{�3�3rc�L�|jj|j�S)z1The reverse DNS lookup record for this IP address)r�int_to_arparrs r�reverse_dnszIPAddress.reverse_dnss���|�|�'�'����4�4rc��d}|j}|jjdk(r||jd�}|S|jjdk(r�d|jcxkrtj
krnn||jd�}|Stj
|jcxkrdkrnn||jdz
d�}|St
d|z��|S)z�
        Raises an `AddrConversionError` if IPv6 address cannot be converted
        to IPv4.

        :return: A numerically equivalent version 4 `IPAddress` object.
        NrXrYr�������2IPv6 address %s unsuitable for conversion to IPv4!)r�rrZrrSr%r)r�ip�klasss   rr
zIPAddress.ipv4!s����������<�<���1�$��t�{�{�A�&�B��	��\�\�
!�
!�Q�
&��D�K�K�0�5�=�=�0��4�;�;��*���	����$�+�+�?��?��4�;�;��7��;���	�*�+*�,0�+1�2�2��	rc�j�d}|j}|jjdk(rG|r0d|jcxkrdkrnn||jdz
d�}|S||jd�}|S|jjdk(r+||jd�}|s|d|jzd�}|S)a�
        .. note:: The IPv4-mapped IPv6 address format is now considered             deprecated. See RFC 4291 or later for details.

        :param ipv4_compatible: If ``True`` returns an IPv4-mapped address
            (::ffff:x.x.x.x), an IPv4-compatible (::x.x.x.x) address
            otherwise. Default: False (IPv4-mapped).

        :return: A numerically equivalent version 6 `IPAddress` object.
        NrYr�r�rX)r�rrZr�r�ipv4_compatibler�r�s    rrzIPAddress.ipv67s����������<�<���1�$���4�;�;�@�.�@��4�;�;��7��;���	��4�;�;��*���	��\�\�
!�
!�Q�
&��t�{�{�A�&�B�"��>�D�K�K�7��;���	rc��|�t|d�std��|jj|j|��S)z�
        Only relevant for IPv6 addresses. Has no effect for IPv4.

        :param dialect: An ipv6_* dialect class.

        :return: an alternate string representation for this IP address.
        �word_fmtz-custom dialects should subclass ipv6_verbose!)�dialect)�hasattrr#r�
int_to_strr)rr�s  r�formatzIPAddress.formatTsD�����7�J�/��C�E�E��|�|�&�&�t�{�{�G�&�D�Drc�z�|j|jt|�z|jj�S)z�
        :param other: An `IPAddress` object (or other int-like object).

        :return: bitwise OR (x | y) between the integer value of this IP
            address and ``other``.
        �r�rr�rrZr=s  r�__or__zIPAddress.__or__b�,���~�~�d�k�k�C��J�6����8L�8L�M�Mrc�z�|j|jt|�z|jj�S)z�
        :param other: An `IPAddress` object (or other int-like object).

        :return: bitwise AND (x & y) between the integer value of this IP
            address and ``other``.
        r�r=s  r�__and__zIPAddress.__and__kr�rc�z�|j|jt|�z|jj�S)z�
        :param other: An `IPAddress` object (or other int-like object).

        :return: bitwise exclusive OR (x ^ y) between the integer value of
            this IP address and ``other``.
        r�r=s  r�__xor__zIPAddress.__xor__tr�rc�h�|j|j|z|jj�S)z�
        :param numbits: size of bitwise shift.

        :return: an `IPAddress` object based on this one with its integer
            value left shifted by ``numbits``.
        �r�rrrZ�rr�s  r�
__lshift__zIPAddress.__lshift__}�(���~�~�d�k�k�W�4�d�l�l�6J�6J�K�Krc�h�|j|j|z	|jj�S)z�
        :param numbits: size of bitwise shift.

        :return: an `IPAddress` object based on this one with its integer
            value right shifted by ``numbits``.
        r�r�s  r�
__rshift__zIPAddress.__rshift__�r�rc�,�t|j�S)zi:return: ``True`` if the numerical value of this IP address is not             zero, ``False`` otherwise.)�boolrrs r�__nonzero__zIPAddress.__nonzero__�s���D�K�K� � rc�L�|jj|j�S)z,:return: IP address in presentational format)rr�rrs r�__str__zIPAddress.__str__�s���|�|�&�&�t�{�{�3�3rc�:�|jj�d|�d�S��8:return: Python statement to create an equivalent object�('�')�r�rwrs r�__repr__zIPAddress.__repr__����!�^�^�4�4�d�;�;r)Nrr+�F),rwrxryrzr{rr�r�r�r�r�r�r�r��__radd__r�r�r4r6r�r�r�r�r�r�r�r|r�r�r�r�r
rr�r�r�r�r�r�r��__bool__r�r��
__classcell__�r�s@rrr�s�����I�OR�b1��"�>.�.�
F�
F�F��H�F�F�1�E���#�$�
�B�?��7��7��6��6��4��4��5��5��,�:E�N�N�N�L�L�!��H�4�<rrc�F�eZdZdZdZd�Zed��Zd�Zd�Z	d�Z
d�ZeZy	)
�IPListMixinzu
    A mixin class providing shared list-like functionality to classes
    representing groups of IP addresses.

    r}c���t|j|jj�}t|j|jj�}t||�S)z�
        :return: An iterator providing access to all `IPAddress` objects
            within range represented by this ranged IP object.
        )r�firstrrZ�last�iter_iprange)r�start_ip�end_ips   r�__iter__zIPListMixin.__iter__�sE��
�T�Z�Z����)=�)=�>���4�9�9�d�l�l�&:�&:�;���H�f�-�-rc�L�t|j|jz
dz�S)zP
        The total number of IP addresses within this ranged IP object.
        r�)r�r	rrs r�sizezIPListMixin.size�s!��
�4�9�9�t�z�z�)�A�-�.�.rc�T�|j}|tkDrtdtz��|S)z�
        :return: the number of IP addresses in this ranged IP object. Raises
            an `IndexError` if size > system max int (a Python 2.x
            limitation). Use the .size property for subnets of any size.
        zVrange contains more than %d (sys.maxint) IP addresses! Use the .size property instead.)rrr�)rrs  r�__len__zIPListMixin.__len__�s7���y�y���+���?�AL�M�O�
O��rc��d}t|d�r�|jjdk(rtd��|j	|j
�\}}}||zdks||kDr6t
t|j|jj�g�}|St|j|z|jj�}t|j|z|z
|jj�}t|||�}|S	t|�}|j
|cxkrdkr5nn2t|j|zdz|jj�}|Sd|cxkr|j
dz
kr<ntd��t|j|z|jj�}|Std��#t$rtd|z��wxYw)	z�
        :return: The IP address(es) in this `IPNetwork` object referenced by
            index or slice. As slicing can produce large sequences of objects
            an iterator is returned instead of the more usual `list`.
        N�indicesrYzIPv6 slices are not supported!rr�z'index out range for address range size!zunsupported index type %r!)r�rrZr#rr�iterrrr
r�r	r�r�)r�index�item�start�stop�steprrs        r�__getitem__zIPListMixin.__getitem__�s������5�)�$��|�|�#�#�q�(�� @�A�A�"'�-�-��	�	�":��U�D�$����q� �d�T�k��Y�t�z�z�4�<�<�3G�3G�H�I�J��&��#%�T�Z�Z�%�%7����9M�9M�N��"�4�:�:��#4�t�#;�T�\�\�=Q�=Q�R��#�H�f�d�;����
F��E�
���i�i�K�E�-�A�-�$�T�Y�Y��%6��%:�D�L�L�<P�<P�Q�D����%�2�D�I�I��M�2�%�%N�O�O�%�T�Z�Z�%�%7����9M�9M�N�D���	%�%N�O�O���
F�� <�u� D�E�E�
F�s�AF7�AF7�,F7�7Gc��t|t�r�|jj|jjk7ryt|t�r4|j
|jk\xr|j
|jkS|j|jk\xr|j|jkSt	|�|vS)��
        :param other: an `IPAddress` or ranged IP object.

        :return: ``True`` if other falls within the boundary of this one,
            ``False`` otherwise.
        F)r"rrrZrrrr	r=s  r�__contains__zIPListMixin.__contains__�s����e�V�$��|�|�#�#�u�}�}�'<�'<�<���%��+��|�|�t�z�z�1�O�e�l�l�d�i�i�6O�O��;�;�$�*�*�,�H����t�y�y�1H�H����4�'�'rc��y)z�
        Ranged IP objects always represent a sequence of at least one IP
        address and are therefore always True in the boolean context.
        Tr}rs rr�zIPListMixin.__nonzero__�s��rN)
rwrxryrzr{r
r|rrrrr�rr}rrrr�sC���
�I�.��/��/�
�#�J(�$��Hrrc���t|t�r�t|�dk7rtd|jz��|\}}d|cxkr|j
ksntd|jz��d|cxkr|jks�ntd|jz��t|t�r�|rt|�}d|vr|jdd�\}}n|}d}	t||jt��}|j}	t!|�}dcxkr|jks1ntd|jz��t#d
t/|�z��|t0zr|j2|}||z}||fS#t$rR|jd	k(r2tj|�}	t|	|jt��}ntd
|z��Y��wxYw#t"$r|�|j}Y��t$$r�t||jt��}
|
j'�r|j(|
j}n8|
j+�r|j,|
j}ntd|z��Y��gwxYw)N�zinvalid %s tuple!rz#invalid address value for %s tuple!zinvalid prefix for %s tuple!r�r��r�rXzinvalid IPNetwork address %s!z!addr %r is not a valid IPNetwork!zinvalid prefix for %s address!zunexpected type %s for addr arg)r"�tuple�lenrr&r%r�r�cidr_abbrev_to_verbose�splitrrZr	rS�expand_partial_addressrr�r#r�r��netmask_to_prefixr��hostmask_to_prefixr$r�prefix_to_netmask)r�r��implicit_prefixr�r(�	prefixlen�val1�val2r��
expanded_addr�mask�netmasks            r�parse_ip_networkr1s^���$����t�9��>�!�"5��8J�8J�"J�K�K����y��E�+�V�^�^�+�!�"G��$�$�#%�&�
&��I�-����-�!�"@��$�$�#%�&�
&�	�D�)�	$��)�$�/�D��$�;����C��+�J�D�$��D��D�	N��4����y�A�B��	�	��	��D�	�I� �I�-����-�!�"B��$�$�#%�&�
&��9�D��J�F�G�G��v�~��*�*�9�5�������)����M�	N��~�~��"� %� <� <�T� B�
��}�f�n�n�I�N��%�&E��&L�M�M��		N���	)��|�"�L�L�	���		��T�6�>�>��C�D���� �"�4�4�T�[�[�A�	��!�!�#�"�5�5�d�k�k�B�	�%�&I��'����		�s,�E1�?G�1AG�G�I2�(BI2�1I2c�t��eZdZdZdZd#�fd�	Zd�Zd�Zd�Ze	d�ed�	�Z
e	d
��Ze	d��Ze	d��Z
e	d
��Ze	d��Ze	d��Zej"d��Ze	d��Ze	d��Ze	d��Ze	d��Zd�Zd�Zd�Zd�Zd�Zd�Zd$d�Zd%d�Zd%d�Zd&d�Zd'd�Z d �Z!d!�Z"d"�Z#�xZ$S)(�	IPNetworka�
    An IPv4 or IPv6 network or subnet.

    A combination of an IP address and a network mask.

    Accepts CIDR and several related variants :

    a) Standard CIDR::

        x.x.x.x/y -> 192.0.2.0/24
        x::/y -> fe80::/10

    b) Hybrid CIDR format (netmask address instead of prefix), where 'y'        address represent a valid netmask::

        x.x.x.x/y.y.y.y -> 192.0.2.0/255.255.255.0
        x::/y:: -> fe80::/ffc0::

    c) ACL hybrid CIDR format (hostmask address instead of prefix like        Cisco's ACL bitmasks), where 'y' address represent a valid netmask::

        x.x.x.x/y.y.y.y -> 192.0.2.0/0.0.0.255
        x::/y:: -> fe80::/3f:ffff:ffff:ffff:ffff:ffff:ffff:ffff

    d) Abbreviated CIDR format (as of netaddr 0.7.x this requires the        optional constructor argument ``implicit_prefix=True``)::

        x       -> 192
        x/y     -> 10/8
        x.x/y   -> 192.168/16
        x.x.x/y -> 192.168.0/24

        which are equivalent to::

        x.0.0.0/y   -> 192.0.0.0/24
        x.0.0.0/y   -> 10.0.0.0/8
        x.x.0.0/y   -> 192.168.0.0/16
        x.x.x.0/y   -> 192.168.0.0/24

    .. warning::

        The next release (0.9.0) will contain a backwards incompatible change
        connected to handling of RFC 6164 IPv6 addresses (/127 and /128 subnets).
        When iterating ``IPNetwork`` and ``IPNetwork.iter_hosts()`` the first
        addresses in the networks will no longer be excluded and ``broadcast``
        will be ``None``.
    ��
_prefixlenc���tt|��d\}}}t|d�r%|j}|j
}|j}n�t|d�r%|j}|j
}|j}nl|dk(rtt|||��\}}t}nJ|dk(rtt|||��\}}t}n(|�td|z��	t}t||||�\}}||_||_||_y#t$r;	t}t||||�\}}n#t$rYnwxYw|�td	|����Y�YwxYw)
a�
        Constructor.

        :param addr: an IPv4 or IPv6 address with optional CIDR prefix,
            netmask or hostmask. May be an IP address in presentation
            (string) format, an tuple containing and integer address and a
            network prefix, or another IPAddress/IPNetwork object (copy
            construction).

        :param implicit_prefix: (optional) if True, the constructor uses
            classful IPv4 rules to select a default prefix when one is not
            provided. If False it uses the length of the IP address version.
            (default: False)

        :param version: (optional) optimizes version detection if specified
            and distinguishes between IPv4 and IPv6 for addresses with an
            equivalent integer value.

        :param flags: (optional) decides which rules are applied to the
            interpretation of the addr value. Currently only supports the
            NOHOST option. See the netaddr.core docs for further details.

        )NNNr5rrX)r*r�rYNr�zinvalid IPNetwork )
r�r3rr�rrr5r�r1rSrUr�r)	rr�r*rZr�r(r+r�r�s	        �rrzIPNetwork.__init__{sb���0	�i��'�)�#3� ��y�&��4��&��K�K�E��\�\�F����I�
�T�8�
$��K�K�E��\�\�F����I�
��\�/��t� /�u� >��E�9��F�
��\�/��t� /�u� >��E�9��F��"� �!?�'�!I�J�J�

L���#3�F�D�#�U�$,� ��y����#�������#�	
L��"�F�'7���'��(0�$�E�9��&������=�)�D�*J�K�K�!�	
L�s6�C>�>	E�D �E� 	D,�)E�+D,�,E�Ec�\�|j|j|jjfS)z0:return: Pickled state of an `IPNetwork` object.)rr5rrZrs rr�zIPNetwork.__getstate__�s!���{�{�D�O�O�T�\�\�-A�-A�A�Arc���|\}}}||_|dk(rt|_n|dk(rt|_nt	d|����d|cxkr |jj
kr	||_yt	d|����)zT
        :param state: data used to unpickle a pickled `IPNetwork` object.

        rXrYz#unpickling failed for object state rN)rrSrrUr�r�r5)rr�r(r+rZs     rr�zIPNetwork.__setstate__�s���
%*�!��y�'�����a�<� �D�L�
��\� �D�L�����
�
�	�/�T�\�\�/�/�/�'�D�O�0�����
rc���t|t�stdt|�z��d|cxkr|jj
ks$nt
d|jjz��||_y)Nr!rz!invalid prefix for an %s address!)	r"rr#r$rr�rr&r5r's  r�_set_prefixlenzIPNetwork._set_prefixlen�sa���%��+��;�d�5�k�I�J�J��E�/�T�\�\�/�/�/�!�"E��,�,�*�*�#+�,�
,���rc��|jSr+r4rs rr-zIPNetwork.<lambda>�s
��d�o�o�rzCsize of the bitmask used to separate the network from the host bitsr.c�V�t|j|jj�S)z�
        The IP address of this `IPNetwork` object. This is may or may not be
        the same as the network IP address which varies according to the value
        of the CIDR subnet prefix.
        )rrrrZrs rr�zIPNetwork.ip�s������d�l�l�&:�&:�;�;rc�p�t|j|jz|jj�S)z/The network address of this `IPNetwork` object.)rr�_netmask_intrrZrs r�networkzIPNetwork.network�s*������t�'8�'8�8�$�,�,�:N�:N�O�Orc���|jjdk(r'|jj|jz
dkryt	|j
|jz|jj�S)aFThe broadcast address of this `IPNetwork` object.

        .. warning::

            The next release (0.9.0) will contain a backwards incompatible change
            connected to handling of RFC 6164 IPv6 addresses (/127 and /128 subnets).
            ``broadcast`` will be ``None`` when dealing with those networks.
        rXr�N)rrZr�r5rr�
_hostmask_intrs r�	broadcastzIPNetwork.broadcast�sZ���<�<���1�$�$�,�,�*<�*<�t���*N�ST�)T���T�[�[�4�+=�+=�=�t�|�|�?S�?S�T�Trc�b�|j|jj|jzzS)ze
        The integer value of first IP address found within this `IPNetwork`
        object.
        )rrr%rArs rrzIPNetwork.firsts(���{�{�d�l�l�2�2�T�5G�5G�G�H�Hrc�r�d|jj|jz
zdz
}|j|zS)zd
        The integer value of last IP address found within this `IPNetwork`
        object.
        r�)rr�r5r�r�hostmasks  rr	zIPNetwork.last
s5���$�,�,�,�,�t���>�?�1�D���{�{�X�%�%rc��|jj|jz}t||jj�S)z+The subnet mask of this `IPNetwork` object.)rr%rArrZ)rr0s  rr0zIPNetwork.netmasks5���,�,�&�&��);�);�;����$�,�,�"6�"6�7�7rc���t|�}|j|jk7rtd|�d|����|j�stdt	|�z��|j�|_y)z%Set the prefixlen using a subnet maskzIP version mismatch: z and z!Invalid subnet mask specified: %sN)rrZr�r�r�r�r+)rr(r�s   rr0zIPNetwork.netmasksZ���u�
��
�:�:����%���T�J�K�K��}�}���@�3�u�:�M�N�N����*��rc�H�|jj|jzS)z+Same as self.netmask, but in integer format)rr%rArs rr>zIPNetwork._netmask_int&s���|�|�#�#�d�&8�&8�8�8rc��d|jj|jz
zdz
}t||jj�S)z)The host mask of this `IPNetwork` object.r�)rr�r5rrZrEs  rrFzIPNetwork.hostmask+s=���$�,�,�,�,�t���>�?�1�D����4�<�<�#7�#7�8�8rc�T�d|jj|jz
zdz
S)z,Same as self.hostmask, but in integer formatr�)rr�r5rs rrAzIPNetwork._hostmask_int1s'���d�l�l�(�(�4�?�?�:�;�q�@�@rc��t|j|jz|jf|jj
��S)z�
        The true CIDR address for this `IPNetwork` object which omits any
        host bits to the right of the CIDR subnet prefix.
        �rZ)r3rr>r5rrZrs rrczIPNetwork.cidr6s9������t�0�0�0�$�/�/�B����,�,�.�	.rc���t|j�|j|zz}||jdz
z|jjkDrtd��|dkrtd��||_|S)aP
        Increases the value of this `IPNetwork` object by the current size
        multiplied by ``num``.

        An `IndexError` is raised if result exceeds maximum IP address value
        or is less than zero.

        :param num: (optional) number of `IPNetwork` blocks to increment             this IPNetwork's value by.
        r�z#increment exceeds address boundary!rzincrement is less than zero!)r�r?rrr%r�rr�s   rr�zIPNetwork.__iadd__@si������%����S��9�	�����Q��'�4�<�<�+?�+?�?��B�C�C��q�=��;�<�<�����rc���t|j�|j|zz
}|dkrtd��||jdz
z|jj
kDrtd��||_|S)aP
        Decreases the value of this `IPNetwork` object by the current size
        multiplied by ``num``.

        An `IndexError` is raised if result is less than zero or exceeds
        maximum IP address value.

        :param num: (optional) number of `IPNetwork` blocks to decrement             this IPNetwork's value by.
        rzdecrement is less than zero!r�z#decrement exceeds address boundary!)r�r?rr�rr%rr�s   rr�zIPNetwork.__isub__Usi������%����S��9�	��q�=��;�<�<�����Q��'�4�<�<�+?�+?�?��B�C�C�����rc�@�t|t��r|jj|jjk7ry|jj|j
z
}|j|z	}t|t�r=||z|jjkxr|dz|z|jjkDS|j|z	}t|t�r||k(St|t�r ||k(xr|j
|j
kSt|�|vS)rFr�)r"rrrZr�r5r�IPRange�_start�_endrr3)rr>�
shiftwidth�self_net�	other_nets     rrzIPNetwork.__contains__js����e�V�$��|�|�#�#�u�}�}�'<�'<�<�����+�+�d�o�o�=�J��{�{�j�0�H��%��)�"�Z�/�E�L�L�4G�4G�G�M�#�a�<�J�6�%�*�*�:K�:K�K�N����
�2�I��%��+� �H�,�,��%��+��9�,�T����E�DT�DT�1T�T����4�'�'rc�\�|jj|j|jfS)zR
        :return: A key tuple used to uniquely identify this `IPNetwork`.
        �rrZrr	rs rr4z
IPNetwork.key��#���|�|�#�#�T�Z�Z����:�:rc���|jdz
}|j|jj|jzz}|j|z
}|jj
|||fS)z[
        :return: A key tuple used to compare and sort this `IPNetwork` correctly.
        r�)r5rrr%rArZ)r�
net_size_bitsr�	host_bitss    rr6zIPNetwork.sort_key�s\�����!�+�
����t�|�|�3�3�d�6H�6H�H�I���K�K�%�'�	��|�|�#�#�U�M�9�D�Drc�r�d}|j}|jjdk(r#|d|j|jfz�}|S|jjdk(r�d|j
cxkrtjkr>nn;t
j|j
�}|d||jdz
fz�}|Stj|j
cxkrdkrAnn>t
j|j
dz
�}|d||jdz
fz�}|Std	|z��|S)
z�
        :return: A numerically equivalent version 4 `IPNetwork` object.             Raises an `AddrConversionError` if IPv6 address cannot be             converted to IPv4.
        NrX�%s/%drYr�`r�r�r�)
r�rrZr�r+rrSr%r�r)rr�r�r�s    rr
zIPNetwork.ipv4�s���������<�<���1�$��w�$�'�'�4�>�>�!:�:�;�B��	��\�\�
!�
!�Q�
&��D�K�K�0�5�=�=�0��'�'����4���7�d�D�N�N�R�,?�%@�@�A���	�
���$�+�+�?��?��'�'����n�(D�E���7�d�D�N�N�R�,?�%@�@�A���	�*�+*�,0�+1�2�2��	rc���d}|j}|jjdk(ra|r=d|jcxkrdkr(nn%||jdz
|jfd��}|S||j|jfd��}|S|jjdk(rM|r%||j|jdzfd��}|S|d|jz|jdzfd��}|S)a�
        .. note:: the IPv4-mapped IPv6 address format is now considered         deprecated. See RFC 4291 or later for details.

        :param ipv4_compatible: If ``True`` returns an IPv4-mapped address
            (::ffff:x.x.x.x), an IPv4-compatible (::x.x.x.x) address
            otherwise. Default: False (IPv4-mapped).

        :return: A numerically equivalent version 6 `IPNetwork` object.
        NrYr�r�rMrXr_)r�rrZrr5r�s    rrzIPNetwork.ipv6�s����������<�<���1�$���4�;�;�@�.�@��D�K�K�.�8�$�/�/�J�����	��D�K�K����9�1�E���	��\�\�
!�
!�Q�
&���D�K�K����2�)=�>��J���	��N�T�[�[�8� �O�O�b�0�2�;<�>���	rc��|jd|j|jfz|jj�}||z}|S)z�
        :param step: the number of IP subnets between this `IPNetwork` object
            and the expected subnet. Default: 1 (the previous IP subnet).

        :return: The adjacent subnet preceding this `IPNetwork` object.
        r^�r�r?r+rrZ�rr�ip_copys   r�previouszIPNetwork.previous��A���.�.��D�L�L�$�.�.�+I�!I��L�L� � �"���4����rc��|jd|j|jfz|jj�}||z
}|S)z�
        :param step: the number of IP subnets between this `IPNetwork` object
            and the expected subnet. Default: 1 (the next IP subnet).

        :return: The adjacent subnet succeeding this `IPNetwork` object.
        r^rbrcs   r�nextzIPNetwork.next�rfrc��d|cxkr|jjks&ntd||jjfz��g}|j}||_|j
|j
k7rJ|j
|j�|xj
dz
c_|j
|j
k7r�J|S)ab
        Provides a list of supernets for this `IPNetwork` object between the
        size of the current prefix and (if specified) an endpoint prefix.

        :param prefixlen: (optional) a CIDR prefix for the maximum supernet.
            Default: 0 - returns all possible supernets.

        :return: a tuple of supernet `IPNetwork` objects.
        r�"CIDR prefix /%d invalid for IPv%d!r�)rr�r�rZrcr5�append)rr+�	supernets�supernets    rrmzIPNetwork.supernet�s����I�3����!3�!3�3��A��d�l�l�2�2�3�4�5�
5��	��9�9��'����!�!�T�_�_�4����X�]�]�+����1�$���!�!�T�_�_�4��rc#�K�d|jcxkr|jjks&ntd||jjfz��|j|ksy|jj}d||jz
zd||z
zz}|�|}d|cxkr|kstd��td��|jj|j�}d}||krd|jd||fz|jj�}|xj|j|zz
c_||_|dz
}|��||kr�cyy�w)a�
        A generator that divides up this IPNetwork's subnet into smaller
        subnets based on a specified CIDR prefix.

        :param prefixlen: a CIDR prefix indicating size of subnets to be
            returned.

        :param count: (optional) number of consecutive IP subnets to be
            returned.

        :return: an iterator containing IPNetwork subnet objects.
        rrjNr r�z,count outside of current IP subnet boundary!r^)
r+rr�r�rZr�rr�r(r)	rr+�count�fmtr��max_subnets�base_subnet�i�subnets	         rrtzIPNetwork.subnet�sB�����D�N�N�8�d�l�l�&8�&8�8��A��d�l�l�2�2�3�4�5�
5��~�~��*�����"�"���E�D�N�N�2�3�q�U�Y�=N�7O�O���=��E��E�(�[�(��K�L�L�)��K�L�L��l�l�-�-�d�j�j�9��
���%�i��^�^�G�{�I�.F�$F����$�$�&�F��L�L�V�[�[�1�_�-�L�(�F��
��F�A��L�
�%�i�s�EE
�E
c���tg�}|jjdk(r�|jdk\rdt	t|jdz|jj�t|jdz
|jj��}|St	t|j|jj�t|j|jj��}|S|jdk\r_t	t|jdz|jj�t|j|jj��}|S)a]
        A generator that provides all the IP addresses that can be assigned
        to hosts within the range of this IP object's subnet.

        - for IPv4, the network and broadcast addresses are always excluded.           for subnets that contains less than 4 IP addresses /31 and /32           report in a manner per RFC 3021

        - for IPv6, only the unspecified address '::' or Subnet-Router anycast           address (first address in the network) is excluded.

        .. warning::

            The next release (0.9.0) will contain a backwards incompatible change
            connected to handling of RFC 6164 IPv6 addresses (/127 and /128 subnets).
            When iterating ``IPNetwork`` and ``IPNetwork.iter_hosts()`` the first
            addresses in the networks will no longer be excluded.

        :return: an IPAddress iterator
        rXr�r )rrrZrr
rrr	)r�it_hostss  r�
iter_hostszIPNetwork.iter_hosts&s��*��8���<�<���1�$��y�y�A�~�'�!�$�*�*�q�.�$�,�,�2F�2F�G�!�$�)�)�a�-����1E�1E�F�H�� ��(�!�$�*�*�d�l�l�.B�.B�C�!�$�)�)�T�\�\�-A�-A�B�D����	�y�y�A�~�'��d�j�j�1�n�d�l�l�.B�.B�C��d�i�i����)=�)=�>�@���rc�n�|jj|j�}|�d|j��S)z&:return: this IPNetwork in CIDR formatr�)rr�rr+)rr�s  rr�zIPNetwork.__str__Rs)���|�|�&�&�t�{�{�3������/�/rc�:�|jj�d|�d�Sr�r�rs rr�zIPNetwork.__repr__Wr�r)FNrr�r��r)NN)%rwrxryrzr{rr�r�r:r|r+r�r?rBrr	r0�setterr>rFrArcr�r�rr4r6r
rrerhrmrtrwr�r�rrs@rr3r3Isn���.�^ �I�B�HB��. ��5�~�Q�S�I��<��<��P��P��U��U��I��I��&��&��8��8�

�^�^�
+��
+��9��9��9��9�
�A��A��.��.��*�*(�<;�E��.�@
�
��.'�R*�X0�
<rr3c�l�eZdZdZdZdd�Zd�Zd�Zd�Ze	d��Z
e	d��Zd	�Zd
�Z
d�Zd�Zd
�Zy)rQz�
    An arbitrary IPv4 or IPv6 address range.

    Formed from a lower and upper bound IP address. The upper bound IP cannot
    be numerically smaller than the lower bound and the IP version of both
    must match.

    �rRrSc��t||��|_|jj|_t||jj|��|_t|j�t|j�kDrt
d��y)a�
        Constructor.

        :param start: an IPv4 or IPv6 address that forms the lower
            boundary of this IP range.

        :param end: an IPv4 or IPv6 address that forms the upper
            boundary of this IP range.

        :param flags: (optional) decides which rules are applied to the
            interpretation of the start and end values. Supported constants
            are INET_PTON and ZEROFILL. See the netaddr.core docs for further
            details.

        r!z(lower bound IP greater than upper bound!N)rrRrrZrSr�r)rr�endr�s    rrzIPRange.__init__gsg��  ��U�3����{�{�*�*����c�4�<�<�#7�#7�u�E��	��t�{�{��c�$�)�)�n�,�!�"L�M�M�-rc��|jj|jj|jjfS)z.:return: Pickled state of an `IPRange` object.)rRr(rSrrZrs rr�zIPRange.__getstate__}s+���{�{� � �$�)�)�/�/�4�<�<�3G�3G�G�Grc��|\}}}t||�|_|jj|_t||�|_y)zQ
        :param state: data used to unpickle a pickled `IPRange` object.
        N)rrRrrS)rr�rr�rZs     rr�zIPRange.__setstate__�s=��$���s�G���w�/����{�{�*�*����c�7�+��	rc�$�t|t��rs|jj|jjk7ryt|t�rH|j
j|jkxr#|jj|jk\St|t�r\|j
j|j
jkxr-|jj|jjk\St|t�rq|jj|jz
}|j|z	|z}|d|zz}|j
j|kxr|jj|kDSt	|�|vS)NFr�)r"rrrZrrRrrSrQr3r�r5)rr>rT�other_start�other_next_starts     rrzIPRange.__contains__�s>���e�V�$��|�|�#�#�u�}�}�'<�'<�<���%��+����*�*�e�l�l�:�9��	�	�(�(�E�L�L�8�:��%��)����*�*�e�l�l�.A�.A�A�>��	�	�(�(�E�J�J�,=�,=�=�?��%��+�"�]�]�0�0�5�3C�3C�C�
�$�|�|�z�9�j�H��#.�!�z�/�#B� ����*�*�k�9�<��	�	�(�(�+;�;�=����4�'�'rc�,�t|j�S)z?The integer value of first IP address in this `IPRange` object.)r�rRrs rrz
IPRange.first�s���4�;�;��rc�,�t|j�S)z>The integer value of last IP address in this `IPRange` object.)r�rSrs rr	zIPRange.last�s���4�9�9�~�rc�\�|jj|j|jfS)zP
        :return: A key tuple used to uniquely identify this `IPRange`.
        rXrs rr4zIPRange.key�rYrc��|jjt|j�z
}|jj|j
j|fS)zY
        :return: A key tuple used to compare and sort this `IPRange` correctly.
        )rr�rrrZrRr)r�skeys  rr6zIPRange.sort_key�sB���|�|�!�!�H�T�Y�Y�$7�7���|�|�#�#�T�[�[�%7�%7��=�=rc�B�t|j|j�S)zx
        The list of CIDR addresses found within the lower and upper bound
        addresses of this `IPRange`.
        )�iprange_to_cidrsrRrSrs r�cidrsz
IPRange.cidrs�s��
 ����T�Y�Y�7�7rc�8�|j�d|j��S)z<:return: this `IPRange` in a common representational format.�-r~rs rr�zIPRange.__str__�s���+�+�t�y�y�1�1rc�h�|jj�d|j�d|j�d�S)r�r�z', 'r�)r�rwrRrSrs rr�zIPRange.__repr__�s&��#'�>�>�#:�#:��K�K����$�	$rNr{)rwrxryrzr{rr�r�rr|rr	r4r6r�r�r�r}rrrQrQ\se���#�I�N�,H�,�(�,� �� �����;�>�8�2�$rrQc'�BK�t|�D]
}|D]}|����y�w)z�
    :param args: A list of IP addresses and subnets passed in as arguments.

    :return: A generator that flattens out IP subnets, yielding unique
        individual IP addresses (no duplicates).
    N)�
cidr_merge)�argsrcr�s   r�iter_unique_ipsr��s0�����4� ����	�B��H�	��s�c�f�d�}t|�rd|vs|dk(r|S	t|�}|�d||���S#t$r�d|vrO|jdd�\}}	dt|�cxkrdksntd	|�d
���n#t$r|cYcYSwxYw|}d}|jd�}t	|�d
kDr|cYStd
t	|�z
�D]}|j
d��|� 	||d�}n#t$r|cYcYSwxYwdj|��d|��cYSttf$r|cYSwxYw)a�
    A function that converts abbreviated IPv4 CIDRs to their more verbose
    equivalent.

    :param abbrev_cidr: an abbreviated CIDR.

    Uses the old-style classful IP address rules to decide on a default
    subnet prefix if one is not explicitly provided.

    Only supports IPv4 addresses.

    Examples ::

        10                  - 10.0.0.0/8
        10/16               - 10.0.0.0/16
        128                 - 128.0.0.0/16
        128/8               - 128.0.0.0/8
        192.168             - 192.168.0.0/16

    :return: A verbose CIDR from an abbreviated CIDR or old-style classful         network address. The original value if it was not recognised as a         supported abbreviation.
    c��t|�}d|cxkrdksntd|z��d|cxkrdkryd|cxkrdkryd	|cxkrd
kryd|cxkrd
kryyy)Nr�zInvalid octet: %r!�r������������rXrm)r�r�)�octets r�classful_prefixz/cidr_abbrev_to_verbose.<locals>.classful_prefix�s����E�
���E� �S� ��1�E�9�:�:��������
�E�
 �S�
 ��!�
�E�
 �S�
 ��!�
�E�
 �S�
 ��!�r�:�z.0.0.0/r�r�rrmzprefixlen in address z out of range for IPv4!N�.rXr�)
rr�r�r%r#�rangerk�joinr#r�)�abbrev_cidrr�rs�	part_addr�prefix�tokenss      rr$r$�se��4��{���+����!2���$����� !�?�1�#5�6�6���4��+�� +� 1� 1�#�q� 9��I�v�
#��C��K�-�2�-�$�(3�&6�7�7�.���
#�"�"�
#��$�I��F�����%���v�;��?����q�3�v�;��'�	�A��M�M�#��	��>�
#�(����3����
#�"�"�
#���(�(�6�*�F�3�3��z�"�����sc�3�"D0�%A<�;D0�<B�D0�B�(D0�6/D0�&C2�1D0�2D�=D0�D�D0�D0�/D0c�H�t|d�std��g}|D]Y}t|ttf�r|}nt|�}|j|j|j|j|f��[|j�t|�dz
}|dkDri||d||dz
dk(rJ||ddz
||dz
dkr3||d||dt||dz
d||d�f||dz
<||=|dz}|dkDr�ig}|D]�}t|�dk(rG|d}t|t�r |j|j���F|j|��X|d}t|d|��}	t|d|��}
|jt|	|
����|S)	a�
    A function that accepts an iterable sequence of IP addresses and subnets
    merging them into the smallest possible list of CIDRs. It merges adjacent
    subnets where possible, those contained within others and also removes
    any duplicates.

    :param ip_addrs: an iterable sequence of IP addresses, subnets or ranges.

    :return: a summarized list of `IPNetwork` objects.
    r
z#A sequence or iterator is expected!r�rr rX�rM)r�r�r"r3rQrkrZr	r�sortr#�min�extendr�rr�)�ip_addrs�rangesr��netrs�merged�range_tuple�originalrZ�range_start�
range_stops           rr�r�)s����8�Z�(��>�?�?�
�F��A���b�9�g�.�/��C��B�-�C��
�
����S�X�X�s�y�y�#�>�@�
A��K�K�M��F��a��A�
�a�%��!�9�Q�<�6�!�a�%�=��+�+��q�	�!��q�0@�F�1�q�5�M�RS�DT�0T�#�A�Y�q�\�6�!�9�Q�<��V�A��E�]�1�=M�v�VW�y�YZ�|�9\�]�F�1�q�5�M��q�	�	�Q���	�a�%�
�F��E���{��q� �"�1�~�H��(�G�,��
�
�h�n�n�.�/��
�
�h�'�!�!�n�G�#�K��N�G�D�K�"�;�q�>�7�C�J��M�M�*�;�
�C�D�E��Mrc�,�t||�\}}}||zS)a
    Removes an exclude IP address or subnet from target IP subnet.

    :param target: the target IP address or subnet to be divided up.

    :param exclude: the IP address or subnet to be removed from target.

    :return: list of `IPNetwork` objects remaining after exclusion.
    )�cidr_partition)�target�exclude�left�_�rights     r�cidr_excluder�\s ��$�F�G�4�N�D�!�U��%�<�rc���t|�}t|�}|j|jkrgg|jgfS|j|jkr|jgggfS|j|jk\rg|ggfSg}g}|jdz}|j
j}|j}|j}|}|d||z
zz}	|j|k\rx|j|	k\r!|jt||f|���|	}
n |jt|	|f|���|}
|dz
}||kDrn|
}|
d||z
zz}	|j|k\r�x||g|ddd�fS)ac
    Partitions a target IP subnet on an exclude IP address.

    :param target: the target IP address or subnet to be divided up.

    :param exclude: the IP address or subnet to partition on

    :return: list of `IPNetwork` objects before, the partition and after, sorted.

    Adding the three lists returns the equivalent of the original subnet.
    r�r rMN���)	r3r	rrcr+rr�rZrk)r�r�r�r��
new_prefixlen�target_module_width�target_firstrZ�i_lower�i_upper�matcheds           rr�r�js����v�
�F��� �G��|�|�f�l�l�"��2����}�$�$�	���w�}�}�	$����}�b�"�$�$�
���7�,�,�,��F�8�R���
�D��E��$�$�q�(�M� �.�.�.�.���<�<�L��o�o�G��G��a�$7�-�$G�H�I�G�
�
�
�}�
,��=�=�G�#��K�K�	�7�M�":�G�L�M��G��L�L��G�]�#;�W�M�N��G����
��.�.�����Q�#6��#F�G�H���
�
�}�
,� �'��E�$�B�$�K�'�'rc�2�t|�}	tt|��}tt|��}||kr|}|}n|}|}|D]}t|�}||kr|}||kDs�|}�|j
|j
k7rt
d��|j}|j}	|j}
|jj}|	dkDr!||
kDr|	dz}	|d||	z
zz}|	dkDr||
kDr�t||	f|j
��S#t$rt	d��wxYw)aO
    Function that accepts a sequence of IP addresses and subnets returning
    a single `IPNetwork` subnet that is large enough to span the lower and
    upper bound IP addresses with a possible overlap on either end.

    :param ip_addrs: sequence of IP addresses and subnets.

    :return: a single spanning `IPNetwork` subnet.
    z-IP sequence must contain at least 2 elements!z.IP sequence cannot contain both IPv4 and IPv6!rr�rM)rr3r�
StopIterationr�rZr#r	r+rrr�)r��
ip_addrs_iter�	network_a�	network_b�min_network�max_networkr�r?�ipnumr+�lowest_ipnumr�s            r�
spanning_cidrr��sK����N�M�J��j��7�8�	��j��7�8�	��9�����������"���B�-���[� �!�K��[� �!�K�"����k�1�1�1��H�I�I����E��%�%�I��$�$�L����%�%�E�
�a�-�E�L�0��Q��	�
�1�u�Y��'�(�(���a�-�E�L�0��u�i�(�+�2E�2E�G�G��;�J��H�I�I�J�s�(D�Dc#�ZK�t|�}t|�}|j|jk7rtd��|j}t|�}|dk(rt	d��t|�}t|�}d}|dkrd}||z
}	||z
}|r||k\sy||ksyt||����"�w)a�
    A generator that produces IPAddress objects between an arbitrary start
    and stop IP address with intervals of step between them. Sequences
    produce are inclusive of boundary IPs.

    :param start: start IP address.

    :param end: end IP address.

    :param step: (optional) size of step between IP addresses. Default: 1

    :return: an iterator of one or more `IPAddress` objects.
    z(start and stop IP versions do not match!rzstep argument cannot be zeroFTN)rrZr#r�r�)rr�rrZr�
negative_steprs       rr
r
�s�����
�e��E�
�C�.�C��}�}����#��B�C�C��m�m�G��t�9�D��q�y��7�8�8�
��J�E��s�8�D��M��a�x��
��D�L�E�
�
��
����D�=���D�=����w�'�'��s�B)B+c��g}t|�}t|�}|j|jg}t||g�}|jj
}|j|dkr>t|ddz
|f|j��}t||�d}|j�}|j|dkDr3t|ddz|f|j��}|t||�dz
}|S|j|�|S)a`
    A function that accepts an arbitrary start and end IP address or subnet
    and returns a list of CIDR subnets that fit exactly between the boundaries
    of the two with no overlap.

    :param start: the start IP address or subnet.

    :param end: the end IP address or subnet.

    :return: a list of one or more IP addresses and subnets.
    rr�rMr )
r3rr	r�rr�rZr��poprk)rr��	cidr_list�iprange�	cidr_spanr�r�s       rr�r�s����I��e��E�
�C�.�C��{�{�C�H�H�%�G��u�c�l�+�I��M�M���E�������#��W�Q�Z��\�5�1�5�=�=�I��"�9�g�6�q�9�	��M�M�O�	��~�~���
�"��W�Q�Z��\�5�1�5�=�=�I���^�I�w�7��:�:�	���	����#��rc���d}t|d�std|�d���t|�}t|D�cgc]
}t	|���c}�D]}||vr|}�
|��
|j
|vs�|S|Scc}w)ab
    Matches an IP address or subnet against a given sequence of IP addresses
    and subnets.

    :param ip: a single IP address or subnet.

    :param cidrs: a sequence of IP addresses and/or subnets.

    :return: the smallest (most specific) matching IPAddress or IPNetwork
        object from the provided sequence, None if there was no match.
    Nr
�)IP address/subnet sequence expected, not �!)r�r#r�sortedr3r?�r�r��matchrcs    r�smallest_matching_cidrr�'s���
�E��5�*�%�����	�
�2��B��E�:�D�	�$��:�;���
��:��E�� �T�\�\��%>���L���L��;s�A-c��d}t|d�std|�d���t|�}t|D�cgc]
}t	|���c}�D]}||vs�|}|S|Scc}w)ab
    Matches an IP address or subnet against a given sequence of IP addresses
    and subnets.

    :param ip: a single IP address or subnet.

    :param cidrs: a sequence of IP addresses and/or subnets.

    :return: the largest (least specific) matching IPAddress or IPNetwork
        object from the provided sequence, None if there was no match.
    Nr
r�r�)r�r#rr�r3r�s    r�largest_matching_cidrr�Dsv��
�E��5�*�%�����	�
�2��B��E�:�D�	�$��:�;���
��:��E���L��
�L��;s�Ac��g}t|d�std|�d���t|�}t|D�cgc]
}t	|���c}�D]/}||vr|j|��|s�|j|dvs�.|S|Scc}w)aM
    Matches an IP address or subnet against a given sequence of IP addresses
    and subnets.

    :param ip: a single IP address.

    :param cidrs: a sequence of IP addresses and/or subnets.

    :return: all matching IPAddress and/or IPNetwork objects from the provided
        sequence, an empty list if there was no match.
    r
r�r�r�)r�r#rr�r3rkr?)r�r��matchesrcs    r�all_matching_cidrsr�_s����G��5�*�%�����	�
�2��B��E�:�D�	�$��:�;���
��:��N�N�4� ��4�<�<�w�r�{�:���N���N��;s�A?z127.0.0.0/8z
10.0.0.0/8z
100.64.0.0/10z
172.16.0.0/12z192.0.0.0/24z192.168.0.0/16z
198.18.0.0/15z	239.0.0.0z239.255.255.255z169.254.0.0/16z224.0.0.0/4z192.88.99.0/24z	0.0.0.0/8z192.0.2.0/24z240.0.0.0/4z198.51.100.0/24z203.0.113.0/24z233.252.0.0/24z	234.0.0.0z238.255.255.255z	225.0.0.0z231.255.255.255z::1zfc00::/7z	fec0::/10z	fe80::/10zff00::/8z	ff00::/12z::/8z0100::/8z0200::/7z0400::/6z0800::/5z1000::/4z4000::/3z6000::/3z8000::/3zA000::/3zC000::/3zE000::/4zF000::/5zF800::/6zFE00::/9)Frrz)7rz�sys�_sys�netaddr.corerrrrrrr	r
rr�netaddr.strategyr
rSrrU�netaddr.compatrrrrrr�objectrrrr1r3rQr�r$r�r�r�r�r
r�r�r�r�r[r_rfrT�	IPV4_6TO4rir\r`rgrVrjr}rr�<module>r�sS��@��8�8�8�:���Q$�V�Q$�hv<��v<�r
b�&�b�JA�HP<���P<�fj$�f�k�j$�Z	�P�h0�f�9(�x+H�\+(�^!�H�:�6�>�=�)�
��l��
�o��
�o��
�n��
���
�o���K�*�+����,�-���=�)���&�'�	��k��
�n��
�m��
�� �
�������K�*�+��K�*�+���I���
� �%� �
��j��
�k����
�K�(���:�&���k��I�f�-�
�j��9�Z�0�
�j��9�Z�0�
�j��9�Z�0�
�j��9�Z�0�
�j��9�Z�0�
�j��9�Z�0�
�j��9�Z�0�	�
r

Zerion Mini Shell 1.0