%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/__pycache__/ipaddress.cpython-312.pyc

�

���f�1��H�dZdZddlZdZdZGd�de�ZGd�d	e�Zd
�Zd2d�Z	d�Z
d
�Zd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�ZGd�d�Zdaej,Gd�de��Zej,Gd�de��ZGd�d�Zee_Gd�d�ZGd �d!ee�ZGd"�d#e�ZGd$�d%ee�ZGd&�d'�Zee_ee_Gd(�d)�Z Gd*�d+e e�Z!Gd,�d-e!�Z"Gd.�d/e e�Z#Gd0�d1�Z$e$e!_e$e#_y)3z�A fast, lightweight IPv4/IPv6 manipulation library in Python.

This library is used to create/poke/manipulate IPv4 and IPv6 addresses
and networks.

z1.0�N� �c��eZdZdZy)�AddressValueErrorz%A Value Error related to the address.N��__name__�
__module__�__qualname__�__doc__��� /usr/lib/python3.12/ipaddress.pyrr���/r
rc��eZdZdZy)�NetmaskValueErrorz%A Value Error related to the netmask.Nrrr
rrrrr
rc��	t|�S#ttf$rYnwxYw	t|�S#ttf$rYnwxYwt	|�d���)a�Take an IP string/int and return an object of the correct type.

    Args:
        address: A string or integer, the IP address.  Either IPv4 or
          IPv6 addresses may be supplied; integers less than 2**32 will
          be considered to be IPv4 by default.

    Returns:
        An IPv4Address or IPv6Address object.

    Raises:
        ValueError: if the *address* passed isn't either a v4 or a v6
          address

    z. does not appear to be an IPv4 or IPv6 address)�IPv4Addressrr�IPv6Address�
ValueError��addresss r�
ip_addressrsg�� 
��7�#�#���0�1�
��
��
��7�#�#���0�1�
��
����{�"P�Q�
R�R��

���
.�A�Ac��	t||�S#ttf$rYnwxYw	t||�S#ttf$rYnwxYwt	|�d���)a�Take an IP string/int and return an object of the correct type.

    Args:
        address: A string or integer, the IP network.  Either IPv4 or
          IPv6 networks may be supplied; integers less than 2**32 will
          be considered to be IPv4 by default.

    Returns:
        An IPv4Network or IPv6Network object.

    Raises:
        ValueError: if the string passed isn't either a v4 or a v6
          address. Or if the network has host bits set.

    z. does not appear to be an IPv4 or IPv6 network)�IPv4Networkrr�IPv6Networkr)r�stricts  r�
ip_networkr9sk�� 
��7�F�+�+���0�1�
��
��
��7�F�+�+���0�1�
��
����{�"P�Q�
R�Rs�� � �0�A�Ac��	t|�S#ttf$rYnwxYw	t|�S#ttf$rYnwxYwt	|�d���)agTake an IP string/int and return an object of the correct type.

    Args:
        address: A string or integer, the IP address.  Either IPv4 or
          IPv6 addresses may be supplied; integers less than 2**32 will
          be considered to be IPv4 by default.

    Returns:
        An IPv4Interface or IPv6Interface object.

    Raises:
        ValueError: if the string passed isn't either a v4 or a v6
          address.

    Notes:
        The IPv?Interface classes describe an Address on a particular
        Network, so they're basically a combination of both the Address
        and Network classes.

    z0 does not appear to be an IPv4 or IPv6 interface)�
IPv4Interfacerr�
IPv6Interfacerrs r�ip_interfacer"Vsg��*
��W�%�%���0�1�
��
��
��W�%�%���0�1�
��
����{�"R�S�
T�Trc�V�	|jd�S#t$rtd��wxYw)a`Represent an address as 4 packed bytes in network (big-endian) order.

    Args:
        address: An integer representation of an IPv4 IP address.

    Returns:
        The integer address packed as 4 bytes in network (big-endian) order.

    Raises:
        ValueError: If the integer is negative or too large to be an
          IPv4 IP address.

    �z&Address negative or too large for IPv4��to_bytes�
OverflowErrorrrs r�v4_int_to_packedr(xs6��C�����"�"���C��A�B�B�C����(c�V�	|jd�S#t$rtd��wxYw)z�Represent an address as 16 packed bytes in network (big-endian) order.

    Args:
        address: An integer representation of an IPv6 IP address.

    Returns:
        The integer address packed as 16 bytes in network (big-endian) order.

    �z&Address negative or too large for IPv6r%rs r�v6_int_to_packedr,�s6��C�����#�#���C��A�B�B�C�r)c�r�t|�jd�}t|�dkDrtd|����|S)zAHelper to split the netmask and raise AddressValueError if needed�/�zOnly one '/' permitted in )�str�split�lenr)r�addrs  r�_split_optional_netmaskr4�s9���w�<���c�"�D�
�4�y�1�}��"<�W�K� H�I�I��Kr
c#�K�t|�}t|�x}}|D](}|j|jdzk7r||f��|}|}�*||f��y�w)z�Find a sequence of sorted deduplicated IPv#Address.

    Args:
        addresses: a list of IPv#Address objects.

    Yields:
        A tuple containing the first and last IP addresses in the sequence.

    �N)�iter�next�_ip)�	addresses�it�first�last�ips     r�_find_address_ranger?�sb����
�i��B���8��E�D����
�6�6�T�X�X��\�!���+���E���	�
��+��s�A
Ac�R�|dk(r|St|||dz
zj��S)z�Count the number of zero bits on the right hand side.

    Args:
        number: an integer.
        bits: maximum number of bits to count.

    Returns:
        The number of zero bits on the right hand side of the number.

    rr6)�min�
bit_length)�number�bitss  r�_count_righthand_zero_bitsrE�s1����{����t�v�g����*�6�6�8�9�9r
c#�VK�t|t�rt|t�std��|j|jk7rt|�d|�d���||kDrt	d��|jdk(rt
}n!|jdk(rt}nt	d��|j}|j}|j}||kr`tt||�||z
dzj�dz
�}||||z
f�}|��|d|zz
}|dz
|jk(ry	||kr�_y	y	�w)
a�Summarize a network range given the first and last IP addresses.

    Example:
        >>> list(summarize_address_range(IPv4Address('192.0.2.0'),
        ...                              IPv4Address('192.0.2.130')))
        ...                                #doctest: +NORMALIZE_WHITESPACE
        [IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/31'),
         IPv4Network('192.0.2.130/32')]

    Args:
        first: the first IPv4Address or IPv6Address in the range.
        last: the last IPv4Address or IPv6Address in the range.

    Returns:
        An iterator of the summarized IPv(4|6) network objects.

    Raise:
        TypeError:
            If the first and last objects are not IP addresses.
            If the first and last objects are not the same version.
        ValueError:
            If the last object is not greater than the first.
            If the version of the first address is not 4 or 6.

    z1first and last must be IP addresses, not networks� and � are not of the same versionz*last IP address must be greater than firstr$�zunknown IP versionr6N)
�
isinstance�_BaseAddress�	TypeError�versionrrr�_max_prefixlenr9rArErB�	_ALL_ONES)r<r=r>�ip_bits�	first_int�last_int�nbits�nets        r�summarize_address_rangerU�s(����4��|�
,�
��l�
+��K�L�L��}�}����$����&�'�	'��t�|��E�F�F��}�}���
��	���!�	�
���-�.�.��"�"�G��	�	�I��x�x�H�
�x�
��.�y�'�B��	�)�A�-�9�9�;�a�?�A���)�W�u�_�-�.���	��Q�%�Z��	��q�=�B�L�L�(���x�
�s�D$D)�'D)c#�XK�t|�}i}|rU|j�}|j�}|j|�}|�|||<n||k7r||=|j	|�|r�Ud}t|j
��D]$}|�|j|jk\r�|��|}�&y�w)auLoops through the addresses, collapsing concurrent netblocks.

    Example:

        ip1 = IPv4Network('192.0.2.0/26')
        ip2 = IPv4Network('192.0.2.64/26')
        ip3 = IPv4Network('192.0.2.128/26')
        ip4 = IPv4Network('192.0.2.192/26')

        _collapse_addresses_internal([ip1, ip2, ip3, ip4]) ->
          [IPv4Network('192.0.2.0/24')]

        This shouldn't be called directly; it is called via
          collapse_addresses([]).

    Args:
        addresses: A list of IPv4Network's or IPv6Network's

    Returns:
        A list of IPv4Network's or IPv6Network's depending on what we were
        passed.

    N)�list�pop�supernet�get�append�sorted�values�broadcast_address)r:�to_merge�subnetsrTrY�existingr=s       r�_collapse_addresses_internalrb�s�����2�I��H��G�
��l�l�n���<�<�>���;�;�x�(���� #�G�H��
��_���!��O�O�H�%���D��g�n�n�&�'������%�%��)>�)>�>���	����s
�A$B*�'AB*c��g}g}g}|D�]}t|t�rD|r0|dj|jk7rt|�d|d�d���|j	|��X|j
|jk(rO|r0|dj|jk7rt|�d|d�d���	|j	|j���|r0|dj|jk7rt|�d|d�d���|j	|���tt|��}|r.t|�D] \}}|jt||���"t||z�S#t$r|j	|j�Y��wxYw)a�Collapse a list of IP objects.

    Example:
        collapse_addresses([IPv4Network('192.0.2.0/25'),
                            IPv4Network('192.0.2.128/25')]) ->
                           [IPv4Network('192.0.2.0/24')]

    Args:
        addresses: An iterator of IPv4Network or IPv6Network objects.

    Returns:
        An iterator of the collapsed IPv(4|6)Network objects.

    Raises:
        TypeError: If passed a list of mixed version objects.

    ���rGrH)rJrK�_versionrLr[�
_prefixlenrNr>�AttributeError�network_addressr\�setr?�extendrUrb)r:�addrs�ips�netsr>r<r=s       r�collapse_addressesrn0s{��$
�E�
�C�
�D�����b�,�'��s�2�w�'�'�2�;�;�6��!#�S��W�!.�/�/��J�J�r�N�
�]�]�b�/�/�
/��s�2�w�'�'�2�;�;�6��!#�S��W�!.�/�/�
/��
�
�2�5�5�!���R��)�)�R�[�[�8��!#�T�"�X�!/�0�0��K�K��O�%�*��S��
�C��.�s�3�	?�K�E�4��L�L�0���=�>�	?�(����5�5��!"�
/��
�
�2�-�-�.�
/�s�-E!�!$F	�F	c��t|t�r|j�St|t�r|j	�St
S)a2Return a key suitable for sorting between networks and addresses.

    Address and Network objects are not sortable by default; they're
    fundamentally different so the expression

        IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')

    doesn't make any sense.  There are some times however, where you may wish
    to have ipaddress sort these for you anyway. If you need to do this, you
    can use this function as the key= argument to sorted().

    Args:
      obj: either a Network or Address object.
    Returns:
      appropriate key.

    )rJ�_BaseNetwork�_get_networks_keyrK�_get_address_key�NotImplemented)�objs r�get_mixed_type_keyrufs<��$�#�|�$��$�$�&�&�	�C��	&��#�#�%�%��r
c���eZdZdZdZed��Zed��Zed��Zed��Z	d�Z
d�Zed	��Z
ed
��Zed��Zed��Zed
��Zed��Zd�Zy)�_IPAddressBasezThe mother class.rc�"�|j�S)z:Return the longhand version of the IP address as a string.)�_explode_shorthand_ip_string��selfs r�explodedz_IPAddressBase.exploded�s���0�0�2�2r
c��t|�S)z;Return the shorthand version of the IP address as a string.�r0rzs r�
compressedz_IPAddressBase.compressed�s���4�y�r
c�"�|j�S)aIThe name of the reverse DNS pointer for the IP address, e.g.:
            >>> ipaddress.ip_address("127.0.0.1").reverse_pointer
            '1.0.0.127.in-addr.arpa'
            >>> ipaddress.ip_address("2001:db8::1").reverse_pointer
            '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'

        )�_reverse_pointerrzs r�reverse_pointerz_IPAddressBase.reverse_pointer�s���$�$�&�&r
c�6�dt|�fz}t|��)Nz%200s has no version specified��type�NotImplementedError�r{�msgs  rrMz_IPAddressBase.version�s��.�$�t�*��>��!�#�&�&r
c��|dkrd}t|||jfz��||jkDr'd}t|||j|jfz��y)Nrz-%d (< 0) is not permitted as an IPv%d addressz2%d (>= 2**%d) is not permitted as an IPv%d address)rrerOrN)r{rr�s   r�_check_int_addressz!_IPAddressBase._check_int_address�sg���Q�;�A�C�#�C�7�D�M�M�*B�$B�C�C��T�^�^�#�F�C�#�C�7�D�4G�4G�+/�=�=�+:�%:�;�
;�$r
c�`�t|�}||k7rd}t|||||jfz��y)Nz6%r (len %d != %d) is not permitted as an IPv%d address)r2rre)r{r�expected_len�address_lenr�s     r�_check_packed_addressz$_IPAddressBase._check_packed_address�sG���'�l���,�&�J�C�#�C�7�K�+7����+H�%H�I�
I�'r
c�:�|j|j|z	zS)z�Turn the prefix length into a bitwise netmask

        Args:
            prefixlen: An integer, the prefix length.

        Returns:
            An integer.

        )rO)�cls�	prefixlens  r�_ip_int_from_prefixz"_IPAddressBase._ip_int_from_prefix�s���}�}��
�
�� :�;�;r
c���t||j�}|j|z
}||z	}d|zdz
}||k7r1|jdz}|j|d�}d}t||z��|S)aReturn prefix length from the bitwise netmask.

        Args:
            ip_int: An integer, the netmask in expanded bitwise format

        Returns:
            An integer, the prefix length.

        Raises:
            ValueError: If the input intermingles zeroes & ones
        r6��bigz&Netmask pattern %r mixes zeroes & ones)rErNr&r)	r��ip_int�trailing_zeroesr��leading_ones�all_ones�byteslen�detailsr�s	         r�_prefix_from_ip_intz"_IPAddressBase._prefix_from_ip_int�s���5�V�58�5G�5G�I���&�&��8�	���0����N�a�'���8�#��)�)�Q�.�H��o�o�h��6�G�:�C��S�7�]�+�+��r
c�$�d|z}t|�d�)Nz%r is not a valid netmask)r)r��netmask_strr�s   r�_report_invalid_netmaskz&_IPAddressBase._report_invalid_netmask�s��)�K�7����$�$�.r
c��|j�r|j�s|j|�	t|�}dcxkr|j
ksn|j|�|S#t$r|j|�Y�FwxYw)a	Return prefix length from a numeric string

        Args:
            prefixlen_str: The string to be converted

        Returns:
            An integer, the prefix length.

        Raises:
            NetmaskValueError: If the input is not a valid netmask
        r)�isascii�isdigitr��intrrN)r��
prefixlen_strr�s   r�_prefix_from_prefix_stringz)_IPAddressBase._prefix_from_prefix_string�s����%�%�'�M�,A�,A�,C��'�'�
�6�	7��M�*�I��Y�4�#�"4�"4�4��'�'�
�6����	�	7��'�'�
�6�	7�s�A(�(B�Bc�*�	|j|�}	|j�S#t$r|j|�Y�.wxYw#t$rYnwxYw|j
z}	|j|�S#t$r|j|�YywxYw)aTurn a netmask/hostmask string into a prefix length

        Args:
            ip_str: The netmask/hostmask to be converted

        Returns:
            An integer, the prefix length.

        Raises:
            NetmaskValueError: If the input is not a valid netmask/hostmask
        N)�_ip_int_from_stringrr�r�rrO)r��ip_strr�s   r�_prefix_from_ip_stringz%_IPAddressBase._prefix_from_ip_string�s���	0��,�,�V�4�F�	��*�*�6�2�2��!�	0��'�'��/�	0���	��	��	�#�-�-���	0��*�*�6�2�2���	0��'�'��/�	0�s2�%�A�A�A�	A�A�$A5�5B�Bc���t|ttf�r||jfSt|t�st|�}t
|�dkDr|S|d|jfS)z�Helper function to parse address of Network/Interface.

        Arg:
            address: Argument of Network/Interface.

        Returns:
            (addr, prefix) tuple.
        r6r)rJ�bytesr�rN�tupler4r2)r�rs  r�_split_addr_prefixz!_IPAddressBase._split_addr_prefixsa���g��s�|�,��C�.�.�.�.��'�5�)�.�g�6�G��w�<�!���N��q�z�3�-�-�-�-r
c�2�|jt|�ffS�N��	__class__r0rzs r�
__reduce__z_IPAddressBase.__reduce__-s���~�~��D�	�|�+�+r
N)rr	r
r�	__slots__�propertyr|rr�rMr�r��classmethodr�r�r�r�r�r�r�rr
rrwrws�����I�
�3��3������'��'��'��'�;�I��
<��
<�����0�/��/�����0�0��0�B�.��.�.,r
rwc�b��eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Z�fd
�Z�xZS)rKz�A generic IP object.

    This IP class contains the version independent methods which are
    used by single IP addresses.
    rc��|jSr��r9rzs r�__int__z_BaseAddress.__int__>s���x�x�r
c��	|j|jk(xr|j|jk(S#t$r	tcYSwxYwr�)r9rergrs�r{�others  r�__eq__z_BaseAddress.__eq__AsF��	"��H�H��	�	�)�8��
�
����7�
9���	"�!�!�	"�s�36�A�Ac���t|t�stS|j|jk7rt	|�d|�d���|j
|j
k7r|j
|j
kSy�NrGrHF)rJrKrsrerLr9r�s  r�__lt__z_BaseAddress.__lt__Hs_���%��.�!�!��=�=�E�N�N�*��!�5�*�+�
+��8�8�u�y�y� ��8�8�e�i�i�'�'�r
c�h�t|t�stS|jt|�|z�Sr��rJr�rsr�r�s  r�__add__z_BaseAddress.__add__T�*���%��%�!�!��~�~�c�$�i�%�/�0�0r
c�h�t|t�stS|jt|�|z
�Sr�r�r�s  r�__sub__z_BaseAddress.__sub__Yr�r
c�L�|jj�dt|��d�S�N�(�)�r�rr0rzs r�__repr__z_BaseAddress.__repr__^����>�>�2�2�C��I�>�>r
c�J�t|j|j��Sr�)r0�_string_from_ip_intr9rzs r�__str__z_BaseAddress.__str__as���4�+�+�D�H�H�5�6�6r
c�P�ttt|j���Sr�)�hash�hexr�r9rzs r�__hash__z_BaseAddress.__hash__ds���C��D�H�H�
�&�'�'r
c��|j|fSr��rerzs rrrz_BaseAddress._get_address_keygs���
�
�t�$�$r
c�4�|j|jffSr�)r�r9rzs rr�z_BaseAddress.__reduce__js���~�~����{�*�*r
c����|r|ddk(rtt|�|�St�ddl}|j	d�atj|�}|st�|�|�S|j�\}}}|dk(r|jdk(rd}nd	}|dk(r
|j}n|jdz}|r||dzd
z
z
}|r|dz
}tt|�|�d|�|�|���S)
a�Returns an IP address as a formatted string.

        Supported presentation types are:
        's': returns the IP address as a string (default)
        'b': converts to binary and returns a zero-padded string
        'X' or 'x': converts to upper- or lower-case hex and returns a zero-padded string
        'n': the same as 'b' for IPv4 and 'x' for IPv6

        For binary and hex presentation types, the alternate form specifier
        '#' and the grouping option '_' are supported.
        rd�sNrz(#?)(_?)([xbnX])�nr$�b�xr6r/�0)�formatr0�_address_fmt_re�re�compile�	fullmatch�super�
__format__�groupsrerNr�)	r{�fmtr��m�	alternate�grouping�fmt_base�padlenr�s	        �rr�z_BaseAddress.__format__ms�����c�"�g��n��#�d�)�S�)�)��"�� �j�j�);�<�O��%�%�c�*����7�%�c�*�*�()���
�%�	�8�X��s�?��}�}��!������s�?��(�(�F��(�(�A�-�F���f��k�A�o�%�F���a�K�F��c�$�i�I�;�a��x��z�(��!L�M�Mr
)rr	r
rr�r�r�r�r�r�r�r�r�rrr�r��
__classcell__�r�s@rrKrK3sM�����I��"��1�
1�
?�7�(�%�+�/N�/Nr
rKc��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ejd��Zejd
��Zed��Zed��Zed��Zed��Zed��Zed��Zd�Zd�Zd�Zd$d�Zd$d�Zed��Zed��Z d�Z!d�Z"ed��Z#ed��Z$ed ��Z%ed!��Z&ed"��Z'ed#��Z(y)%rpz}A generic IP network object.

    This IP class contains the version independent methods which are
    used by networks.
    c�L�|jj�dt|��d�Sr�r�rzs rr�z_BaseNetwork.__repr__�r�r
c�8�d|j|jfzS�N�%s/%d)rhr�rzs rr�z_BaseNetwork.__str__�s���$�.�.����?�?�?r
c#�K�t|j�}t|j�}t|dz|�D]}|j	|����y�w)z�Generate Iterator over usable hosts in a network.

        This is like __iter__ except it doesn't return the network
        or broadcast addresses.

        r6N�r�rhr^�range�_address_class�r{�network�	broadcastr�s    r�hostsz_BaseNetwork.hosts�sS�����d�*�*�+����.�.�/�	��w��{�I�.�	)�A��%�%�a�(�(�	)���AAc#�K�t|j�}t|j�}t||dz�D]}|j	|����y�w�Nr6r�r�s    r�__iter__z_BaseNetwork.__iter__�sQ�����d�*�*�+����.�.�/�	��w�	�A�
�.�	)�A��%�%�a�(�(�	)�r�c��t|j�}t|j�}|dk\r'||z|kDrtd��|j	||z�S|dz
}||z|krtd��|j	||z�S)Nrzaddress out of ranger6)r�rhr^�
IndexErrorr�)r{r�r�r�s    r�__getitem__z_BaseNetwork.__getitem__�s����d�*�*�+����.�.�/�	���6���{�Y�&� �!7�8�8��&�&�w��{�3�3�
��F�A��1�}�w�&� �!7�8�8��&�&�y�1�}�5�5r
c�L�t|t�stS|j|jk7rt	|�d|�d���|j
|j
k7r|j
|j
kS|j|jk7r|j|jkSyr�)rJrprsrerLrh�netmaskr�s  rr�z_BaseNetwork.__lt__�s����%��.�!�!��=�=�E�N�N�*��!�5�*�+�
+����5�#8�#8�8��'�'�%�*?�*?�?�?��<�<�5�=�=�(��<�<�%�-�-�/�/�r
c���	|j|jk(xrF|j|jk(xr+t|j�t|j�k(S#t$r	t
cYSwxYwr�)rerhr�rrgrsr�s  rr�z_BaseNetwork.__eq__�sk��	"��M�M�U�^�^�3�<��(�(�E�,A�,A�A�<�����%��U�]�]�);�;�
=���	"�!�!�	"�s�A A#�#A5�4A5c�j�tt|j�t|j�z�Sr�)r�r�rhrrzs rr�z_BaseNetwork.__hash__�s&���C��,�,�-��D�L�L�0A�A�B�Br
c���|j|jk7ryt|t�ry|j|jjz|j
jk(S�NF)rerJrpr9rrhr�s  r�__contains__z_BaseNetwork.__contains__�sN���=�=�E�N�N�*���e�\�*���9�9�t�|�|�/�/�/�4�3G�3G�3K�3K�K�Kr
c�~�|j|vxs.|j|vxs|j|vxs|j|vS)z*Tell if self is partly contained in other.�rhr^r�s  r�overlapsz_BaseNetwork.overlaps�sN���#�#�u�,�7��"�"�e�+�
6��%�%��-�5��+�+�t�3�	7r
c�v�|jt|j�t|j�z�Sr�)r�r�rh�hostmaskrzs rr^z_BaseNetwork.broadcast_address�s3���"�"�3�t�';�';�#<�#&�t�}�}�#5�$6�7�	7r
c�d�|jt|j�|jz�Sr�)r�r�rrOrzs rr
z_BaseNetwork.hostmask�s%���"�"�3�t�|�|�#4�t�~�~�#E�F�Fr
c�8�d|j|jfzSr�)rhrfrzs r�with_prefixlenz_BaseNetwork.with_prefixlen�s���$�.�.����@�@�@r
c�8�|j�d|j��S�Nr.)rhrrzs r�with_netmaskz_BaseNetwork.with_netmasks���.�.����=�=r
c�8�|j�d|j��Sr)rhr
rzs r�
with_hostmaskz_BaseNetwork.with_hostmasks���.�.��
�
�>�>r
c�^�t|j�t|j�z
dzS)z&Number of hosts in the current subnet.r6)r�r^rhrzs r�
num_addressesz_BaseNetwork.num_addressess*���4�)�)�*�S��1E�1E�-F�F��J�Jr
c�6�dt|�fz}t|��)Nz%%200s has no associated address classr�r�s  rr�z_BaseNetwork._address_classs��
6��d��
�E��!�#�&�&r
c��|jSr�)rfrzs rr�z_BaseNetwork.prefixlens�����r
c#�K�|j|jk(st|�d|�d���t|t�std|z��|j	|�st|�d|����||k(ry|j
|j�d|j���}|j�\}}||k7rv||k7rq|j	|�r|��|j�\}}n=|j	|�r|��|j�\}}ntd|�d|�d	|����||k7r||k7r�q||k(r|��y||k(r|��ytd|�d|�d	|�����w)
a�Remove an address from a larger block.

        For example:

            addr1 = ip_network('192.0.2.0/28')
            addr2 = ip_network('192.0.2.1/32')
            list(addr1.address_exclude(addr2)) =
                [IPv4Network('192.0.2.0/32'), IPv4Network('192.0.2.2/31'),
                 IPv4Network('192.0.2.4/30'), IPv4Network('192.0.2.8/29')]

        or IPv6:

            addr1 = ip_network('2001:db8::1/32')
            addr2 = ip_network('2001:db8::1/128')
            list(addr1.address_exclude(addr2)) =
                [ip_network('2001:db8::1/128'),
                 ip_network('2001:db8::2/127'),
                 ip_network('2001:db8::4/126'),
                 ip_network('2001:db8::8/125'),
                 ...
                 ip_network('2001:db8:8000::/33')]

        Args:
            other: An IPv4Network or IPv6Network object of the same type.

        Returns:
            An iterator of the IPv(4|6)Network objects which is self
            minus other.

        Raises:
            TypeError: If self and other are of differing address
              versions, or if other is not a network object.
            ValueError: If other is not completely contained by self.

        rGrHz%s is not a network objectz not contained in Nr.z Error performing exclusion: s1: z s2: z other: )rerLrJrp�	subnet_ofrr�rhr�r`�AssertionError)r{r��s1�s2s    r�address_excludez_BaseNetwork.address_excludesT����H�}�}����.��!�5�*�+�
+��%��.��8�5�@�A�A����t�$����E�F�F��D�=�����5�+@�+@�+0�?�?�!<�=��������B��E�k�b�E�k����r�"���������B�����$���������B�%�&(�"�e�&5�6�6��E�k�b�E�k���;��H�
�5�[��H�!�"$�b�%�"1�2�
2�s�D'E�*(Ec�(�|j|jk7rt|�d|�d���|j|jkry|j|jkDry|j|jkry|j|jkDryy)a�Compare two IP objects.

        This is only concerned about the comparison of the integer
        representation of the network addresses.  This means that the
        host bits aren't considered at all in this method.  If you want
        to compare host bits, you can easily enough do a
        'HostA._ip < HostB._ip'

        Args:
            other: An IP object.

        Returns:
            If the IP versions of self and other are the same, returns:

            -1 if self < other:
              eg: IPv4Network('192.0.2.0/25') < IPv4Network('192.0.2.128/25')
              IPv6Network('2001:db8::1000/124') <
                  IPv6Network('2001:db8::2000/124')
            0 if self == other
              eg: IPv4Network('192.0.2.0/24') == IPv4Network('192.0.2.0/24')
              IPv6Network('2001:db8::1000/124') ==
                  IPv6Network('2001:db8::1000/124')
            1 if self > other
              eg: IPv4Network('192.0.2.128/25') > IPv4Network('192.0.2.0/25')
                  IPv6Network('2001:db8::2000/124') >
                      IPv6Network('2001:db8::1000/124')

          Raises:
              TypeError if the IP versions are different.

        rGz are not of the same typerdr6r)rerLrhrr�s  r�compare_networksz_BaseNetwork.compare_networksgs���B�=�=�E�N�N�*��!�5�*�+�
+����%�"7�"7�7�����%�"7�"7�7���<�<�%�-�-�'���<�<�%�-�-�'��r
c�H�|j|j|jfS)z�Network-only key function.

        Returns an object that identifies this address' network and
        netmask. This function is a suitable "key" argument for sorted()
        and list.sort().

        )rerhrrzs rrqz_BaseNetwork._get_networks_key�s���
�
�t�3�3�T�\�\�B�Br
Nc#�K�|j|jk(r|��y|�9||jkrtd��|dk7rtd��||jz
}|dkrtd��|j|z}||jkDrtd||fz��t|j�}t|j
�dz}t|j�dz|z	}t|||�D]}|j||f�}|���y�w)a�The subnets which join to make the current subnet.

        In the case that self contains only one IP
        (self._prefixlen == 32 for IPv4 or self._prefixlen == 128
        for IPv6), yield an iterator with just ourself.

        Args:
            prefixlen_diff: An integer, the amount the prefix length
              should be increased by. This should not be set if
              new_prefix is also set.
            new_prefix: The desired new prefix length. This must be a
              larger number (smaller prefix) than the existing prefix.
              This should not be set if prefixlen_diff is also set.

        Returns:
            An iterator of IPv(4|6) objects.

        Raises:
            ValueError: The prefixlen_diff is too small or too large.
                OR
            prefixlen_diff and new_prefix are both set or new_prefix
              is a smaller number than the current prefix (smaller
              number means a larger network)

        Nznew prefix must be longerr6�(cannot set prefixlen_diff and new_prefixrzprefix length diff must be > 0z0prefix length diff %d is invalid for netblock %s)	rfrNrr�rhr^r
r�r�)	r{�prefixlen_diff�
new_prefix�
new_prefixlen�start�end�step�new_addr�currents	         rr`z_BaseNetwork.subnets�s!����4�?�?�d�1�1�1��J���!��D�O�O�+� �!<�=�=���"� �!K�L�L�'�$�/�/�9�N��A���=�>�>����.�8�
��4�.�.�.��B�!�4�F)�)�*�
*��D�(�(�)���$�(�(�)�A�-���D�M�M�"�Q�&�>�9���e�S�$�/�	�H��n�n�h�
�%>�?�G��M�	�s�D
Dc�t�|jdk(r|S|�9||jkDrtd��|dk7rtd��|j|z
}|j|z
}|dkrtd|j|fz��|jt	|j
�t	|j�|zz|f�S)a�The supernet containing the current network.

        Args:
            prefixlen_diff: An integer, the amount the prefix length of
              the network should be decreased by.  For example, given a
              /24 network and a prefixlen_diff of 3, a supernet with a
              /21 netmask is returned.

        Returns:
            An IPv4 network object.

        Raises:
            ValueError: If self.prefixlen - prefixlen_diff < 0. I.e., you have
              a negative prefix length.
                OR
            If prefixlen_diff and new_prefix are both set or new_prefix is a
              larger number than the current prefix (larger number means a
              smaller network)

        rznew prefix must be shorterr6r$z;current prefixlen is %d, cannot have a prefixlen_diff of %d)rfrr�r�r�rhr)r{r%r&r's    rrYz_BaseNetwork.supernet�s���*�?�?�a���K��!��D�O�O�+� �!=�>�>���"� �!K�L�L�!�_�_�z�9�N�����7�
��1���M�����0�1�2�
2��~�~���$�$�%��T�\�\�):�n�)L�M����	r
c�^�|jjxr|jjS�z�Test if the address is reserved for multicast use.

        Returns:
            A boolean, True if the address is a multicast address.
            See RFC 2373 2.7 for details.

        )rh�is_multicastr^rzs rr0z_BaseNetwork.is_multicast�s,���$�$�1�1�4��&�&�3�3�	5r
c��	|j|jk7rt|�d|�d���|j|jkxr|j|jk\S#t$rtd|�d|����wxYw)NrGrHz*Unable to test subnet containment between )rerLrhr^rg)�ar�s  r�
_is_subnet_ofz_BaseNetwork._is_subnet_ofs���	4��z�z�Q�Z�Z�'��1�#�U�1�#�-I� J�K�K��%�%��):�):�:�?��'�'�1�+>�+>�>�
@���	4��'�'(�c��q�c�3�4�
4�	4�s�AA � A;c�&�|j||�S)z1Return True if this network is a subnet of other.�r3r�s  rrz_BaseNetwork.subnet_ofs���!�!�$��.�.r
c�&�|j||�S)z3Return True if this network is a supernet of other.r5r�s  r�supernet_ofz_BaseNetwork.supernet_ofs���!�!�%��.�.r
c�^�|jjxr|jjS)��Test if the address is otherwise IETF reserved.

        Returns:
            A boolean, True if the address is within one of the
            reserved IPv6 Network ranges.

        )rh�is_reservedr^rzs rr:z_BaseNetwork.is_reserved�,���$�$�0�0�3��&�&�2�2�	4r
c�^�|jjxr|jjS�z�Test if the address is reserved for link-local.

        Returns:
            A boolean, True if the address is reserved per RFC 4291.

        )rh�
is_link_localr^rzs rr>z_BaseNetwork.is_link_local+s,���$�$�2�2�5��&�&�4�4�	6r
c���t�fd��jjD��xr(t�fd��jjD��S)z�Test if this network belongs to a private range.

        Returns:
            A boolean, True if the network is reserved per
            iana-ipv4-special-registry or iana-ipv6-special-registry.

        c3�Z�K�|]"}�j|vxr�j|v���$y�wr�r
)�.0�priv_networkr{s  �r�	<genexpr>z*_BaseNetwork.is_private.<locals>.<genexpr>?s>�����J�#��'�'�<�7�:��)�)�\�9�:�J���(+c3�Z�K�|]"}�j|vxr�j|v���$y�wr�r
)rAr�r{s  �rrCz*_BaseNetwork.is_private.<locals>.<genexpr>As@�����R� ��(�(��7�:��*�*�'�9�:�R�rD��any�
_constants�_private_networks�all�_private_networks_exceptionsrzs`r�
is_privatez_BaseNetwork.is_private6sU����J�'+���'H�'H�J�J��NQ�R�$(�?�?�#O�#O�R�O�	r
c��|jS)z�Test if this address is allocated for public networks.

        Returns:
            A boolean, True if the address is not reserved per
            iana-ipv4-special-registry or iana-ipv6-special-registry.

        �rLrzs r�	is_globalz_BaseNetwork.is_globalGs���?�?�"�"r
c�^�|jjxr|jjS)��Test if the address is unspecified.

        Returns:
            A boolean, True if this is the unspecified address as defined in
            RFC 2373 2.5.2.

        )rh�is_unspecifiedr^rzs rrRz_BaseNetwork.is_unspecifiedRs,���$�$�3�3�6��&�&�5�5�	7r
c�^�|jjxr|jjS)��Test if the address is a loopback address.

        Returns:
            A boolean, True if the address is a loopback address as defined in
            RFC 2373 2.5.3.

        )rh�is_loopbackr^rzs rrUz_BaseNetwork.is_loopback^r;r
)r6N))rr	r
rr�r�r�r�rr�r�r�rr�	functools�cached_propertyr^r
r�rrrrr�r�rr!rqr`rYr0�staticmethodr3rr7r:r>rLrOrRrUrr
rrprp�s����?�@�
)�)�6�
�"�C�
L�7����7��7����G��G��A��A��>��>��?��?��K��K��'��'�����I2�V.�`C�3�j'�R�	5��	5��	4��	4�/�/��	4��	4��6��6����� �#��#��	7��	7��	4��	4r
rpc��eZdZgZy)�_BaseConstantsN)rr	r
rIrr
rrZrZks���r
rZc��eZdZdZdZdZdezdz
ZeZiZ	d�Z
ed��Zed��Z
ed	��Zed
��Zd�Zed��Zed
��Zy)�_BaseV4zyBase IPv4 object.

    The following methods are used by IPv4 objects in both single IP
    addresses and networks.

    rr$r/r6c��t|�Sr�r~rzs rryz$_BaseV4._explode_shorthand_ip_string�s���4�y�r
c�l�||jvrxt|t�r+|}d|cxkr|jks&n|j	|�n	|j|�}t|j|��}||f|j|<|j|S#t$r|j|�}Y�VwxYw�aMake a (netmask, prefix_len) tuple from the given argument.

        Argument can be:
        - an integer (the prefix length)
        - a string representing the prefix length (e.g. "24")
        - a string representing the prefix netmask (e.g. "255.255.255.0")
        r)
�_netmask_cacherJr�rNr�r�rr�rr��r��argr�rs    r�
_make_netmaskz_BaseV4._make_netmask�s����c�(�(�(��#�s�#��	��Y�<�#�*<�*<�<��/�/�	�:�@� #� >� >�s� C�I�
"�#�"9�"9�)�"D�E�G�&-�y�&8�C���s�#��!�!�#�&�&��
)�@�!$� :� :�3� ?�I�@�s�B�B3�2B3c��|std��|jd�}t|�dk7rtd|z��	tj	t|j|�d�S#t$r}t|�d|���d�d}~wwxYw)aTurn the given IP string into an integer for comparison.

        Args:
            ip_str: A string, the IP ip_str.

        Returns:
            The IP ip_str as an integer.

        Raises:
            AddressValueError: if ip_str isn't a valid IPv4 Address.

        �Address cannot be empty�.r$zExpected 4 octets in %rr�� in N)rr1r2r��
from_bytes�map�_parse_octetr)r�r��octets�excs    rr�z_BaseV4._ip_int_from_string�s����#�$=�>�>����c�"���v�;�!��#�$=��$F�G�G�	J��>�>�#�c�&6�&6��"?��G�G���	J�#�#�v�$>�?�T�I��	J�s�)A&�&	B�/B�Bc�4�|std��|j�r|j�sd}t||z��t|�dkDrd}t||z��|dk7r|ddk(rd}t||z��t	|d�}|d	kDrtd
|z��|S)aConvert a decimal octet into an integer.

        Args:
            octet_str: A string, the number to parse.

        Returns:
            The octet as an integer.

        Raises:
            ValueError: if the octet isn't strictly a decimal from [0..255].

        zEmpty octet not permittedz#Only decimal digits permitted in %r�z$At most 3 characters permitted in %rr�rz%Leading zeros are not permitted in %r�
�zOctet %d (> 255) not permitted)rr�r�r2r�)r��	octet_strr��	octet_ints    rrjz_BaseV4._parse_octet�s�����8�9�9��!�!�#�	�(9�(9�(;�7�C��S�9�_�-�-��y�>�A��8�C��S�9�_�-�-����	�!��� 3�9�C��S�9�_�-�-��	�2�&�	��s�?��=�	�I�J�J��r
c	�`�djtt|jdd���S)z�Turns a 32-bit integer into dotted decimal notation.

        Args:
            ip_int: An integer, the IP address.

        Returns:
            The IP address as a string in dotted decimal notation.

        rfr$r�)�joinrir0r&)r�r�s  rr�z_BaseV4._string_from_ip_int�s%���x�x��C�����E�!:�;�<�<r
c�j�t|�jd�ddd�}dj|�dzS)z�Return the reverse DNS pointer name for the IPv4 address.

        This implements the method described in RFC1035 3.5.

        rfNrdz
.in-addr.arpa)r0r1rt)r{�reverse_octetss  rr�z_BaseV4._reverse_pointer�s3���T�����-�d��d�3���x�x��'�/�9�9r
c��|jSr��rNrzs r�
max_prefixlenz_BaseV4.max_prefixlen�����"�"�"r
c��|jSr�r�rzs rrMz_BaseV4.version�����}�}�r
N)rr	r
rr�re�
IPV4LENGTHrOrNr`ryr�rcr�rjr�r�r�ryrMrr
rr\r\ss�����I��H��J��!�#�I��N��N���'��'�2�J��J�2�!��!�F�
=��
=�:��#��#����r
r\c���eZdZdZdZd�Zed��Zed��Zee	j�d���Zee	j�d���Zed��Z
ed	��Zed
��Zed��Zy)
rz/Represent and manipulate single IPv4 Addresses.)r9�__weakref__c�6�t|t�r|j|�||_yt|t�r-|j|d�tj
|�|_yt|�}d|vrtd|����|j|�|_y)a�
        Args:
            address: A string or integer representing the IP

              Additionally, an integer can be passed, so
              IPv4Address('192.0.2.1') == IPv4Address(3221225985).
              or, more generally
              IPv4Address(int(IPv4Address('192.0.2.1'))) ==
                IPv4Address('192.0.2.1')

        Raises:
            AddressValueError: If ipaddress isn't a valid IPv4 address.

        Nr$r.�Unexpected '/' in )
rJr�r�r9r�r�rhr0rr��r{r�addr_strs   r�__init__zIPv4Address.__init__s���"�g�s�#��#�#�G�,��D�H���g�u�%��&�&�w��2��~�~�g�.�D�H���w�<���(�?�#�&8���$D�E�E��+�+�H�5��r
c�,�t|j�S�z*The binary representation of this address.)r(r9rzs r�packedzIPv4Address.packed)��� ����)�)r
c�2�||jjvS)z�Test if the address is otherwise IETF reserved.

         Returns:
             A boolean, True if the address is within the
             reserved IPv4 Network range.

        )rH�_reserved_networkrzs rr:zIPv4Address.is_reserved.s���t���8�8�8�8r
c���t�fd��jjD��xr(t�fd��jjD��S)��``True`` if the address is defined as not globally reachable by
        iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_
        (for IPv6) with the following exceptions:

        * ``is_private`` is ``False`` for ``100.64.0.0/10``
        * For IPv4-mapped IPv6-addresses the ``is_private`` value is determined by the
            semantics of the underlying IPv4 addresses and the following condition holds
            (see :attr:`IPv6Address.ipv4_mapped`)::

                address.is_private == address.ipv4_mapped.is_private

        ``is_private`` has value opposite to :attr:`is_global`, except for the ``100.64.0.0/10``
        IPv4 range where they are both ``False``.
        c3�&�K�|]}�|v���
y�wr�r�rArTr{s  �rrCz)IPv4Address.is_private.<locals>.<genexpr>K������I�����I���c3�&�K�|]}�|v���
y�wr�rr�s  �rrCz)IPv4Address.is_private.<locals>.<genexpr>L������\��D��O�\�r�rFrzs`rrLzIPv4Address.is_private9s@���$
�I�t���'H�'H�I�I�
]��\�t���/[�/[�\�\�	
r
c�P�||jjvxr
|jS�ar``True`` if the address is defined as globally reachable by
        iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_
        (for IPv6) with the following exception:

        For IPv4-mapped IPv6-addresses the ``is_private`` value is determined by the
        semantics of the underlying IPv4 addresses and the following condition holds
        (see :attr:`IPv6Address.ipv4_mapped`)::

            address.is_global == address.ipv4_mapped.is_global

        ``is_global`` has value opposite to :attr:`is_private`, except for the ``100.64.0.0/10``
        IPv4 range where they are both ``False``.
        )rH�_public_networkrLrzs rrOzIPv4Address.is_globalOs%�� �4�?�?�:�:�:�R�4�?�?�?R�Rr
c�2�||jjvS)z�Test if the address is reserved for multicast use.

        Returns:
            A boolean, True if the address is multicast.
            See RFC 3171 for details.

        �rH�_multicast_networkrzs rr0zIPv4Address.is_multicasta����t���9�9�9�9r
c�4�||jjk(S)z�Test if the address is unspecified.

        Returns:
            A boolean, True if this is the unspecified address as defined in
            RFC 5735 3.

        )rH�_unspecified_addressrzs rrRzIPv4Address.is_unspecifiedls���t���;�;�;�;r
c�2�||jjvS)z�Test if the address is a loopback address.

        Returns:
            A boolean, True if the address is a loopback per RFC 3330.

        )rH�_loopback_networkrzs rrUzIPv4Address.is_loopbackws���t���8�8�8�8r
c�2�||jjvS)z�Test if the address is reserved for link-local.

        Returns:
            A boolean, True if the address is link-local per RFC 3927.

        �rH�_linklocal_networkrzs rr>zIPv4Address.is_link_local�����t���9�9�9�9r
N)rr	r
rr�r�r�r�r:rV�	lru_cacherLrOr0rRrUr>rr
rrrs���9�&�I�!6�F�*��*��9��9���Y����
���
�(��Y����S���S� �:��:��<��<��9��9��:��:r
rc��eZdZd�Zej
d��Zd�Zd�Zd�Z	d�Z
ejZe
d��Ze
d��Ze
d	��Ze
d
��Zy)r c���|j|�\}}tj||�t||fd��|_|jj
|_|jj|_y�NF)r)r�rr�rr�rrf�r{rr3�masks    rr�zIPv4Interface.__init__��Z���,�,�W�5�
��d����T�4�(�"�D�$�<��>����|�|�+�+����,�,�1�1��r
c�.�|jjSr��r�r
rzs rr
zIPv4Interface.hostmask�����|�|�$�$�$r
c�V�d|j|j�|jfzSr��r�r9rfrzs rr�zIPv4Interface.__str__�s,���$�2�2�4�8�8�<��/�/�+�+�	+r
c��tj||�}|tus|s|S	|j|jk(S#t$rYywxYwr)rr�rsr�rg�r{r��
address_equals   rr�zIPv4Interface.__eq__��P��#�*�*�4��7�
��N�*�-� � �	��<�<�5�=�=�0�0���	��		���=�	A	�A	c���tj||�}|turtS	|j|jkxs|j|jk(xr|S#t$rYywxYwr)rr�rsr�rg�r{r��address_lesss   rr�zIPv4Interface.__lt__�sl��"�)�)�$��6���>�)�!�!�	��L�L�5�=�=�0�C��L�L�E�M�M�1�B�l�
D���	��	�s�7A�	A*�)A*c��t|j|jt|jj
�f�Sr��r�r9rfr�r�rhrzs rr�zIPv4Interface.__hash__��+���T�X�X�t����D�L�L�4P�4P�0Q�R�S�Sr
c�,�t|j�Sr�)rr9rzs rr>zIPv4Interface.ip�����4�8�8�$�$r
c�V�|j|j��d|j��Srr�rzs rrzIPv4Interface.with_prefixlen��%���2�2�4�8�8�<��/�/�+�	+r
c�V�|j|j��d|j��Sr�r�r9rrzs rrzIPv4Interface.with_netmask��%���2�2�4�8�8�<��,�,�(�	(r
c�V�|j|j��d|j��Sr�r�r9r
rzs rrzIPv4Interface.with_hostmask��%���2�2�4�8�8�<��-�-�)�	)r
N)rr	r
r�rVrWr
r�r�r�r�rwr�r�r>rrrrr
rr r �s���2����%��%�+�
�
�T� �*�*�J�
�%��%��+��+��(��(��)��)r
r c�T�eZdZdZeZdd�Zeej�d���Z
y)raeThis class represents and manipulates 32-bit IPv4 network + addresses..

    Attributes: [examples for IPv4Network('192.0.2.0/27')]
        .network_address: IPv4Address('192.0.2.0')
        .hostmask: IPv4Address('0.0.0.31')
        .broadcast_address: IPv4Address('192.0.2.32')
        .netmask: IPv4Address('255.255.255.224')
        .prefixlen: 27

    c���|j|�\�}t��|_|j|�\|_|_t
|j�}|t
|j�z|k7r6|rtd|z��t|t
|j�z�|_|j
|jdz
k(r|j|_
y|j
|jk(r�fd�|_
yy)aInstantiate a new IPv4 network object.

        Args:
            address: A string or integer representing the IP [& network].
              '192.0.2.0/24'
              '192.0.2.0/255.255.255.0'
              '192.0.2.0/0.0.0.255'
              are all functionally the same in IPv4. Similarly,
              '192.0.2.1'
              '192.0.2.1/255.255.255.255'
              '192.0.2.1/32'
              are also functionally equivalent. That is to say, failing to
              provide a subnetmask will create an object with a mask of /32.

              If the mask (portion after the / in the argument) is given in
              dotted quad form, it is treated as a netmask if it starts with a
              non-zero field (e.g. /255.0.0.0 == /8) and as a hostmask if it
              starts with a zero field (e.g. 0.255.255.255 == /8), with the
              single exception of an all-zero mask which is treated as a
              netmask == /0. If no mask is given, a default of /32 is used.

              Additionally, an integer can be passed, so
              IPv4Network('192.0.2.1') == IPv4Network(3221225985)
              or, more generally
              IPv4Interface(int(IPv4Interface('192.0.2.1'))) ==
                IPv4Interface('192.0.2.1')

        Raises:
            AddressValueError: If ipaddress isn't a valid IPv4 address.
            NetmaskValueError: If the netmask isn't valid for
              an IPv4 address.
            ValueError: If strict is True and a network address is not
              supplied.
        �%s has host bits setr6c���t��gSr�)r�r3s�r�<lambda>z&IPv4Network.__init__.<locals>.<lambda>����+�d�"3�!4�r
N)r�rrhrcrrfr�rrNr�r��r{rrr�r�r3s     @rr�zIPv4Network.__init__�s����F�,�,�W�5�
��d�*�4�0���(,�(:�(:�4�(@�%���d�o��T�)�)�*���C����%�%��/�� �!7�$�!>�?�?�'2�6�36�t�|�|�3D�4E�(F��$��?�?�t�2�2�Q�6�7����D�J�
�_�_��!4�!4�
5�4�D�J�6r
c��|jtd�vxr|jtd�vxr
|jS)z�Test if this address is allocated for public networks.

        Returns:
            A boolean, True if the address is not reserved per
            iana-ipv4-special-registry.

        �
100.64.0.0/10)rhrr^rLrzs rrOzIPv4Network.is_globalsJ���)�)�[��-I�I�K��*�*�k�/�.J�J�L�$��O�O�#�	%r
N�T)rr	r
rrr�r�r�rVr�rOrr
rrr�s;��	�!�N�25�h��Y����
%���
%r
rc�T�eZdZed�Zed�Zed�Zed�Zed�ed�ed�ed�ed�ed�ed	�ed
�ed�ed�ed
�ed�ed�ed�gZed�ed�gZ	ed�Z
ed�Zy)�_IPv4Constantsz169.254.0.0/16z127.0.0.0/8z224.0.0.0/4r�z	0.0.0.0/8z
10.0.0.0/8z
172.16.0.0/12z192.0.0.0/24z192.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/32z192.0.0.9/32z
192.0.0.10/32z0.0.0.0N)
rr	r
rr�r�r�r�rIrKr�rr�rr
rr�r�!s���$�%5�6��#�M�2��$�]�3��!�/�2�O�
	�K� ��L�!��M�"��$�%��O�$��N�#��$�%��N�#��$�%��O�$��%�&��$�%��M�"��(�)�
��$	�N�#��O�$�$� �
$�M�2��&�y�1�r
r�c���eZdZdZdZdZdezdz
ZdZe	d�Z
eZiZe
d��Ze
d	��Ze
d
��Ze
d��Ze
dd
��Zd�Zd�Zed��Zed��Zed��Zy)�_BaseV6zyBase IPv6 object.

    The following methods are used by IPv6 objects in both single IP
    addresses and networks.

    rrIr/r6r��0123456789ABCDEFabcdefc�*�||jvrwt|t�r+|}d|cxkr|jks%n|j	|�n|j|�}t
|j|��}||f|j|<|j|Sr_)r`rJr�rNr�r�rr�ras    rrcz_BaseV6._make_netmask_s����c�(�(�(��#�s�#��	��Y�<�#�*<�*<�<��/�/�	�:��:�:�3�?�	�!�#�"9�"9�)�"D�E�G�&-�y�&8�C���s�#��!�!�#�&�&r
c�F�|std��|jd�}d}t|�|krd||fz}t|��d|dvrU	t|j	��j
}|j
d	|d
z	dzz�|j
d	|dzz�|jdz}t|�|kDrd
|dz
|fz}t|��d}tdt|�dz
�D]}	||	r�	|�d|z}t|��|	}�|��|}
t|�|z
dz
}|ds|
dz}
|
rd}t||z��|ds|dz}|rd}t||z��|j|
|zz
}|dkr�d}t||jdz
|fz��t|�|jk7rd}t||j|fz��|dsd}t||z��|dsd}t||z��t|�}
d}d}	d}
t|
�D]}	|
d
z}
|
|j||	�z}
� |
d
|zz}
t|d�D]}	|
d
z}
|
|j||	�z}
� |
S#t$r}t|�d|���d�d}~wwxYw#t$r}t|�d|���d�d}~wwxYw)z�Turn an IPv6 ip_str into an integer.

        Args:
            ip_str: A string, the IPv6 ip_str.

        Returns:
            An int, the IPv6 address

        Raises:
            AddressValueError: if ip_str isn't a valid IPv6 Address.

        re�:rnz At least %d parts expected in %rrfrdrgN�%xr+�r6z!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)rr1r2rrXr9r[�
_HEXTET_COUNTr��
_parse_hextetr)r�r��parts�
_min_partsr��ipv4_intrl�
_max_parts�
skip_index�i�parts_hi�parts_lo�
parts_skippedr�s              rr�z_BaseV6._ip_int_from_stringss>���#�$=�>�>����S�!���
��u�:�
�"�4�
�F�7K�K�C�#�C�(�(��%��)��
N�&�u�y�y�{�3�7�7��
�L�L��(�b�.�F�!:�;�<��L�L���F�!2�3�4�
�&�&��*�
��u�:�
�"�5��A��v�8N�N�C�#�C�(�(��
��q�#�e�*�q�.�)�	�A���8��)�<�v�E�C�+�C�0�0��
�
	��!�!�H��5�z�J�.��2�H���8��A�
���L�C�+�C�&�L�9�9���9��A�
���M�C�+�C�&�L�9�9��-�-��H�1D�E�M��q� �G��'��s�/@�/@��/B�F�.K�(K�L�L�
�5�z�S�.�.�.�D��'��s�/@�/@�&�.I�(I�J�J���8�H��'��f��5�5���9�I��'��f��5�5��5�z�H��H��M�	J��F��8�_�
6���2�
���#�+�+�E�!�H�5�5��
6�
�r�M�)�)�F��H�9�a�(�
6���2�
���#�+�+�E�!�H�5�5��
6��M��O%�
N�'�c�6�(B�C��M��
N��P�	J�#�#�v�$>�?�T�I��	J�s1�	#I�9A%J�	I>�(I9�9I>�	J �
J�J c��|jj|�std|z��t|�dkDrd}t||z��t	|d�S)a&Convert an IPv6 hextet string into an integer.

        Args:
            hextet_str: A string, the number to parse.

        Returns:
            The hextet as an integer.

        Raises:
            ValueError: if the input isn't strictly a hex number from
              [0..FFFF].

        zOnly hex digits permitted in %rr$z$At most 4 characters permitted in %rr+)�_HEX_DIGITS�
issupersetrr2r�)r��
hextet_strr�s   rr�z_BaseV6._parse_hextet�sW�� ���)�)�*�5��>��K�L�L��z�?�Q��8�C��S�:�-�.�.��:�r�"�"r
c���d}d}d}d}t|�D]%\}}|dk(r|dz
}|dk(r|}||kDs�|}|}�"d}d}�'|dkDr*||z}|t|�k(r|dgz
}dg||||dk(rdg|z}|S)a�Compresses a list of hextets.

        Compresses a list of strings, replacing the longest continuous
        sequence of "0" in the list with "" and adding empty strings at
        the beginning or at the end of the string such that subsequently
        calling ":".join(hextets) will produce the compressed version of
        the IPv6 address.

        Args:
            hextets: A list of strings, the hextets to compress.

        Returns:
            A list of strings.

        rdrr�r6�)�	enumerater2)	r��hextets�best_doublecolon_start�best_doublecolon_len�doublecolon_start�doublecolon_len�index�hextet�best_doublecolon_ends	         r�_compress_hextetsz_BaseV6._compress_hextets�s���""$�� ������&�w�/�	'�M�E�6���}��1�$��$��*�(-�%�"�%9�9�+:�(�->�*�"#��$&�!�	'� �!�#�$:�$8�%9� �$�s�7�|�3��B�4���DF�4�G�*�+?�@�%��*��$��.���r
Nc
��|�t|j�}||jkDrtd��d|z}t	ddd�D�cgc]}dt|||dzd�z��}}|j|�}dj
|�Scc}w)	a,Turns a 128-bit integer into hexadecimal notation.

        Args:
            ip_int: An integer, the IP address.

        Returns:
            A string, the hexadecimal representation of the address.

        Raises:
            ValueError: The address is bigger than 128 bits of all ones.

        zIPv6 address is too large�%032xrrr$r�r+r�)r�r9rOrr�r�rt)r�r��hex_strr�r�s     rr�z_BaseV6._string_from_ip_int%s����>�����\�F��C�M�M�!��8�9�9��F�"��;@��B��?�K�a�4�#�g�a��!��n�b�1�1�K��K��'�'��0���x�x�� � ��Ls�Bc��t|t�rt|j�}n1t|t�rt|j
�}nt|�}|j
|�}d|z}tddd�D�cgc]
}|||dz��}}t|ttf�r ddj|�|jfzSdj|�Scc}w)zmExpand a shortened IPv6 address.

        Returns:
            A string, the expanded IPv6 address.

        r�rrr$r�r�)rJrr0rhr!r>r�r�rprtrf)r{r�r�r�r�r�s      rryz$_BaseV6._explode_shorthand_ip_string?s����d�K�(���-�-�.�F�
��m�
,�����\�F���Y�F��)�)�&�1���F�"��).�q�"�a��9�A���1�Q�3��9��9��d�\�=�9�:��c�h�h�u�o�t���?�?�?��x�x�����:s�=Cc�n�|jddd�jdd�}dj|�dzS)z�Return the reverse DNS pointer name for the IPv6 address.

        This implements the method described in RFC3596 2.5.

        Nrdr�r�rfz	.ip6.arpa)r|�replacert)r{�
reverse_charss  rr�z_BaseV6._reverse_pointerTs7���
�
�d��d�+�3�3�C��<�
��x�x�
�&��4�4r
c�l�|jd�\}}}|sd}||fS|rd|vrtd|z��||fS)z�Helper function to parse IPv6 string address with scope id.

        See RFC 4007 for details.

        Args:
            ip_str: A string, the IPv6 address.

        Returns:
            (addr, scope_id) tuple.

        �%NzInvalid IPv6 address: "%r")�	partitionr)r�r3�sep�scope_ids    r�_split_scope_idz_BaseV6._split_scope_id]sU��%�.�.�s�3���c�8���H��X�~���S�H�_�#�$@�6�$I�J�J��X�~�r
c��|jSr�rxrzs rryz_BaseV6.max_prefixlenqrzr
c��|jSr�r�rzs rrMz_BaseV6.versionur|r
r�)rr	r
rr�re�
IPV6LENGTHrOr��	frozensetr�rNr`r�rcr�r�r�r�ryr�rXr�r�ryrMrr
rr�r�Ks�����I��H��J��!�#�I��M��4�5�K��N��N��'��'�&�eJ��eJ�N�#��#�2�-��-�^�!��!�2�*5�����&�#��#����r
r�c�:��eZdZdZdZd�Z�fd�Zd�Z�fd�Zd�Z	e
d��Ze
d	��Ze
d
��Z
e
d��Ze
d��Ze
d
��Ze
ej$�d���Ze
d��Ze
d��Ze
d��Ze
d��Ze
d��Ze
d��Z�xZS)rz/Represent and manipulate single IPv6 Addresses.)r9�	_scope_idrc��t|t�r |j|�||_d|_yt|t
�r5|j
|d�tj|d�|_d|_yt|�}d|vrtd|����|j|�\}|_|j|�|_y)aInstantiate a new IPv6 address object.

        Args:
            address: A string or integer representing the IP

              Additionally, an integer can be passed, so
              IPv6Address('2001:db8::') ==
                IPv6Address(42540766411282592856903984951653826560)
              or, more generally
              IPv6Address(int(IPv6Address('2001:db8::'))) ==
                IPv6Address('2001:db8::')

        Raises:
            AddressValueError: If address isn't a valid IPv6 address.

        Nr+r�r.r�)rJr�r�r9rr�r�rhr0rr�r�r�s   rr�zIPv6Address.__init__�s���$�g�s�#��#�#�G�,��D�H�!�D�N���g�u�%��&�&�w��3��~�~�g�u�5�D�H�!�D�N���w�<���(�?�#�&8���$D�E�E�#'�#7�#7��#A� ��$�.��+�+�H�5��r
c�`��t�|��}|jr|dz|jzS|S)Nr�)r�r�r)r{r�r�s  �rr�zIPv6Address.__str__�s-������"��04���v��|�d�n�n�,�J�F�Jr
c�D�t|j|jf�Sr�)r�r9rrzs rr�zIPv6Address.__hash__�s���T�X�X�t�~�~�.�/�/r
c�x��t�|�|�}|turtS|sy|jt	|dd�k(S)NFr)r�r�rsr�getattr)r{r�r�r�s   �rr�zIPv6Address.__eq__�s=������u�-�
��N�*�!�!����~�~����T�!B�B�Br
c�2�|jt|�ffSr�r�rzs rr�zIPv6Address.__reduce__�s������T���-�-r
c��|jS)z�Identifier of a particular zone of the address's scope.

        See RFC 4007 for details.

        Returns:
            A string identifying the zone of the address if specified, else None.

        )rrzs rr�zIPv6Address.scope_id�s���~�~�r
c�,�t|j�Sr�)r,r9rzs rr�zIPv6Address.packed�r�r
c�2�||jjvSr/r�rzs rr0zIPv6Address.is_multicast�r�r
c�T��t�fd��jjD��S)r9c3�&�K�|]}�|v���
y�wr�r)rAr�r{s  �rrCz*IPv6Address.is_reserved.<locals>.<genexpr>�s�����I��4�1�9�I�r�)rGrH�_reserved_networksrzs`rr:zIPv6Address.is_reserved�s ����I�d�o�o�&H�&H�I�I�Ir
c�2�||jjvSr=r�rzs rr>zIPv6Address.is_link_local�r�r
c�2�||jjvS�a`Test if the address is reserved for site-local.

        Note that the site-local address space has been deprecated by RFC 3879.
        Use is_private to test if this address is in the space of unique local
        addresses as defined by RFC 4193.

        Returns:
            A boolean, True if the address is reserved per RFC 3513 2.5.6.

        )rH�_sitelocal_networkrzs r�
is_site_localzIPv6Address.is_site_local�s���t���9�9�9�9r
c�����j}|�|jSt�fd��jjD��xr(t�fd��jjD��S)r�c3�&�K�|]}�|v���
y�wr�rr�s  �rrCz)IPv6Address.is_private.<locals>.<genexpr>r�r�c3�&�K�|]}�|v���
y�wr�rr�s  �rrCz)IPv6Address.is_private.<locals>.<genexpr>r�r�)�ipv4_mappedrLrGrHrIrJrK)r{rs` rrLzIPv6Address.is_private�s]���"�&�&���"��)�)�)��I�t���'H�'H�I�I�
]��\�t���/[�/[�\�\�	
r
c��|jSr�rNrzs rrOzIPv6Address.is_globals���?�?�"�"r
c� �|jdk(S)rQrr�rzs rrRzIPv6Address.is_unspecified#����x�x�1�}�r
c� �|jdk(S)rTr6r�rzs rrUzIPv6Address.is_loopback.rr
c�X�|jdz	dk7ryt|jdz�S)z�Return the IPv4 mapped address.

        Returns:
            If the IPv6 address is a v4 mapped address, return the
            IPv4 mapped address. Return None otherwise.

        rr�N����r9rrzs rrzIPv6Address.ipv4_mapped9s+��
�H�H��N�v�%���4�8�8�j�0�1�1r
c��|jdz	dk7ryt|jdz	dz�t|jdz�fS)z�Tuple of embedded teredo IPs.

        Returns:
            Tuple of the (server, client) IPs or None if the address
            doesn't appear to be a teredo address (doesn't start with
            2001::/32)

        �`i N�@r r!rzs r�teredozIPv6Address.teredoFsI��
�H�H��N�z�)���T�X�X��^�z�9�:��T�X�X�I�
�2�3�5�	5r
c�^�|jdz	dk7ryt|jdz	dz�S)z�Return the IPv4 6to4 embedded address.

        Returns:
            The IPv4 6to4-embedded address if present or None if the
            address doesn't appear to contain a 6to4 embedded address.

        �pi N�Pr r!rzs r�	sixtofourzIPv6Address.sixtofourUs/��
�H�H��O��&���D�H�H��N�j�8�9�9r
)rr	r
rr�r�r�r�r�r�r�r�r�r0r:r>rrVr�rLrOrRrUrr%r)r�r�s@rrrzs@���9�3�I�&6�PK�0�C�.��	��	��*��*��:��:��J��J��:��:��:��:���Y����
���
�.�#��#� ���������
2��
2��5��5��
:��
:r
rc����eZdZd�Zej
d��Z�fd�Zd�Zd�Z	d�Z
ejZe
d��Ze
d��Ze
d	��Ze
d
��Ze
d��Ze
d��Z�xZS)
r!c���|j|�\}}tj||�t||fd��|_|jj
|_|jj|_yr�)r�rr�rr�rrfr�s    rr�zIPv6Interface.__init__er�r
c�.�|jjSr�r�rzs rr
zIPv6Interface.hostmaskmr�r
c�>��dt�|��|jfzSr�)r�r�rf)r{r�s �rr�zIPv6Interface.__str__qs%����%�'�/�+��/�/�+�+�	+r
c��tj||�}|tus|s|S	|j|jk(S#t$rYywxYwr)rr�rsr�rgr�s   rr�zIPv6Interface.__eq__ur�r�c���tj||�}|tur|S	|j|jkxs|j|jk(xr|S#t$rYywxYwr)rr�rsr�rgr�s   rr�zIPv6Interface.__lt__�sl��"�)�)�$��6���>�)���	��L�L�5�=�=�0�C��L�L�E�M�M�1�B�l�
D���	��	�s�7A�	A&�%A&c��t|j|jt|jj
�f�Sr�r�rzs rr�zIPv6Interface.__hash__�r�r
c�,�t|j�Sr�)rr9rzs rr>zIPv6Interface.ip�r�r
c�V�|j|j��d|j��Srr�rzs rrzIPv6Interface.with_prefixlen�r�r
c�V�|j|j��d|j��Srr�rzs rrzIPv6Interface.with_netmask�r�r
c�V�|j|j��d|j��Srr�rzs rrzIPv6Interface.with_hostmask�r�r
c�P�|jdk(xr|jjS)Nr)r9r�rRrzs rrRzIPv6Interface.is_unspecified�s���x�x�1�}�<����!<�!<�<r
c�P�|jdk(xr|jjSr�)r9r�rUrzs rrUzIPv6Interface.is_loopback�s���x�x�1�}�9����!9�!9�9r
)rr	r
r�rVrWr
r�r�r�r�rwr�r�r>rrrrRrUr�r�s@rr!r!cs����2����%��%�+�
�
�T� �*�*�J�
�%��%��+��+��(��(��)��)��=��=��:��:r
r!c�2�eZdZdZeZdd�Zd�Zed��Z	y)ravThis class represents and manipulates 128-bit IPv6 networks.

    Attributes: [examples for IPv6('2001:db8::1000/124')]
        .network_address: IPv6Address('2001:db8::1000')
        .hostmask: IPv6Address('::f')
        .broadcast_address: IPv6Address('2001:db8::100f')
        .netmask: IPv6Address('ffff:ffff:ffff:ffff:ffff:ffff:ffff:fff0')
        .prefixlen: 124

    c���|j|�\�}t��|_|j|�\|_|_t
|j�}|t
|j�z|k7r6|rtd|z��t|t
|j�z�|_|j
|jdz
k(r|j|_
y|j
|jk(r�fd�|_
yy)a�Instantiate a new IPv6 Network object.

        Args:
            address: A string or integer representing the IPv6 network or the
              IP and prefix/netmask.
              '2001:db8::/128'
              '2001:db8:0000:0000:0000:0000:0000:0000/128'
              '2001:db8::'
              are all functionally the same in IPv6.  That is to say,
              failing to provide a subnetmask will create an object with
              a mask of /128.

              Additionally, an integer can be passed, so
              IPv6Network('2001:db8::') ==
                IPv6Network(42540766411282592856903984951653826560)
              or, more generally
              IPv6Network(int(IPv6Network('2001:db8::'))) ==
                IPv6Network('2001:db8::')

            strict: A boolean. If true, ensure that we have been passed
              A true network address, eg, 2001:db8::1000/124 and not an
              IP address on a network, eg, 2001:db8::1/124.

        Raises:
            AddressValueError: If address isn't a valid IPv6 address.
            NetmaskValueError: If the netmask isn't valid for
              an IPv6 address.
            ValueError: If strict was True and a network address was not
              supplied.
        r�r6c���t��gSr�)rr�s�rr�z&IPv6Network.__init__.<locals>.<lambda>�r�r
N)r�rrhrcrrfr�rrNr�r�r�s     @rr�zIPv6Network.__init__�s����>�,�,�W�5�
��d�*�4�0���(,�(:�(:�4�(@�%���d�o��T�)�)�*���C����%�%��/�� �!7�$�!>�?�?�'2�6�36�t�|�|�3D�4E�(F��$��?�?�t�2�2�Q�6�7����D�J�
�_�_�� 3� 3�
3�4�D�J�4r
c#�K�t|j�}t|j�}t|dz|dz�D]}|j	|����y�w)z�Generate Iterator over usable hosts in a network.

          This is like __iter__ except it doesn't return the
          Subnet-Router anycast address.

        r6Nr�r�s    rr�zIPv6Network.hosts�sW�����d�*�*�+����.�.�/�	��w��{�I��M�2�	)�A��%�%�a�(�(�	)�s�AAc�^�|jjxr|jjSr)rhrr^rzs rrzIPv6Network.is_site_local�s,���$�$�2�2�5��&�&�4�4�	6r
Nr�)
rr	r
rrr�r�r�r�rrr
rrr�s-��	�!�N�.5�`
)��6��6r
rc��eZdZed�Zed�Zed�ed�ed�ed�ed�ed�ed	�ed
�ed�ed�g
Zed�ed
�ed�ed�ed�ed�gZed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed�ed �gZed!�Z	y")#�_IPv6Constantsz	fe80::/10zff00::/8z::1/128z::/128z
::ffff:0:0/96z64:ff9b:1::/48z100::/64z	2001::/23z
2001:db8::/32z	2002::/16zfc00::/7z
2001:1::1/128z
2001:1::2/128z2001:3::/32z2001:4:112::/48z2001:20::/28z2001:30::/28z::/8z100::/8z200::/7z400::/6z800::/5z1000::/4z4000::/3z6000::/3z8000::/3zA000::/3zC000::/3zE000::/4zF000::/5zF800::/6zFE00::/9z	fec0::/10N)
rr	r
rr�r�rIrKrrrr
rr=r=
	s6��$�[�1��$�Z�0��
	�I���H���O�$��$�%��J���K� ��O�$��K� ��J���K� �
��	�O�$��O�$��M�"��%�&��N�#��N�#�
$� �	�F��[��3��I���I� 6��I���J� 7��J���Z�!8��J���Z�!8��J���Z�!8��J���Z�!8��J��	��%�[�1�r
r=r�)%r�__version__rVr}rrrrrrr"r(r,r4r?rErUrbrnrurwr��total_orderingrKrprZrHr\rr rr�r�rr!rr=rr
r�<module>r@s�������
�
�
�
�0�
�0�0�
�0�S�:S�:U�DC�(
C� ��(
:� 4�n.�b36�l�2o,�o,�d��
���hN�>�hN��hN�V���H4�>�H4��H4�V��
)���J�J�ZI:�'�<�I:�X@)�K�@)�FO%�'�<�O%�d#2�#2�L(���'���l�l�^	f:�'�<�f:�RH:�K�H:�VY6�'�<�Y6�x*2�*2�Z(���'��r

Zerion Mini Shell 1.0