404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.147.126.199: ~ $
�
i f��@s�dZdZddlZdZdZGdd�de�ZGdd	�d	e�Zd
d�Zdd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�ZGd#d$�d$�ZejGd%d&�d&e��ZejGd'd(�d(e��ZGd)d*�d*�ZGd+d,�d,ee�ZGd-d.�d.e�ZGd/d0�d0ee�ZGd1d2�d2�ZGd3d4�d4ee�ZGd5d6�d6e�ZGd7d8�d8ee�ZdS)9z�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@seZdZdZdS)�AddressValueErrorz%A Value Error related to the address.N)�__name__�
__module__�__qualname__�__doc__�r	r	�./opt/alt/python34/lib64/python3.4/ipaddress.pyrsrc@seZdZdZdS)�NetmaskValueErrorz%A Value Error related to the netmask.N)rrrrr	r	r	r
rsrcCsfyt|�SWnttfk
r(YnXyt|�SWnttfk
rQYnXtd|��dS)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

    z0%r does not appear to be an IPv4 or IPv6 addressN)�IPv4Addressrr�IPv6Address�
ValueError)�addressr	r	r
�
ip_addresssrTcCslyt||�SWnttfk
r+YnXyt||�SWnttfk
rWYnXtd|��dS)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.

    z0%r does not appear to be an IPv4 or IPv6 networkN)�IPv4Networkrr�IPv6Networkr)r�strictr	r	r
�
ip_network9srcCsfyt|�SWnttfk
r(YnXyt|�SWnttfk
rQYnXtd|��dS)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.

    z2%r does not appear to be an IPv4 or IPv6 interfaceN)�
IPv4Interfacerr�
IPv6Interfacer)rr	r	r
�ip_interfaceWsrc	Cs/y|jdd�SWntd��YnXdS)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.

    ��bigz&Address negative or too large for IPv4N)�to_bytesr)rr	r	r
�v4_int_to_packedzsrc	Cs/y|jdd�SWntd��YnXdS)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.

    �rz&Address negative or too large for IPv6N)rr)rr	r	r
�v6_int_to_packed�s
rcCs>t|�jd�}t|�dkr:td|��n|S)zAHelper to split the netmask and raise AddressValueError if needed�/�zOnly one '/' permitted in %r)�str�split�lenr)r�addrr	r	r
�_split_optional_netmask�sr$cCsS|d}}x8|dd�D]&}|j|jdkrD|}qPqW||fS)z�Find a sequence of IPv#Address.

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

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

    r�N)�_ip)�	addresses�first�last�ipr	r	r
�_find_address_range�s
	r+cCs=|dkr|Sx&t|�D]}||?d@r|SqW|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.

    rr%)�range)Znumber�bits�ir	r	r
�_count_righthand_zero_bits�sr/ccs^t|t�ot|t�s-td��n|j|jkrXtd||f��n||krstd��n|jdkr�t}n$|jdkr�t}ntd��|j}|j}|j}x�||krYt	t
||�||dj�d�}|d|||f�}|V|d|>7}|d|jkrGPn|j
|�}q�Wd	S)
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 networksz%%s and %s are not of the same versionz*last IP address must be greater than firstr�zunknown IP versionr%z%s/%dN)�
isinstance�_BaseAddress�	TypeError�versionrrr�_max_prefixlenr&�minr/�
bit_length�	_ALL_ONES�	__class__)r(r)r*Zip_bitsZ	first_intZlast_intZnbitsZnetr	r	r
�summarize_address_range�s2					r:cCs�x�d}g}d}x�|D]�}|s>|}|j|�q|j|jkrk|j|jkrkd}q|t|j�j��dkr�|j�|d<}d}q|}|j|�qW|}|s|SqWdS)avLoops 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_recursive([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.

    NFTr%���)�append�network_address�broadcast_address�list�supernet�subnets)r'Z	last_addrZ	ret_arrayZ	optimizedZcur_addrr	r	r
�_collapse_addresses_recursives&
	"	rBcCs�d}g}g}g}x3|D]+}t|t�r}|rm|dj|jkrmtd||df��n|j|�q|j|jkr|r�|dj|jkr�td||d	f��ny|j|j�WqJtk
r|j|j	�YqJXq|r=|d
j|jkr=td||df��n|j|�qWt
t|��}t
t|��}x[|t|�kr�t
||d��\}}|j|�d}|jt||��quWttt
||dtj���S)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.

    rr%z%%s and %s are not of the same versionN�keyr;r;r;r;r;r;)r1r2�_versionr3r<�
_prefixlenr5r*�AttributeErrorr=�sorted�setr"r+�index�extendr:�iterrB�_BaseNetwork�_get_networks_key)r'r.ZaddrsZipsZnetsr*r(r)r	r	r
�collapse_addresses5s<

	rNcCs6t|t�r|j�St|t�r2|j�StS)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.

    )r1rLrMr2�_get_address_key�NotImplemented)�objr	r	r
�get_mixed_type_keyns


rRc@s�eZdZdZedd��Zedd��Zedd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)�_IPAddressBasezThe mother class.cCs
|j�S)z:Return the longhand version of the IP address as a string.)�_explode_shorthand_ip_string)�selfr	r	r
�exploded�sz_IPAddressBase.explodedcCs
t|�S)z;Return the shorthand version of the IP address as a string.)r )rUr	r	r
�
compressed�sz_IPAddressBase.compressedcCs#dt|�f}t|��dS)Nz%200s has no version specified)�type�NotImplementedError)rU�msgr	r	r
r4�sz_IPAddressBase.versioncCsi|dkr.d}t|||jf��n||jkred}t|||j|jf��ndS)Nrz-%d (< 0) is not permitted as an IPv%d addressz2%d (>= 2**%d) is not permitted as an IPv%d address)rrDr8r5)rUrrZr	r	r
�_check_int_address�sz!_IPAddressBase._check_int_addresscCsDt|�}||kr@d}t|||||jf��ndS)Nz6%r (len %d != %d) is not permitted as an IPv%d address)r"rrD)rUrZexpected_lenZaddress_lenrZr	r	r
�_check_packed_address�s
z$_IPAddressBase._check_packed_addresscCs|j|j|?AS)z�Turn the prefix length into a bitwise netmask

        Args:
            prefixlen: An integer, the prefix length.

        Returns:
            An integer.

        )r8)rU�	prefixlenr	r	r
�_ip_int_from_prefix�s
z"_IPAddressBase._ip_int_from_prefixc	Cst||j�}|j|}||?}d|>d}||kr{|jd}|j|d�}d}t||��n|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
        r%�rz&Netmask pattern %r mixes zeroes & ones)r/r5rr)	rU�ip_intZtrailing_zeroesr]Zleading_onesZall_onesZbyteslenZdetailsrZr	r	r
�_prefix_from_ip_int�s


z"_IPAddressBase._prefix_from_ip_intcCsd|}t|�d�dS)Nz%r is not a valid netmask)r)rUZnetmask_strrZr	r	r
�_report_invalid_netmask�s
z&_IPAddressBase._report_invalid_netmaskcCs�tjj|�s"|j|�nyt|�}Wntk
rS|j|�YnXd|kon|jkns�|j|�n|S)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)�_BaseV4�_DECIMAL_DIGITS�
issupersetrb�intrr5)rUZ
prefixlen_strr]r	r	r
�_prefix_from_prefix_string�s
z)_IPAddressBase._prefix_from_prefix_stringcCs�y|j|�}Wntk
r4|j|�YnXy|j|�SWntk
rZYnX||jN}y|j|�SWntk
r�|j|�YnXdS)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_stringrrbrarr8)rU�ip_strr`r	r	r
�_prefix_from_ip_string�s




z%_IPAddressBase._prefix_from_ip_stringN)rrrr�propertyrVrWr4r[r\r^rarbrgrjr	r	r	r
rS�s	rSc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)r2z�A generic IP object.

    This IP class contains the version independent methods which are
    used by single IP addresses.
    cCs9t|t�r5dt|�kr5td|��ndS)NrzUnexpected '/' in %r)r1�bytesr r)rUrr	r	r
�__init__sz_BaseAddress.__init__cCs|jS)N)r&)rUr	r	r
�__int__sz_BaseAddress.__int__cCsCy&|j|jko$|j|jkSWntk
r>tSYnXdS)N)r&rDrFrP)rU�otherr	r	r
�__eq__s

z_BaseAddress.__eq__cCsdt|t�stS|j|jkr>td||f��n|j|jkr`|j|jkSdS)Nz%%s and %s are not of the same versionF)r1r2rPrDr3r&)rUror	r	r
�__lt__$sz_BaseAddress.__lt__cCs*t|t�stS|jt|�|�S)N)r1rfrPr9)rUror	r	r
�__add__0sz_BaseAddress.__add__cCs*t|t�stS|jt|�|�S)N)r1rfrPr9)rUror	r	r
�__sub__5sz_BaseAddress.__sub__cCsd|jjt|�fS)Nz%s(%r))r9rr )rUr	r	r
�__repr__:sz_BaseAddress.__repr__cCst|j|j��S)N)r �_string_from_ip_intr&)rUr	r	r
�__str__=sz_BaseAddress.__str__cCsttt|j���S)N)�hash�hexrfr&)rUr	r	r
�__hash__@sz_BaseAddress.__hash__cCs
|j|fS)N)rD)rUr	r	r
rOCsz_BaseAddress._get_address_keyN)rrrrrmrnrprqrrrsrtrvryrOr	r	r	r
r2sr2c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zedd��Zedd��Zedd��Zed d!��Zed"d#��Zed$d%��Zed&d'��Zd(d)�Zd*d+�Zd,d-�Zd.d/d0d1�Zd.d/d2d3�Zed4d5��Zed6d7��Zed8d9��Zed:d;��Z ed<d=��Z!ed>d?��Z"ed@dA��Z#d/S)BrLz~A generic IP network object.

    This IP class contains the version independent methods which are
    used by networks.

    cCs
i|_dS)N)�_cache)rUrr	r	r
rmPsz_BaseNetwork.__init__cCsd|jjt|�fS)Nz%s(%r))r9rr )rUr	r	r
rtSsz_BaseNetwork.__repr__cCsd|j|jfS)Nz%s/%d)r=r])rUr	r	r
rvVsz_BaseNetwork.__str__ccsNt|j�}t|j�}x)t|d|�D]}|j|�Vq2WdS)z�Generate Iterator over usable hosts in a network.

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

        r%N)rfr=r>r,�_address_class)rU�network�	broadcast�xr	r	r
�hostsYsz_BaseNetwork.hostsccsNt|j�}t|j�}x)t||d�D]}|j|�Vq2WdS)Nr%)rfr=r>r,r{)rUr|r}r~r	r	r
�__iter__esz_BaseNetwork.__iter__cCs�t|j�}t|j�}|dkrT|||krCt�n|j||�S|d7}|||krwt�n|j||�SdS)Nrr%)rfr=r>�
IndexErrorr{)rU�nr|r}r	r	r
�__getitem__ks	
	z_BaseNetwork.__getitem__cCs�t|t�stS|j|jkr>td||f��n|j|jkr`|j|jkS|j|jkr�|j|jkSdS)Nz%%s and %s are not of the same versionF)r1rLrPrDr3r=�netmask)rUror	r	r
rqxsz_BaseNetwork.__lt__cCsayD|j|jkoB|j|jkoBt|j�t|j�kSWntk
r\tSYnXdS)N)rDr=rfr�rFrP)rUror	r	r
rp�s 
z_BaseNetwork.__eq__cCs tt|j�t|j�A�S)N)rwrfr=r�)rUr	r	r
ry�sz_BaseNetwork.__hash__cCs`|j|jkrdSt|t�r)dSt|j�t|j�koYt|j�kSSdS)NF)rDr1rLrfr=r&r>)rUror	r	r
�__contains__�s z_BaseNetwork.__contains__cCs:|j|kp9|j|kp9|j|kp9|j|kS)z*Tell if self is partly contained in other.)r=r>)rUror	r	r
�overlaps�sz_BaseNetwork.overlapscCsW|jjd�}|dkrS|jt|j�t|j�B�}||jd<n|S)Nr>)rz�getr{rfr=�hostmask)rUr~r	r	r
r>�sz_BaseNetwork.broadcast_addresscCsQ|jjd�}|dkrM|jt|j�|jA�}||jd<n|S)Nr�)rzr�r{rfr�r8)rUr~r	r	r
r��s
z_BaseNetwork.hostmaskcCsd|j|jfS)Nz%s/%d)r=rE)rUr	r	r
�with_prefixlen�sz_BaseNetwork.with_prefixlencCsd|j|jfS)Nz%s/%s)r=r�)rUr	r	r
�with_netmask�sz_BaseNetwork.with_netmaskcCsd|j|jfS)Nz%s/%s)r=r�)rUr	r	r
�
with_hostmask�sz_BaseNetwork.with_hostmaskcCst|j�t|j�dS)z&Number of hosts in the current subnet.r%)rfr>r=)rUr	r	r
�
num_addresses�sz_BaseNetwork.num_addressescCs#dt|�f}t|��dS)Nz%%200s has no associated address class)rXrY)rUrZr	r	r
r{�sz_BaseNetwork._address_classcCs|jS)N)rE)rUr	r	r
r]�sz_BaseNetwork.prefixlenccs�|j|jks+td||f��nt|t�sMtd|��n|j|jkon|j|jks�td||f��n||kr�t�n|jd|j|j	f�}|j
�\}}x�||kr�||kr�|j|jkr)|j|jkr)|V|j
�\}}q�|j|jkrg|j|jkrg|V|j
�\}}q�td|||f��q�W||kr�|Vn-||kr�|Vntd|||f��dS)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')
            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')
            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.

        z%%s and %s are not of the same versionz%s is not a network objectz%s not contained in %sz%s/%sz3Error performing exclusion: s1: %s s2: %s other: %sN)rDr3r1rLr=r>r�
StopIterationr9r]rA�AssertionError)rUro�s1�s2r	r	r
�address_exclude�s<$	z_BaseNetwork.address_excludecCs�|j|jkr+td||f��n|j|jkrAdS|j|jkrWdS|j|jkrmdS|j|jkr�dSdS)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.

        z"%s and %s are not of the same typer%rr;r;)rDr3r=r�)rUror	r	r
�compare_networkss!z_BaseNetwork.compare_networkscCs|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().

        )rDr=r�)rUr	r	r
rMOsz_BaseNetwork._get_networks_keyr%NccsL|j|jkr|VdS|dk	rp||jkrEtd��n|dkr`td��n||j}n|dkr�td��n|j|}||jkr�td||f��n|jd|j|j|f�}|V|}xW|j}||jkr
dS|jt|�d�}|jd||f�}|Vq�WdS)	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 longerr%z(cannot set prefixlen_diff and new_prefixrzprefix length diff must be > 0z0prefix length diff %d is invalid for netblock %sz%s/%s)rEr5rr9r=r>r{rf)rU�prefixlen_diff�
new_prefixZ
new_prefixlenr(Zcurrentr}Znew_addrr	r	r
rAYs:
		
z_BaseNetwork.subnetscCs�|jdkr|S|dk	rh||jkr=td��n|dkrXtd��n|j|}n|j|dkr�td|j|f��n|jd|j|j|fdd	�}|jd|j|jf�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)

        rNznew prefix must be shorterr%z(cannot set prefixlen_diff and new_prefixz;current prefixlen is %d, cannot have a prefixlen_diff of %dz%s/%drF)rErr]r9r=)rUr�r��tr	r	r
r@�s 	z_BaseNetwork.supernetcCs|jjo|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.

        )r=�is_multicastr>)rUr	r	r
r��s	z_BaseNetwork.is_multicastcCs|jjo|jjS)z�Test if the address is otherwise IETF reserved.

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

        )r=�is_reservedr>)rUr	r	r
r��s	z_BaseNetwork.is_reservedcCs|jjo|jjS)z�Test if the address is reserved for link-local.

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

        )r=�
is_link_localr>)rUr	r	r
r��sz_BaseNetwork.is_link_localcCs|jjo|jjS)z�Test if this address is allocated for private networks.

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

        )r=�
is_privater>)rUr	r	r
r��s	z_BaseNetwork.is_privatecCs|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.

        )r�)rUr	r	r
�	is_global�s	z_BaseNetwork.is_globalcCs|jjo|jjS)z�Test if the address is unspecified.

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

        )r=�is_unspecifiedr>)rUr	r	r
r��s	z_BaseNetwork.is_unspecifiedcCs|jjo|jjS)z�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.

        )r=�is_loopbackr>)rUr	r	r
r�s	z_BaseNetwork.is_loopback)$rrrrrmrtrvrr�r�rqrpryr�r�rkr>r�r�r�r�r�r{r]r�r�rMrAr@r�r�r�r�r�r�r�r	r	r	r
rLGs@

	N0
>)rLc
@s�eZdZdZdedZed�Zed!�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zedd��Zedd��Zd S)"rczyBase IPv4 object.

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

    rr%�
0123456789���������rrcCsd|_t|_dS)Nr)rD�
IPV4LENGTHr5)rUrr	r	r
rm#s	z_BaseV4.__init__cCs
t|�S)N)r )rUr	r	r
rT'sz$_BaseV4._explode_shorthand_ip_stringcCs�|std��n|jd�}t|�dkrItd|��ny tjt|j|�d�SWn>tk
r�}ztd||f�d�WYdd}~XnXdS)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.

        zAddress cannot be empty�.rzExpected 4 octets in %rrz%s in %rN)rr!r"rf�
from_bytes�map�_parse_octetr)rUriZoctets�excr	r	r
rh*s
 z_BaseV4._ip_int_from_stringcCs�|std��n|jj|�s@d}t||��nt|�dkrkd}t||��nt|d�}|dkr�|ddkr�d	}t||��n|d
kr�td|��n|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 %r�
�r�0z3Ambiguous (octal/decimal) value in %r not permittedr�zOctet %d (> 255) not permitted)rrdrer"rf)rUZ	octet_strrZZ	octet_intr	r	r
r�Cs
z_BaseV4._parse_octetcCs"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.

        r�rr)�joinr�r r)rUr`r	r	r
rugs
z_BaseV4._string_from_ip_intcCs�|jd�}t|�dkr�y.x'|D]}t|�|jkr+dSq+WWntk
rgdSYnXx>t|�D]0\}}|dkru|||dkrudSquWdSyt|�}Wntk
r�dSYnXd|ko�|jkSS)z�Verify that the netmask is valid.

        Args:
            netmask: A string, either a prefix or dotted decimal
              netmask.

        Returns:
            A boolean, True if the prefix represents a valid IPv4
            netmask.

        r�rFrr%T)r!r"rf�_valid_mask_octetsr�	enumerater5)rUr��maskr~�idx�yr	r	r
�_is_valid_netmaskss"

	 
	z_BaseV4._is_valid_netmaskcs�|jd�}y&�fdd�tt|�D�}Wntk
rMdSYnXt|�t|�krjdS|d|dkr�dSdS)	z�Test if the IP string is a hostmask (rather than a netmask).

        Args:
            ip_str: A string, the potential hostmask.

        Returns:
            A boolean, True if the IP string is a hostmask.

        r�cs%g|]}|�jkr|�qSr	)r�)�.0r~)rUr	r
�
<listcomp>�s	z(_BaseV4._is_hostmask.<locals>.<listcomp>Frr%Tr;)r!r�rfrr")rUrir-�partsr	)rUr
�_is_hostmask�s
&
	z_BaseV4._is_hostmaskcCs|jS)N)r5)rUr	r	r
�
max_prefixlen�sz_BaseV4.max_prefixlencCs|jS)N)rD)rUr	r	r
r4�sz_BaseV4.versionN)	r�r�r�r�r�r�r�rr)rrrrr�r8�	frozensetrdr�rmrTrhr�rur�r�rkr�r4r	r	r	r
rcs$rcc@s�eZdZdZdd�Zedd��Zedd��Zeej	�dd	���Z
ed
d��Zedd
��Zedd��Z
edd��ZdS)rz/Represent and manipulate single IPv4 Addresses.cCs�tj||�tj||�t|t�rI|j|�||_dSt|t�r�|j|d�tj	|d�|_dSt
|�}|j|�|_dS)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.

        Nrr)r2rmrcr1rfr[r&rlr\r�r rh)rUr�addr_strr	r	r
rm�s
	zIPv4Address.__init__cCs
t|j�S)z*The binary representation of this address.)rr&)rUr	r	r
�packed�szIPv4Address.packedcCstd�}||kS)z�Test if the address is otherwise IETF reserved.

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

        z240.0.0.0/4)r)rUZreserved_networkr	r	r
r��s	zIPv4Address.is_reservedcCs�|td�kp�|td�kp�|td�kp�|td�kp�|td�kp�|td�kp�|td�kp�|td�kp�|td	�kp�|td
�kp�|td�kp�|td�kp�|td
�kp�|td�kS)z�Test if this address is allocated for private networks.

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

        z	0.0.0.0/8z
10.0.0.0/8z127.0.0.0/8z169.254.0.0/16z
172.16.0.0/12z192.0.0.0/29z192.0.0.170/31z192.0.2.0/24z192.168.0.0/16z
198.18.0.0/15z198.51.100.0/24z203.0.113.0/24z240.0.0.0/4z255.255.255.255/32)r)rUr	r	r
r��s
zIPv4Address.is_privatecCstd�}||kS)z�Test if the address is reserved for multicast use.

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

        z224.0.0.0/4)r)rU�multicast_networkr	r	r
r�s	zIPv4Address.is_multicastcCstd�}||kS)z�Test if the address is unspecified.

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

        z0.0.0.0)r)rUZunspecified_addressr	r	r
r�s	zIPv4Address.is_unspecifiedcCstd�}||kS)z�Test if the address is a loopback address.

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

        z127.0.0.0/8)r)rUZloopback_networkr	r	r
r�szIPv4Address.is_loopbackcCstd�}||kS)z�Test if the address is reserved for link-local.

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

        z169.254.0.0/16)r)rU�linklocal_networkr	r	r
r�&szIPv4Address.is_link_localN)rrrrrmrkr�r��	functools�	lru_cacher�r�r�r�r�r	r	r	r
r�s$rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	ed
d��Z
edd��Zedd��ZdS)rcCs�t|ttf�rGtj||�t|j�|_|j|_	dSt
|�}tj||d�t|dd�|_|jj	|_	|jj|_|jj|_dS)NrrF)
r1rlrfrrmrr&r|r5rEr$r�r�)rUrr#r	r	r
rm4szIPv4Interface.__init__cCs d|j|j�|jjfS)Nz%s/%d)rur&r|r])rUr	r	r
rvDszIPv4Interface.__str__cCsZtj||�}|s%|tkr)|Sy|j|jkSWntk
rUdSYnXdS)NF)rrprPr|rF)rUro�
address_equalr	r	r
rpHs
zIPv4Interface.__eq__cCsStj||�}|tkr"tSy|j|jkSWntk
rNdSYnXdS)NF)rrqrPr|rF)rUro�address_lessr	r	r
rqTs
zIPv4Interface.__lt__cCs|j|jAt|jj�AS)N)r&rErfr|r=)rUr	r	r
ry_szIPv4Interface.__hash__cCs
t|j�S)N)rr&)rUr	r	r
r*bszIPv4Interface.ipcCsd|j|j�|jfS)Nz%s/%s)rur&rE)rUr	r	r
r�fszIPv4Interface.with_prefixlencCsd|j|j�|jfS)Nz%s/%s)rur&r�)rUr	r	r
r�kszIPv4Interface.with_netmaskcCsd|j|j�|jfS)Nz%s/%s)rur&r�)rUr	r	r
r�pszIPv4Interface.with_hostmaskN)
rrrrmrvrprqryrkr*r�r�r�r	r	r	r
r2src@sIeZdZdZeZddd�Zeej	�dd���Z
dS)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

    TcCs�tj||�tj||�t|t�r`t|�|_|j|_t|j	�|_
dSt|t�r�t|�|_|j|_t|j	�|_
dSt|�}t|j
|d��|_t|�dkr"y|j|d�|_Wq.tk
r|j|d�|_Yq.Xn|j|_t|j|j��|_
|r�tt|j�t|j
�@�|jkr�td|��q�ntt|j�t|j
�@�|_|j|jdkr�|j|_ndS)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.0.2/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.

        Nrrr%z%s has host bits set)rcrmrLr1rlrr=r5rEr8r�rfr$rhr"rgrrjr^rr�r)rUrrr#r	r	r
rm�s:&
zIPv4Network.__init__cCs3|jtd�ko'|jtd�ko2|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.

        z
100.64.0.0/10)r=rr>r�)rUr	r	r
r��s
zIPv4Network.is_globalN)rrrrrr{rmrkr�r�r�r	r	r	r
rvs
Trc@s�eZdZdZdedZdZed�Zdd�Z	dd	�Z
d
d�Zdd
�Zddd�Z
dd�Zedd��Zedd��ZdS)�_BaseV6zyBase IPv6 object.

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

    rr%r_Z0123456789ABCDEFabcdefcCsd|_t|_dS)Nr0)rD�
IPV6LENGTHr5)rUrr	r	r
rm�s	z_BaseV6.__init__cCs�|std��n|jd�}d}t|�|kr[d||f}t|��nd|dkr�yt|j��j}Wn>tk
r�}ztd||f�d�WYdd}~XnX|jd	|d
?d@�|jd	|d@�n|jd}t|�|kr8d|d|f}t|��nd}xYtdt|�d�D]>}	||	sX|dk	r�d
|}t|��n|	}qXqXW|dk	rr|}
t|�|d}|ds�|
d8}
|
r�d}t||��q�n|ds,|d8}|r,d}t||��q,n|j|
|}|dkrd}t||jd|f��qn�t|�|jkr�d}t||j|f��n|ds�d}t||��n|ds�d}t||��nt|�}
d}d}y�d}
x5t|
�D]'}	|
d
K}
|
|j	||	�O}
qW|
d
|K}
x9t|d�D]'}	|
d
K}
|
|j	||	�O}
qgW|
SWn>t
k
r�}ztd||f�d�WYdd}~XnXdS)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.

        zAddress cannot be empty�:r�z At least %d parts expected in %rr�r%z%s in %rNz%xri��z!At most %d colons permitted in %rz At most one '::' permitted in %rrz0Leading ':' only permitted as part of '::' in %rz1Trailing ':' only permitted as part of '::' in %rz/Expected at most %d other parts with '::' in %rz,Exactly %d parts expected without '::' in %rr;r;r;)rr!r"r�popr&r<�
_HEXTET_COUNTr,�
_parse_hextetr)rUrir�Z
_min_partsrZZipv4_intr�Z
_max_partsZ
skip_indexr.Zparts_hiZparts_loZ
parts_skippedr`r	r	r
rh�s�
,
 






#



z_BaseV6._ip_int_from_stringcCs]|jj|�s%td|��nt|�dkrPd}t||��nt|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 %rrz$At most 4 characters permitted in %rr)�_HEX_DIGITSrerr"rf)rUZ
hextet_strrZr	r	r
r�asz_BaseV6._parse_hextetc	Cs�d}d}d}d}xot|�D]a\}}|dkrz|d7}|dkr\|}n||kr�|}|}q�q%d}d}q%W|dkr�||}|t|�kr�|dg7}ndg|||�<|dkr�dg|}q�n|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.

        r%rr��r;r;r;r;)r�r")	rU�hextetsZbest_doublecolon_startZbest_doublecolon_lenZdoublecolon_startZdoublecolon_lenrIZhextetZbest_doublecolon_endr	r	r
�_compress_hextetszs.
	
z_BaseV6._compress_hextetsNcs�|dkrt|j�}n||jkr<td��nd|��fdd�tddd�D�}|j|�}d	j|�S)
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.

        NzIPv6 address is too largez%032xcs1g|]'}dt�||d�d��qS)z%xrr)rf)r�r~)�hex_strr	r
r��s	z/_BaseV6._string_from_ip_int.<locals>.<listcomp>rrrr�)rfr&r8rr,r�r�)rUr`r�r	)r�r
ru�s

%z_BaseV6._string_from_ip_intcs�t|t�r!t|j�}n-t|t�rBt|j�}nt|�}|j|�}d|��fdd�tddd�D�}t|ttf�r�ddj	|�|j
fSdj	|�S)	z�Expand a shortened IPv6 address.

        Args:
            ip_str: A string, the IPv6 address.

        Returns:
            A string, the expanded IPv6 address.

        z%032xcs$g|]}�||d��qS)rr	)r�r~)r�r	r
r��s	z8_BaseV6._explode_shorthand_ip_string.<locals>.<listcomp>rrrz%s/%dr�)r1rr r=rr*rhr,rLr�rE)rUrir`r�r	)r�r
rT�s

%z$_BaseV6._explode_shorthand_ip_stringcCs|jS)N)r5)rUr	r	r
r��sz_BaseV6.max_prefixlencCs|jS)N)rD)rUr	r	r
r4�sz_BaseV6.version)rrrrr�r8r�r�r�rmrhr�r�rurTrkr�r4r	r	r	r
r��sg/r�c@seZdZdZdd�Zedd��Zedd��Zedd	��Zed
d��Z	edd
��Z
eej�dd���Z
edd��Zedd��Zedd��Zedd��Zedd��Zedd��ZdS)r
z/Represent and manipulate single IPv6 Addresses.cCs�tj||�tj||�t|t�rI|j|�||_dSt|t�r�|j|d�tj	|d�|_dSt
|�}|j|�|_dS)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.

        Nrr)r2rmr�r1rfr[r&rlr\r�r rh)rUrr�r	r	r
rm�s
	zIPv6Address.__init__cCs
t|j�S)z*The binary representation of this address.)rr&)rUr	r	r
r�szIPv6Address.packedcCstd�}||kS)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.

        zff00::/8)r)rUr�r	r	r
r�s	zIPv6Address.is_multicastcs�td�td�td�td�td�td�td�td�td	�td
�td�td�td
�td�td�g}t�fdd�|D��S)z�Test if the address is otherwise IETF reserved.

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

        z::/8z100::/8z200::/7z400::/6z800::/5z1000::/4z4000::/3z6000::/3z8000::/3zA000::/3zC000::/3zE000::/4zF000::/5zF800::/6zFE00::/9c3s|]}�|kVqdS)Nr	)r�r~)rUr	r
�	<genexpr>/sz*IPv6Address.is_reserved.<locals>.<genexpr>)r�any)rUZreserved_networksr	)rUr
r�s	zIPv6Address.is_reservedcCstd�}||kS)z�Test if the address is reserved for link-local.

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

        z	fe80::/10)r)rUr�r	r	r
r�1szIPv6Address.is_link_localcCstd�}||kS)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.

        z	fec0::/10)r)rUZsitelocal_networkr	r	r
�
is_site_local<szIPv6Address.is_site_localcCs�|td�kp�|td�kp�|td�kp�|td�kp�|td�kp�|td�kp�|td�kp�|td�kp�|td	�kp�|td
�kS)z�Test if this address is allocated for private networks.

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

        z::1/128z::/128z
::ffff:0:0/96z100::/64z	2001::/23z2001:2::/48z
2001:db8::/32z2001:10::/28zfc00::/7z	fe80::/10)r)rUr	r	r
r�Ks
zIPv6Address.is_privatecCs|jS)z�Test if this address is allocated for public networks.

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

        )r�)rUr	r	r
r�`s	zIPv6Address.is_globalcCs
|jdkS)z�Test if the address is unspecified.

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

        r)r&)rUr	r	r
r�ks	zIPv6Address.is_unspecifiedcCs
|jdkS)z�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.

        r%)r&)rUr	r	r
r�vs	zIPv6Address.is_loopbackcCs(|jd?dkrdSt|jd@�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.

        ri��Nl��)r&r)rUr	r	r
�ipv4_mapped�s	zIPv6Address.ipv4_mappedcCs@|jd?dkrdSt|jd?d@�t|jd@�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�@l��)r&r)rUr	r	r
�teredo�s
zIPv6Address.teredocCs,|jd?dkrdSt|jd?d@�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�Pl��)r&r)rUr	r	r
�	sixtofour�s	zIPv6Address.sixtofourN)rrrrrmrkr�r�r�r�r�r�r�r�r�r�r�r�r�r�r	r	r	r
r
�s%
r
c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	ed
d��Z
edd��Zedd��Zedd��Z
edd��ZdS)rcCs�t|ttf�rGtj||�t|j�|_|j|_	dSt
|�}tj||d�t|dd�|_|jj|_|jj	|_	|jj|_dS)NrrF)
r1rlrfr
rmrr&r|r5rEr$r�r�)rUrr#r	r	r
rm�szIPv6Interface.__init__cCs d|j|j�|jjfS)Nz%s/%d)rur&r|r])rUr	r	r
rv�szIPv6Interface.__str__cCsZtj||�}|s%|tkr)|Sy|j|jkSWntk
rUdSYnXdS)NF)r
rprPr|rF)rUror�r	r	r
rp�s
zIPv6Interface.__eq__cCsStj||�}|tkr"tSy|j|jkSWntk
rNdSYnXdS)NF)r
rqrPr|rF)rUror�r	r	r
rq�s
zIPv6Interface.__lt__cCs|j|jAt|jj�AS)N)r&rErfr|r=)rUr	r	r
ry�szIPv6Interface.__hash__cCs
t|j�S)N)r
r&)rUr	r	r
r*�szIPv6Interface.ipcCsd|j|j�|jfS)Nz%s/%s)rur&rE)rUr	r	r
r��szIPv6Interface.with_prefixlencCsd|j|j�|jfS)Nz%s/%s)rur&r�)rUr	r	r
r��szIPv6Interface.with_netmaskcCsd|j|j�|jfS)Nz%s/%s)rur&r�)rUr	r	r
r��szIPv6Interface.with_hostmaskcCs|jdko|jjS)Nr)r&r|r�)rUr	r	r
r��szIPv6Interface.is_unspecifiedcCs|jdko|jjS)Nr%)r&r|r�)rUr	r	r
r��szIPv6Interface.is_loopbackN)rrrrmrvrprqryrkr*r�r�r�r�r�r	r	r	r
r�src@sIeZdZdZeZddd�Zdd�Zedd��Z	d	S)
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

    TcCs�tj||�tj||�t|t�r`t|�|_|j|_t|j	�|_
dSt|t�r�t|�|_|j|_t|j	�|_
dSt|�}t|j
|d��|_t|�dkr�|j|d�|_n|j|_t|j|j��|_
|ratt|j�t|j
�@�|jkratd|��qantt|j�t|j
�@�|_|j|jdkr�|j|_ndS)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.

        Nrrr%z%s has host bits set)r�rmrLr1rfr
r=r5rEr8r�rlr$rhr"rgr^rr�r)rUrrr#r	r	r
rms4 zIPv6Network.__init__ccsRt|j�}t|j�}x-t|d|d�D]}|j|�Vq6WdS)z�Generate Iterator over usable hosts in a network.

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

        r%N)rfr=r>r,r{)rUr|r}r~r	r	r
rMszIPv6Network.hostscCs|jjo|jjS)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.

        )r=r�r>)rUr	r	r
r�YszIPv6Network.is_site_localN)
rrrrr
r{rmrrkr�r	r	r	r
r�s
Hr) r�__version__r�r�r�rrrrrrrrr$r+r/r:rBrNrRrS�total_orderingr2rLrcrrrr�r
rrr	r	r	r
�<module>	s@#809�:����Ds��J

Filemanager

Name Type Size Permission Actions
__future__.cpython-34.pyc File 4.07 KB 0644
__future__.cpython-34.pyo File 4.07 KB 0644
__phello__.foo.cpython-34.pyc File 134 B 0644
__phello__.foo.cpython-34.pyo File 134 B 0644
_bootlocale.cpython-34.pyc File 1.02 KB 0644
_bootlocale.cpython-34.pyo File 1016 B 0644
_collections_abc.cpython-34.pyc File 23.39 KB 0644
_collections_abc.cpython-34.pyo File 23.39 KB 0644
_compat_pickle.cpython-34.pyc File 7.33 KB 0644
_compat_pickle.cpython-34.pyo File 7.25 KB 0644
_dummy_thread.cpython-34.pyc File 4.71 KB 0644
_dummy_thread.cpython-34.pyo File 4.71 KB 0644
_markupbase.cpython-34.pyc File 8.72 KB 0644
_markupbase.cpython-34.pyo File 8.54 KB 0644
_osx_support.cpython-34.pyc File 10.38 KB 0644
_osx_support.cpython-34.pyo File 10.38 KB 0644
_pyio.cpython-34.pyc File 63.41 KB 0644
_pyio.cpython-34.pyo File 63.39 KB 0644
_sitebuiltins.cpython-34.pyc File 3.59 KB 0644
_sitebuiltins.cpython-34.pyo File 3.59 KB 0644
_strptime.cpython-34.pyc File 15.41 KB 0644
_strptime.cpython-34.pyo File 15.41 KB 0644
_sysconfigdata.cpython-34.pyc File 24.49 KB 0644
_sysconfigdata.cpython-34.pyo File 24.49 KB 0644
_threading_local.cpython-34.pyc File 6.78 KB 0644
_threading_local.cpython-34.pyo File 6.78 KB 0644
_weakrefset.cpython-34.pyc File 8.27 KB 0644
_weakrefset.cpython-34.pyo File 8.27 KB 0644
abc.cpython-34.pyc File 7.69 KB 0644
abc.cpython-34.pyo File 7.64 KB 0644
aifc.cpython-34.pyc File 27.26 KB 0644
aifc.cpython-34.pyo File 27.26 KB 0644
antigravity.cpython-34.pyc File 847 B 0644
antigravity.cpython-34.pyo File 847 B 0644
argparse.cpython-34.pyc File 64.33 KB 0644
argparse.cpython-34.pyo File 64.17 KB 0644
ast.cpython-34.pyc File 12.07 KB 0644
ast.cpython-34.pyo File 12.07 KB 0644
asynchat.cpython-34.pyc File 8.16 KB 0644
asynchat.cpython-34.pyo File 8.16 KB 0644
asyncore.cpython-34.pyc File 17.54 KB 0644
asyncore.cpython-34.pyo File 17.54 KB 0644
base64.cpython-34.pyc File 17.87 KB 0644
base64.cpython-34.pyo File 17.67 KB 0644
bdb.cpython-34.pyc File 18.26 KB 0644
bdb.cpython-34.pyo File 18.26 KB 0644
binhex.cpython-34.pyc File 13.22 KB 0644
binhex.cpython-34.pyo File 13.22 KB 0644
bisect.cpython-34.pyc File 2.79 KB 0644
bisect.cpython-34.pyo File 2.79 KB 0644
bz2.cpython-34.pyc File 14.8 KB 0644
bz2.cpython-34.pyo File 14.8 KB 0644
cProfile.cpython-34.pyc File 4.51 KB 0644
cProfile.cpython-34.pyo File 4.51 KB 0644
calendar.cpython-34.pyc File 26.92 KB 0644
calendar.cpython-34.pyo File 26.92 KB 0644
cgi.cpython-34.pyc File 29.13 KB 0644
cgi.cpython-34.pyo File 29.13 KB 0644
cgitb.cpython-34.pyc File 10.8 KB 0644
cgitb.cpython-34.pyo File 10.8 KB 0644
chunk.cpython-34.pyc File 5.15 KB 0644
chunk.cpython-34.pyo File 5.15 KB 0644
cmd.cpython-34.pyc File 13.14 KB 0644
cmd.cpython-34.pyo File 13.14 KB 0644
code.cpython-34.pyc File 9.47 KB 0644
code.cpython-34.pyo File 9.47 KB 0644
codecs.cpython-34.pyc File 34.31 KB 0644
codecs.cpython-34.pyo File 34.31 KB 0644
codeop.cpython-34.pyc File 6.31 KB 0644
codeop.cpython-34.pyo File 6.31 KB 0644
colorsys.cpython-34.pyc File 3.57 KB 0644
colorsys.cpython-34.pyo File 3.57 KB 0644
compileall.cpython-34.pyc File 7.21 KB 0644
compileall.cpython-34.pyo File 7.21 KB 0644
configparser.cpython-34.pyc File 43.83 KB 0644
configparser.cpython-34.pyo File 43.83 KB 0644
contextlib.cpython-34.pyc File 10.13 KB 0644
contextlib.cpython-34.pyo File 10.13 KB 0644
copy.cpython-34.pyc File 7.87 KB 0644
copy.cpython-34.pyo File 7.79 KB 0644
copyreg.cpython-34.pyc File 4.5 KB 0644
copyreg.cpython-34.pyo File 4.46 KB 0644
crypt.cpython-34.pyc File 2.38 KB 0644
crypt.cpython-34.pyo File 2.38 KB 0644
csv.cpython-34.pyc File 12.69 KB 0644
csv.cpython-34.pyo File 12.69 KB 0644
datetime.cpython-34.pyc File 54.95 KB 0644
datetime.cpython-34.pyo File 53.02 KB 0644
decimal.cpython-34.pyc File 168.48 KB 0644
decimal.cpython-34.pyo File 168.48 KB 0644
difflib.cpython-34.pyc File 59.1 KB 0644
difflib.cpython-34.pyo File 59.05 KB 0644
dis.cpython-34.pyc File 14.25 KB 0644
dis.cpython-34.pyo File 14.25 KB 0644
doctest.cpython-34.pyc File 78.23 KB 0644
doctest.cpython-34.pyo File 77.97 KB 0644
dummy_threading.cpython-34.pyc File 1.19 KB 0644
dummy_threading.cpython-34.pyo File 1.19 KB 0644
enum.cpython-34.pyc File 15.96 KB 0644
enum.cpython-34.pyo File 15.96 KB 0644
filecmp.cpython-34.pyc File 8.91 KB 0644
filecmp.cpython-34.pyo File 8.91 KB 0644
fileinput.cpython-34.pyc File 13.96 KB 0644
fileinput.cpython-34.pyo File 13.96 KB 0644
fnmatch.cpython-34.pyc File 3.07 KB 0644
fnmatch.cpython-34.pyo File 3.07 KB 0644
formatter.cpython-34.pyc File 18.47 KB 0644
formatter.cpython-34.pyo File 18.47 KB 0644
fractions.cpython-34.pyc File 18.82 KB 0644
fractions.cpython-34.pyo File 18.82 KB 0644
ftplib.cpython-34.pyc File 32.54 KB 0644
ftplib.cpython-34.pyo File 32.54 KB 0644
functools.cpython-34.pyc File 23.06 KB 0644
functools.cpython-34.pyo File 23.06 KB 0644
genericpath.cpython-34.pyc File 3.41 KB 0644
genericpath.cpython-34.pyo File 3.41 KB 0644
getopt.cpython-34.pyc File 6.58 KB 0644
getopt.cpython-34.pyo File 6.53 KB 0644
getpass.cpython-34.pyc File 4.52 KB 0644
getpass.cpython-34.pyo File 4.52 KB 0644
gettext.cpython-34.pyc File 14.82 KB 0644
gettext.cpython-34.pyo File 14.82 KB 0644
glob.cpython-34.pyc File 2.81 KB 0644
glob.cpython-34.pyo File 2.81 KB 0644
gzip.cpython-34.pyc File 18.99 KB 0644
gzip.cpython-34.pyo File 18.94 KB 0644
hashlib.cpython-34.pyc File 7.76 KB 0644
hashlib.cpython-34.pyo File 7.76 KB 0644
heapq.cpython-34.pyc File 13.58 KB 0644
heapq.cpython-34.pyo File 13.58 KB 0644
hmac.cpython-34.pyc File 5.03 KB 0644
hmac.cpython-34.pyo File 5.03 KB 0644
imaplib.cpython-34.pyc File 42.46 KB 0644
imaplib.cpython-34.pyo File 40 KB 0644
imghdr.cpython-34.pyc File 4.05 KB 0644
imghdr.cpython-34.pyo File 4.05 KB 0644
imp.cpython-34.pyc File 9.64 KB 0644
imp.cpython-34.pyo File 9.64 KB 0644
inspect.cpython-34.pyc File 74.54 KB 0644
inspect.cpython-34.pyo File 74.22 KB 0644
io.cpython-34.pyc File 3.38 KB 0644
io.cpython-34.pyo File 3.38 KB 0644
ipaddress.cpython-34.pyc File 61.51 KB 0644
ipaddress.cpython-34.pyo File 61.51 KB 0644
keyword.cpython-34.pyc File 1.9 KB 0644
keyword.cpython-34.pyo File 1.9 KB 0644
linecache.cpython-34.pyc File 3.04 KB 0644
linecache.cpython-34.pyo File 3.04 KB 0644
locale.cpython-34.pyc File 36.4 KB 0644
locale.cpython-34.pyo File 36.4 KB 0644
lzma.cpython-34.pyc File 15.54 KB 0644
lzma.cpython-34.pyo File 15.54 KB 0644
macpath.cpython-34.pyc File 5.87 KB 0644
macpath.cpython-34.pyo File 5.87 KB 0644
macurl2path.cpython-34.pyc File 2.05 KB 0644
macurl2path.cpython-34.pyo File 2.05 KB 0644
mailbox.cpython-34.pyc File 68.64 KB 0644
mailbox.cpython-34.pyo File 68.54 KB 0644
mailcap.cpython-34.pyc File 6.39 KB 0644
mailcap.cpython-34.pyo File 6.39 KB 0644
mimetypes.cpython-34.pyc File 16.41 KB 0644
mimetypes.cpython-34.pyo File 16.41 KB 0644
modulefinder.cpython-34.pyc File 16.97 KB 0644
modulefinder.cpython-34.pyo File 16.89 KB 0644
netrc.cpython-34.pyc File 4.18 KB 0644
netrc.cpython-34.pyo File 4.18 KB 0644
nntplib.cpython-34.pyc File 35.46 KB 0644
nntplib.cpython-34.pyo File 35.46 KB 0644
ntpath.cpython-34.pyc File 12.99 KB 0644
ntpath.cpython-34.pyo File 12.99 KB 0644
nturl2path.cpython-34.pyc File 1.68 KB 0644
nturl2path.cpython-34.pyo File 1.68 KB 0644
numbers.cpython-34.pyc File 12.37 KB 0644
numbers.cpython-34.pyo File 12.37 KB 0644
opcode.cpython-34.pyc File 5.05 KB 0644
opcode.cpython-34.pyo File 5.05 KB 0644
operator.cpython-34.pyc File 12.48 KB 0644
operator.cpython-34.pyo File 12.48 KB 0644
optparse.cpython-34.pyc File 50.33 KB 0644
optparse.cpython-34.pyo File 50.25 KB 0644
os.cpython-34.pyc File 28.91 KB 0644
os.cpython-34.pyo File 28.91 KB 0644
pathlib.cpython-34.pyc File 39.53 KB 0644
pathlib.cpython-34.pyo File 39.53 KB 0644
pdb.cpython-34.pyc File 48.31 KB 0644
pdb.cpython-34.pyo File 48.25 KB 0644
pickle.cpython-34.pyc File 45.88 KB 0644
pickle.cpython-34.pyo File 45.74 KB 0644
pickletools.cpython-34.pyc File 68.61 KB 0644
pickletools.cpython-34.pyo File 67.55 KB 0644
pipes.cpython-34.pyc File 8.23 KB 0644
pipes.cpython-34.pyo File 8.23 KB 0644
pkgutil.cpython-34.pyc File 17.19 KB 0644
pkgutil.cpython-34.pyo File 17.19 KB 0644
platform.cpython-34.pyc File 30.44 KB 0644
platform.cpython-34.pyo File 30.44 KB 0644
plistlib.cpython-34.pyc File 29.44 KB 0644
plistlib.cpython-34.pyo File 29.36 KB 0644
poplib.cpython-34.pyc File 13.43 KB 0644
poplib.cpython-34.pyo File 13.43 KB 0644
posixpath.cpython-34.pyc File 9.58 KB 0644
posixpath.cpython-34.pyo File 9.58 KB 0644
pprint.cpython-34.pyc File 11.19 KB 0644
pprint.cpython-34.pyo File 11.03 KB 0644
profile.cpython-34.pyc File 14.8 KB 0644
profile.cpython-34.pyo File 14.55 KB 0644
pstats.cpython-34.pyc File 23.12 KB 0644
pstats.cpython-34.pyo File 23.12 KB 0644
pty.cpython-34.pyc File 4.13 KB 0644
pty.cpython-34.pyo File 4.13 KB 0644
py_compile.cpython-34.pyc File 6.7 KB 0644
py_compile.cpython-34.pyo File 6.7 KB 0644
pyclbr.cpython-34.pyc File 8.98 KB 0644
pyclbr.cpython-34.pyo File 8.98 KB 0644
pydoc.cpython-34.pyc File 88.78 KB 0644
pydoc.cpython-34.pyo File 88.72 KB 0644
queue.cpython-34.pyc File 9.04 KB 0644
queue.cpython-34.pyo File 9.04 KB 0644
quopri.cpython-34.pyc File 6.29 KB 0644
quopri.cpython-34.pyo File 6.09 KB 0644
random.cpython-34.pyc File 18.61 KB 0644
random.cpython-34.pyo File 18.61 KB 0644
re.cpython-34.pyc File 14.21 KB 0644
re.cpython-34.pyo File 14.21 KB 0644
reprlib.cpython-34.pyc File 5.73 KB 0644
reprlib.cpython-34.pyo File 5.73 KB 0644
rlcompleter.cpython-34.pyc File 5.56 KB 0644
rlcompleter.cpython-34.pyo File 5.56 KB 0644
runpy.cpython-34.pyc File 7.57 KB 0644
runpy.cpython-34.pyo File 7.57 KB 0644
sched.cpython-34.pyc File 6.42 KB 0644
sched.cpython-34.pyo File 6.42 KB 0644
selectors.cpython-34.pyc File 16.35 KB 0644
selectors.cpython-34.pyo File 16.35 KB 0644
shelve.cpython-34.pyc File 9.72 KB 0644
shelve.cpython-34.pyo File 9.72 KB 0644
shlex.cpython-34.pyc File 7.34 KB 0644
shlex.cpython-34.pyo File 7.34 KB 0644
shutil.cpython-34.pyc File 32.24 KB 0644
shutil.cpython-34.pyo File 32.24 KB 0644
site.cpython-34.pyc File 17.55 KB 0644
site.cpython-34.pyo File 17.55 KB 0644
smtpd.cpython-34.pyc File 25.07 KB 0644
smtpd.cpython-34.pyo File 25.07 KB 0644
smtplib.cpython-34.pyc File 32.35 KB 0644
smtplib.cpython-34.pyo File 32.28 KB 0644
sndhdr.cpython-34.pyc File 6.61 KB 0644
sndhdr.cpython-34.pyo File 6.61 KB 0644
socket.cpython-34.pyc File 17.69 KB 0644
socket.cpython-34.pyo File 17.64 KB 0644
socketserver.cpython-34.pyc File 22.71 KB 0644
socketserver.cpython-34.pyo File 22.71 KB 0644
sre_compile.cpython-34.pyc File 11.66 KB 0644
sre_compile.cpython-34.pyo File 11.5 KB 0644
sre_constants.cpython-34.pyc File 5.45 KB 0644
sre_constants.cpython-34.pyo File 5.45 KB 0644
sre_parse.cpython-34.pyc File 19.76 KB 0644
sre_parse.cpython-34.pyo File 19.76 KB 0644
ssl.cpython-34.pyc File 26.96 KB 0644
ssl.cpython-34.pyo File 26.96 KB 0644
stat.cpython-34.pyc File 3.49 KB 0644
stat.cpython-34.pyo File 3.49 KB 0644
statistics.cpython-34.pyc File 16.76 KB 0644
statistics.cpython-34.pyo File 16.46 KB 0644
string.cpython-34.pyc File 8.18 KB 0644
string.cpython-34.pyo File 8.18 KB 0644
stringprep.cpython-34.pyc File 13.32 KB 0644
stringprep.cpython-34.pyo File 13.25 KB 0644
struct.cpython-34.pyc File 347 B 0644
struct.cpython-34.pyo File 347 B 0644
subprocess.cpython-34.pyc File 42.34 KB 0644
subprocess.cpython-34.pyo File 42.23 KB 0644
sunau.cpython-34.pyc File 17.88 KB 0644
sunau.cpython-34.pyo File 17.88 KB 0644
symbol.cpython-34.pyc File 2.6 KB 0644
symbol.cpython-34.pyo File 2.6 KB 0644
symtable.cpython-34.pyc File 11.04 KB 0644
symtable.cpython-34.pyo File 10.92 KB 0644
sysconfig.cpython-34.pyc File 16.88 KB 0644
sysconfig.cpython-34.pyo File 16.88 KB 0644
tabnanny.cpython-34.pyc File 7.57 KB 0644
tabnanny.cpython-34.pyo File 7.57 KB 0644
tarfile.cpython-34.pyc File 66.45 KB 0644
tarfile.cpython-34.pyo File 66.45 KB 0644
telnetlib.cpython-34.pyc File 18.94 KB 0644
telnetlib.cpython-34.pyo File 18.94 KB 0644
tempfile.cpython-34.pyc File 21.07 KB 0644
tempfile.cpython-34.pyo File 21.07 KB 0644
textwrap.cpython-34.pyc File 13.48 KB 0644
textwrap.cpython-34.pyo File 13.39 KB 0644
this.cpython-34.pyc File 1.29 KB 0644
this.cpython-34.pyo File 1.29 KB 0644
threading.cpython-34.pyc File 38.05 KB 0644
threading.cpython-34.pyo File 37.36 KB 0644
timeit.cpython-34.pyc File 10.8 KB 0644
timeit.cpython-34.pyo File 10.8 KB 0644
token.cpython-34.pyc File 3.53 KB 0644
token.cpython-34.pyo File 3.53 KB 0644
tokenize.cpython-34.pyc File 19.48 KB 0644
tokenize.cpython-34.pyo File 19.43 KB 0644
trace.cpython-34.pyc File 23.62 KB 0644
trace.cpython-34.pyo File 23.56 KB 0644
traceback.cpython-34.pyc File 10.83 KB 0644
traceback.cpython-34.pyo File 10.83 KB 0644
tracemalloc.cpython-34.pyc File 16.73 KB 0644
tracemalloc.cpython-34.pyo File 16.73 KB 0644
tty.cpython-34.pyc File 1.12 KB 0644
tty.cpython-34.pyo File 1.12 KB 0644
types.cpython-34.pyc File 5.43 KB 0644
types.cpython-34.pyo File 5.43 KB 0644
uu.cpython-34.pyc File 3.93 KB 0644
uu.cpython-34.pyo File 3.93 KB 0644
uuid.cpython-34.pyc File 21.35 KB 0644
uuid.cpython-34.pyo File 21.29 KB 0644
warnings.cpython-34.pyc File 11.98 KB 0644
warnings.cpython-34.pyo File 11.27 KB 0644
wave.cpython-34.pyc File 18.69 KB 0644
wave.cpython-34.pyo File 18.63 KB 0644
weakref.cpython-34.pyc File 19.87 KB 0644
weakref.cpython-34.pyo File 19.83 KB 0644
webbrowser.cpython-34.pyc File 16.73 KB 0644
webbrowser.cpython-34.pyo File 16.69 KB 0644
xdrlib.cpython-34.pyc File 8.79 KB 0644
xdrlib.cpython-34.pyo File 8.79 KB 0644
zipfile.cpython-34.pyc File 44.75 KB 0644
zipfile.cpython-34.pyo File 44.7 KB 0644