Your IP : 18.217.10.152
3
� fC# � @ s� d Z dZddlZdZdZG dd� de�ZG dd � d e�Zd
d� Zd=d
d�Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd � Zd!d"� ZG d#d$� d$�ZejG d%d&� d&e��ZejG d'd(� d(e��ZG d)d*� d*�ZG d+d,� d,ee�ZG d-d.� d.e�ZG d/d0� d0ee�ZG d1d2� d2�Zee_G d3d4� d4�ZG d5d6� d6ee�ZG d7d8� d8e�Z G d9d:� d:ee�Z!G d;d<� d<�Z"e"e_dS )>z�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 @ s e Zd ZdZdS )�AddressValueErrorz%A Value Error related to the address.N)�__name__�
__module__�__qualname__�__doc__� r r �./opt/alt/python36/lib64/python3.6/ipaddress.pyr s r c @ s e Zd ZdZdS )�NetmaskValueErrorz%A Value Error related to the netmask.N)r r r r r r r r
r s r c C sT yt | �S ttfk
r Y nX yt| �S ttfk
rB Y nX td| ��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)�IPv4Addressr r �IPv6Address�
ValueError)�addressr r r
�
ip_address s r Tc C sX y
t | |�S ttfk
r" Y nX y
t| |�S ttfk
rF Y nX td| ��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)�IPv4Networkr r �IPv6Networkr )r �strictr r r
�
ip_network9 s
r c C sT yt | �S ttfk
r Y nX yt| �S ttfk
rB Y nX td| ��dS )ag 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 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)�
IPv4Interfacer r �
IPv6Interfacer )r r r r
�ip_interfaceW s r c C s. y| j dd�S tk
r( td��Y nX dS )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_bytes�
OverflowErrorr )r r r r
�v4_int_to_packedz s r c C s. y| j dd�S tk
r( td��Y nX dS )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.
� r z&Address negative or too large for IPv6N)r r r )r r r r
�v6_int_to_packed� s
r c C s* t | �jd�}t|�dkr&td| ��|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� s r% c c sR t | �}t|� }}x.|D ]&}|j|jd kr<||fV |}|}qW ||fV dS )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�ipr r r
�_find_address_range� s
r/ c C s$ | dkr|S t || | d @ j� �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.
r r&