MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 13.59.2.242
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /../usr/lib/python2.7/site-packages/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //../usr/lib/python2.7/site-packages/IPy.pyc
�
-=�Mc@s2dZdZddlZddlZi	dd6dd6dd6dd	6dd
6dd6dd6dd
6dd6ZiPdd6ddd6ddd6dddd
6dddd
d6dddd6dd6dd6dd6dd6dd 6dd!6d"d#6d$d%6d&d'6d(d)dd6d*d+6d,d-6d.d/6d0d16d0d26d0d36d,d46d5d66d,d76d8d96d0d:6d0d;6d.d<6d0d=6d0d>6d0d?6d0d@6d0dA6ddB6d0dC6dDdE6d,dF6d0dG6d.dH6d0dI6d0dJ6d0dK6d,dL6d,dM6d,dN6dOdP6d0dQ6d,dR6d.dS6d.dT6d.dU6d8dV6d0dW6dDdX6ddY6ddZ6dd[6dd\6dd]6dd^6dd_6dd`6dda6ddb6ddc6ddde6ddf6dgdh6ddi6djdk6dldm6dndo6dpdq6drds6dtdu6dvdw6dxdy6dzd{6d|d}6Zd~fd��YZd�efd���YZd��Zd��Z	d��Z
d��Zd��Zid�d6d!d
6d�d�6d[d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6dad�6d�d�6Z
d��Zd��Zd��Zd��Zd��Zd��Zd��Zd��Zed�kr.ddlZej�\ZZer+ddlZejd��nndS(�s�
IPy - class and tools for handling of IPv4 and IPv6 addresses and networks.
See README file for learn how to use IPy.

Further Information might be available at:
https://github.com/haypo/python-ipy
s0.75i����NtPUBLICt0tPRIVATEt00000000t00001010t01111111t1t1010100111111110t101011000001t1100000010101000tRESERVEDt111i`tUNSPECIFIEDi�tLOOPBACKitIPV4MAPiPit
WKP46TRANSt 00000000011001001111111110011011i@t
UNASSIGNEDt00000001t0000001t0000010t0000011t00001t0001sGLOBAL-UNICASTt001tSPECIALPURPOSEt00100000000000010000000tTEREDOt 00100000000000010000000000000000tBMWGt 00100000000000010000000000000010tORCHIDt0010000000000001000000000001sALLOCATED APNICt00100000000000010000001sALLOCATED ARINt00100000000000010000010sALLOCATED RIPE NCCt00100000000000010000011t00100000000000010000100t00100000000000010000101t00100000000000010000110t
DOCUMENTATIONt 00100000000000010000110110111000t00100000000000010000111sALLOCATED LACNICt00100000000000010001001t00100000000000010001010t00100000000000010001011t00100000000000010001100t00100000000000010001101t0010000000000001000111t00100000000000010010t001000000000000100110t0010000000000001001110t0010000000000001001111t00100000000000010100000sALLOCATED AFRINICt00100000000000010100001t00100000000000010100010t00100000000000010100011t00100000000000010100100t00100000000000010100101t00100000000000010100110t00100000000000010101t0010000000000001100t00100000000000011010t00100000000000011011t6TO4t0010000000000010t001000000000001100t001001000000t001001100000t00100110000100000000000t00100110001000000000000t001010000000t001010100000t001011000000t00101101t0010111t0011t010t011t100t101t110t1110t11110t111110tULAt1111110t	111111100t	LINKLOCALt
1111111010t
1111111011t	MULTICASTt11111111sNODE-LOCAL MULTICASTt1111111100000001sLINK-LOCAL MULTICASTt1111111100000010sADMIN-LOCAL MULTICASTt1111111100000100sSITE-LOCAL MULTICASTt1111111100000101sORG-LOCAL MULTICASTt1111111100001000sGLOBAL MULTICASTt1111111100001110sRESERVED MULTICASTt1111111100001111sPREFIX-BASED MULTICASTt111111110011sRP-EMBEDDED MULTICASTt111111110111tIPintcBs"eZdZddd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dd	�Zdd
�Zdd�Z
dd�Zdd
�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(sHandling of IP addresses returning integers.

    Use class IP instead because some features are not implemented for
    IPint.icCsWd|_d|_d}d}t|ttf�rt|�|_|dkro|jdkrfd}qod}n|dkr�|jdkr�td|j��nd	}nF|dkr�|jd
kr�td|j��nd}ntd
��||_||_	nOt|t
�r:|j|_|j	|_	|j|_nt|ttf�r=|j
d�}t|�dkrR|\}}t|�\|_}	|	dkr�td��nt|�\}}
|
dkr�td��n||jkr�td��n||j}t|�}td|d	|f�j�j�|krFtd|��qFn�t|�dkr|j
d�}t|�dkr�|d}d}qFt|�dkr�td��qF|\}}|jd�dkrFt|�\}}
|
dkrtd��nt|�}qFn-t|�dkr:td��ntd��t|�\|_}	|dkrp|	}n|dkr�|dkr�d	|}q�|dkr�d|}q�td
��n||_t|�|_	|r�|jt|j	|j�@|_nt|j|j	|j�sStdt|�|j	f��qSntdt|���dS(s-Create an instance of an IP object.

        Data can be a network specification or a single IP. IP
        addresses can be specified in all forms understood by
        parseAddress(). The size of a network can be specified as

        /prefixlen        a.b.c.0/24               2001:658:22a:cafe::/64
        -lastIP           a.b.c.0-a.b.c.255        2001:658:22a:cafe::-2001:658:22a:cafe:ffff:ffff:ffff:ffff
        /decimal netmask  a.b.c.d/255.255.255.0    not supported for IPv6

        If no size specification is given a size of 1 address (/32 for
        IPv4 and /128 for IPv6) is assumed.

        If make_net is True, an IP address will be transformed into the network
        address by applying the specified netmask.

        >>> print(IP('127.0.0.0/8'))
        127.0.0.0/8
        >>> print(IP('127.0.0.0/255.0.0.0'))
        127.0.0.0/8
        >>> print(IP('127.0.0.0-127.255.255.255'))
        127.0.0.0/8
        >>> print(IP('127.0.0.1/255.0.0.0', make_net=True))
        127.0.0.0/8

        See module documentation for more examples.
        iii����IiiI����sJIPv4 Addresses can't be larger than 0xffffffffffffffffffffffffffffffff: %xi l	���������sJIPv6 Addresses can't be larger than 0xffffffffffffffffffffffffffffffff: %xi�sonly IPv4 and IPv6 supportedt-is)first-last notation only allowed for IPv4s last address should be IPv4, toos(last address should be larger than firsts%s/%ss*the range %s is not on a network boundary.t/s"only one '/' allowed in IP Addresst.snetmask must be IPv4s"only one '-' allowed in IP Addressscan't parses!%s has invalid prefix length (%s)sUnsupported data type: %sN(tNoPrefixForSingleIptNonet
WantPrefixLent
isinstancetinttlongtipt
ValueErrort
_ipversiont
_prefixlenRetstrtunicodetsplittlentparseAddresst_count1BitstIPt	broadcasttfindt_netmaskToPrefixlent_prefixlenToNetmaskt_checkNetaddrWorksWithPrefixlentreprt	TypeErrorttype(tselftdatat	ipversiontmake_nettnetbitst	prefixlentxRotlastt
parsedVersiontlastversiontsizetnetmasktvers((s'/usr/lib/python2.7/site-packages/IPy.pyt__init__{s�							
,
		

	"	%cCs|jS(s�Return the first / base / network addess as an (long) integer.

        The same as IP[0].

        >>> "%X" % IP('10.0.0.0/8').int()
        'A000000'
        (Ro(R�((s'/usr/lib/python2.7/site-packages/IPy.pyRm�scCs|jS(s�Return the IP version of this Object.

        >>> IP('10.0.0.0/8').version()
        4
        >>> IP('::1').version()
        6
        (Rq(R�((s'/usr/lib/python2.7/site-packages/IPy.pytversionscCs|jS(sWReturns Network Prefixlen.

        >>> IP('10.0.0.0/8').prefixlen()
        8
        (Rr(R�((s'/usr/lib/python2.7/site-packages/IPy.pyR�scCs
|j�S(sT
        Return the base (first) address of a network as an (long) integer.
        (Rm(R�((s'/usr/lib/python2.7/site-packages/IPy.pytnetscCs|j�|j�dS(sl
        Return the broadcast (last) address of a network as an (long) integer.

        The same as IP[-1].i(RmRv(R�((s'/usr/lib/python2.7/site-packages/IPy.pyRzscCs|jdkr|jdks<|jdkrQ|jdkrQ|jrQd}qQn|d
kr~|j}|d
kr~d}q~n|r|dkr�|j�}t|ttf�s�|j�}ndt	||j�S|d	krd
t	|j
|j�d|j�Sd|jSndSd
S(s�Prints Prefixlen/Netmask.

        Not really. In fact it is our universal Netmask/Prefixlen printer.
        This is considered an internal function.

        want == 0 / None        don't return anything    1.2.3.0
        want == 1               /prefix                  1.2.3.0/24
        want == 2               /netmask                 1.2.3.0/255.255.255.0
        want == 3               -lastip                  1.2.3.0-1.2.3.255
        ii ii�iiis/%sis-%ss/%dtN(RqRrRiRjRkR�RlRmRntintToIpRoRv(R�twantR�((s'/usr/lib/python2.7/site-packages/IPy.pyt_printPrefix%s$		%cCs�|jdkrd}n$|jdkr0d}ntd��|jdkr`|dkr`d}nt|j�}d|t|�||j|�S(	s�Return a string representation as a binary value.

        >>> print(IP('127.0.0.1').strBin())
        01111111000000000000000000000001
        ii ii�sonly IPv4 and IPv6 supportediRN(RqRpRkRjt	_intToBinRoRvR�(R�t
wantprefixlentbitstret((s'/usr/lib/python2.7/site-packages/IPy.pytstrBinOs			c	Cs|jd
kr$|d
kr$d}n|jdkr@|j|�S|jd?dkr�t|jd@d�}d||j|�}|Sg|jd�jd�D]}t|d	�^q�}dgd
}x.t	t
|��D]}t||�||<q�W|jt
|��}t
|�dkr�g|jd�jd�D]}|^q6}x-|t
|�krw||dkrw||=qKW|j|d�|dt
|�kr�|jd�n|dkr�dg|}ndj|�|j|�S|jd�|j|�Sd
S(skReturn a string representation in compressed format using '::' Notation.

        >>> IP('127.0.0.1').strCompressed()
        '127.0.0.1'
        >>> IP('2001:0658:022a:cafe:0200::1').strCompressed()
        '2001:658:22a:cafe:200::1'
        >>> IP('ffff:ffff:ffff:ffff:ffff:f:f:fffc/127').strCompressed()
        'ffff:ffff:ffff:ffff:ffff:f:f:fffc/127'
        iii i��I����s::ffff:it:iiRR�N(RkRjRqtstrFullsizeRoR�R�RuRmtxrangeRvt_countFollowingZerostindextmaxt	strNormaltinserttappendtjoin(	R�R�tipv4ttextR�thextetstfollowingzerostitcompressionpos((s'/usr/lib/python2.7/site-packages/IPy.pyt
strCompressedcs0	
4
+%cCs�|jd	kr$|d	kr$d}n|jdkrE|jd�}nx|jdkr�djgg|jd�jd�D]}t|d�^qvD]}t|�d^q��}ntd��||j	|�S(
s�Return a string representation in the usual format.

        >>> print(IP('127.0.0.1').strNormal())
        127.0.0.1
        >>> print(IP('2001:0658:022a:cafe:0200::1').strNormal())
        2001:658:22a:cafe:200:0:0:1
        iiiiR�iisonly IPv4 and IPv6 supportedN(
RkRjRqR�R�RuRmthexRpR�(R�R�R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��s		]cCsJ|jdkr$|dkr$d}nt|j|j�j�|j|�S(s�Return a string representation in the non-mangled format.

        >>> print(IP('127.0.0.1').strFullsize())
        127.0.0.1
        >>> print(IP('2001:0658:022a:cafe:0200::1').strFullsize())
        2001:0658:022a:cafe:0200:0000:0000:0001
        iN(RkRjR�RoRqtlowerR�(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��s		cCsg|jdkr$|dkr$d}nt|j�}|ddkrP|d }n|j�|j|�S(s�Return a string representation in hex format in lower case.

        >>> IP('127.0.0.1').strHex()
        '0x7f000001'
        >>> IP('2001:0658:022a:cafe:0200::1').strHex()
        '0x20010658022acafe0200000000000001'
        ii����tLN(RkRjR�RoR�R�(R�R�R�((s'/usr/lib/python2.7/site-packages/IPy.pytstrHex�s		
cCsa|jdkr$|dkr$d}nt|j�}|ddkrP|d }n||j|�S(s�Return a string representation in decimal format.

        >>> print(IP('127.0.0.1').strDec())
        2130706433
        >>> print(IP('2001:0658:022a:cafe:0200::1').strDec())
        42540616829182469433547762482097946625
        ii����R�N(RkRjRsRoR�(R�R�R�((s'/usr/lib/python2.7/site-packages/IPy.pytstrDec�s		
cCs�|jdkrt}n$|jdkr0t}ntd��|j�}x<tt|�dd�D]"}|| |kra||| SqaWdS(s�Return a description of the IP type ('PRIVATE', 'RESERVERD', etc).

        >>> print(IP('127.0.0.1').iptype())
        PRIVATE
        >>> print(IP('192.168.1.1').iptype())
        PRIVATE
        >>> print(IP('195.185.1.2').iptype())
        PUBLIC
        >>> print(IP('::1').iptype())
        LOOPBACK
        >>> print(IP('2001:0658:022a:cafe:0200::1').iptype())
        ALLOCATED RIPE NCC

        The type information for IPv6 is out of sync with reality.
        iisonly IPv4 and IPv6 supportedii����tunknown(Rqt
IPv4rangest
IPv6rangesRpR�R�Rv(R�tiprangeR�R�((s'/usr/lib/python2.7/site-packages/IPy.pytiptype�s		cCs]|jdkrd|j}n+|jdkr>d|j}ntd��d|jd|>S(srReturn netmask as an integer.

        >>> "%X" % IP('195.185.0.0/16').netmask().int()
        'FFFF0000'
        ii ii�sonly IPv4 and IPv6 supportedii(RqRrRp(R�tlocallen((s'/usr/lib/python2.7/site-packages/IPy.pyR��scCso|jdkr8d|j}td|jd|>d�S|jdkr_d|j}d|jStd��d	S(
s�Return netmask as an string. Mostly useful for IPv6.

        >>> print(IP('195.185.0.0/16').strNetmask())
        255.255.0.0
        >>> print(IP('2001:0658:022a:cafe::0/64').strNetmask())
        /64
        ii iiii�s/%dsonly IPv4 and IPv6 supportedN(RqRrR�Rp(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyt
strNetmask
s


cCsR|jdkrd|j}n+|jdkr>d|j}ntd��d|S(s�Return the length of a subnet.

        >>> print(IP('195.185.1.0/28').len())
        16
        >>> print(IP('195.185.1.0/24').len())
        256
        ii ii�sonly IPv4 and IPv6 supportedi(RqRrRp(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyRvs	cCstS(sAll IPy objects should evaluate to true in boolean context.
        Ordinarily they do, but if handling a default route expressed as
        0.0.0.0/0, the __len__() of the object becomes 0, which is used
        as the boolean value of the object.
        (tTrue(R�((s'/usr/lib/python2.7/site-packages/IPy.pyt__nonzero__0scCst|j��S(s�Return the length of a subnet.

        Called to implement the built-in function len().
        It breaks with IPv6 Networks. Anybody knows how to fix this.(RmRv(R�((s'/usr/lib/python2.7/site-packages/IPy.pyt__len__9s	cCs�t|ttf�st�n|dkrdt|�|j�kr[|j�t|�}qt�n||j�krt�n|jt|�S(sNCalled to implement evaluation of self[key].

        >>> ip=IP('127.0.0.0/30')
        >>> for x in ip:
        ...  print(repr(x))
        ...
        IP('127.0.0.0')
        IP('127.0.0.1')
        IP('127.0.0.2')
        IP('127.0.0.3')
        >>> ip[2]
        IP('127.0.0.2')
        >>> ip[-1]
        IP('127.0.0.3')
        i(RlRmRnR�tabsRvt
IndexErrorRo(R�tkey((s'/usr/lib/python2.7/site-packages/IPy.pyt__getitem__Es			cCsTt|�}|j|jkrL|j|j|j�|j�dkrLtStSdS(s�Called to implement membership test operators.

        Should return true if item is in self, false otherwise. Item
        can be other IP-objects, strings or ints.

        >>> IP('195.185.1.1').strHex()
        '0xc3b90101'
        >>> 0xC3B90101 in IP('195.185.1.0/24')
        True
        >>> '127.0.0.1' in IP('127.0.0.0/24')
        True
        >>> IP('127.0.0.0/24') in IP('127.0.0.0/25')
        False
        iN(RyRoRvR�tFalse(R�titem((s'/usr/lib/python2.7/site-packages/IPy.pyt__contains__es<cCsxt|�}|j|jkr>|j|j|j�kr>dS|j|jkrp|j|j|j�krpdSdSdS(s�Check if two IP address ranges overlap.

        Returns 0 if the two ranges don't overlap, 1 if the given
        range overlaps at the end and -1 if it does at the beginning.

        >>> IP('192.168.0.0/23').overlaps('192.168.1.0/24')
        1
        >>> IP('192.168.0.0/23').overlaps('192.168.1.255')
        1
        >>> IP('192.168.0.0/23').overlaps('192.168.2.0')
        0
        >>> IP('192.168.1.0/24').overlaps('192.168.0.0/23')
        -1
        ii����iN(RyRoRv(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pytoverlaps|s..cCs
|j�S(sSDispatch to the prefered String Representation.

        Used to implement str(IP).(R�(R�((s'/usr/lib/python2.7/site-packages/IPy.pyt__str__�scCsd|jd�S(sPrint a representation of the Object.

        Used to implement repr(IP). Returns a string which evaluates
        to an identical Object (without the wantprefixlen stuff - see
        module docstring.

        >>> print(repr(IP('10.0.0.0/24')))
        IP('10.0.0.0/24')
        sIPint('%s')i(R�(R�((s'/usr/lib/python2.7/site-packages/IPy.pyt__repr__�scCs�|j|j�kr&|j�|jS|j|j�krL|j�|jS|j|jkrbdS|j|jkrxdS|j|jkr�|j|jkr�dS|j|jkr�dSdSndSdS(s�Called by comparison operations.

        Should return a negative integer if self < other, zero if self
        == other, a positive integer if self > other.

        Networks with different prefixlen are considered non-equal.
        Networks with the same prefixlen and differing addresses are
        considered non equal but are compared by their base address
        integer value to aid sorting of IP objects.

        The version of Objects is not put into consideration.

        >>> IP('10.0.0.0/24') > IP('10.0.0.0')
        1
        >>> IP('10.0.0.0/24') < IP('10.0.0.0')
        0
        >>> IP('10.0.0.0/24') < IP('12.0.0.0/24')
        1
        >>> IP('10.0.0.0/24') > IP('12.0.0.0/24')
        0

        i����iiN(RrR�RoRq(R�tother((s'/usr/lib/python2.7/site-packages/IPy.pyt__cmp__�scCs|j|�dkS(Ni(R�(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyt__eq__�scCs|j|�dkS(Ni(R�(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyt__lt__�scCsWtd�}|j}x(|dkr?||d@A}|d?}qW||jA}t|�S(shCalled for the key object for dictionary operations, and by
        the built-in function hash(). Should return a 32-bit integer
        usable as a hash value for dictionary operations. The only
        required property is that objects which compare equal have the
        same hash value

        >>> IP('10.0.0.0/24').__hash__()
        -167772185
        i����ii���i (RmRoRr(R�tthehashRo((s'/usr/lib/python2.7/site-packages/IPy.pyt__hash__�s	
N( t__name__t
__module__t__doc__R�RmR�R�R�RzR�RjR�R�R�R�R�R�R�R�R�RvR�R�R�R�R�R�R�R�R�R�R�(((s'/usr/lib/python2.7/site-packages/IPy.pyReus:�	
	
				*-	!							 					=		RycBsheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(s-Class for handling IP addresses and networks.cCsttj|�d|j�S(s�Return the base (first) address of a network as an IP object.

        The same as IP[0].

        >>> IP('10.0.0.0/8').net()
        IP('10.0.0.0')
        R�(RyReR�Rq(R�((s'/usr/lib/python2.7/site-packages/IPy.pyR�scCsttj|��S(s�Return the broadcast (last) address of a network as an IP object.

        The same as IP[-1].

        >>> IP('10.0.0.0/8').broadcast()
        IP('10.255.255.255')
        (RyReRz(R�((s'/usr/lib/python2.7/site-packages/IPy.pyRzscCsttj|�d|j�S(siReturn netmask as an IP object.

        >>> IP('10.0.0.0/8').netmask()
        IP('255.0.0.0')
         R�(RyReR�Rq(R�((s'/usr/lib/python2.7/site-packages/IPy.pyR�scCst|jdkrdS|jd?dkr*dS|jd@}|jdkrdd|dd|jf}nt|dd�S(	Nii i��I����i�s%s/%sR�i(RqRjRoRrRy(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyt_getIPv4Map!s
cCs|jdkr6g}|j�dkrNx|D]}|j|j��q.Wn�|j�dkr�x�td|j�d�D]!}|j||j�d�qyWn�|j�dkr�x|td|j�d�D]!}|j||j�d�q�Wn>x;td|j�d�D]!}|j||j�d�q
W|S|jdkr|j�}|dk	rg|j�St|j	�dj
�}|dd	kr�|d }n|jddkr�td
��nt
|�}|j�dj|�}td|jd�d}d
||gStd��dS(s�Return a list with values forming the reverse lookup.

        >>> IP('213.221.113.87/32').reverseNames()
        ['87.113.221.213.in-addr.arpa.']
        >>> IP('213.221.112.224/30').reverseNames()
        ['224.112.221.213.in-addr.arpa.', '225.112.221.213.in-addr.arpa.', '226.112.221.213.in-addr.arpa.', '227.112.221.213.in-addr.arpa.']
        >>> IP('127.0.0.0/24').reverseNames()
        ['0.0.127.in-addr.arpa.']
        >>> IP('127.0.0.0/23').reverseNames()
        ['0.0.127.in-addr.arpa.', '1.0.127.in-addr.arpa.']
        >>> IP('127.0.0.0/16').reverseNames()
        ['0.127.in-addr.arpa.']
        >>> IP('127.0.0.0/15').reverseNames()
        ['0.127.in-addr.arpa.', '1.127.in-addr.arpa.']
        >>> IP('128.0.0.0/8').reverseNames()
        ['128.in-addr.arpa.']
        >>> IP('128.0.0.0/7').reverseNames()
        ['128.in-addr.arpa.', '129.in-addr.arpa.']
        >>> IP('::1:2').reverseNames()
        ['2.0.0.0.1.ip6.arpa.']
        iiiiiiii����tls3can't create IPv6 reverse names at sub nibble levelRhi s%s.ip6.arpa.sonly IPv4 and IPv6 supportedNiiiiii(RqRvR�treverseNameR�R�RjtreverseNamesR�RoR�RrtNotImplementedErrortlisttreverseR�RmRp(R�R�R�R�R�tstfirst_nibble_index((s'/usr/lib/python2.7/site-packages/IPy.pyR�+s:
""


cCs<|jdkr�|jd�}|jd�}|j�td|jd�}|jddkr�d|d|jdt|j|j�dd�jd�df}|dd	kr�|d }n|d7}nd
}dj	||�}d||fS|jdkr,|j
�}|dk	r)|j�St
|j�d
j�}|dd	kr_|d }n|jddkr�d||jt
|j|j�d�d
j�f}|dd	kr�|d }n|d7}nd
}t|�}|j�dj	|�}td|jd�d
}d|||fStd��dS(sReturn the value for reverse lookup/PTR records as RFC 2317 look alike.

        RFC 2317 is an ugly hack which only works for sub-/24 e.g. not
        for /23. Do not use it. Better set up a zone for every
        address. See reverseName for a way to achieve that.

        >>> print(IP('195.185.1.1').reverseName())
        1.1.185.195.in-addr.arpa.
        >>> print(IP('195.185.1.0/28').reverseName())
        0-15.1.185.195.in-addr.arpa.
        >>> IP('::1:2').reverseName()
        '2.0.0.0.1.ip6.arpa.'
        iiRhis%s-%siii����R�R�s%s%s.in-addr.arpa.iii s%s%s.ip6.arpa.sonly IPv4 and IPv6 supportedN(RqR�RuR�RmRrR�RoRvR�R�RjR�R�R�R�Rp(R�R�tfirst_byte_indext
nibblepartR�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR�cs@
F



8


cCs?dt|�kr%td|��ntd||fdt�S(s�Transform a single IP address into a network specification by
        applying the given netmask.

        Returns a new IP instance.

        >>> print(IP('127.0.0.1').make_net('255.0.0.0'))
        127.0.0.0/8
        Rgsinvalid netmask (%s)s%s/%sR�(RsRpRyR�(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��s	cCsttj||��S(sACalled to implement evaluation of self[key].

        >>> ip=IP('127.0.0.0/30')
        >>> for x in ip:
        ...  print(str(x))
        ...
        127.0.0.0
        127.0.0.1
        127.0.0.2
        127.0.0.3
        >>> print(str(ip[2]))
        127.0.0.2
        >>> print(str(ip[-1]))
        127.0.0.3
        (RyReR�(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��scCsd|jd�S(sePrint a representation of the Object.

        >>> IP('10.0.0.0/8')
        IP('10.0.0.0/8')
        sIP('%s')i(R�(R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��scCs�|j�|j�kr'td��n|j�dkrHtd��n|j�|j�krotd��n||kr�|j|�St|j��}|j�d|_|SdS(s3Emulate numeric objects through network aggregations3Only networks with the same prefixlen can be added.is8Networks with a prefixlen longer than /1 can't be added.s4Only networks with the same IP version can be added.N(R�RpR�t__add__RyRmRr(R�R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��s
(
R�R�R�R�RzR�R�R�R�R�R�R�R�(((s'/usr/lib/python2.7/site-packages/IPy.pyRys	
	
		
	8	5	
			c
Cs�g}d}d}x|t|�kr1||}|jd�r{|dk	r_td|��nt|�}|d7}qn|jd�}|dkr�td|��n|dkr |j|| �|||d!dkr�||7}n||d7}|t|�kr.td|��q.q|j|�PqW|r�d	|dkr�|dk	r~|t|�dkr~td
|��nt|d�d}|d d|d?d|d
@g}n|dk	rdt|�}|dkr�td|��n|| dg|||}nt|�dkr9td|��nd}d}x�|D]�}y0t|d�}d|ko{d
kn}	Wntk
r�t}	nX|	r�td||f��n|d>|}|d7}qLW|S(st
    Internal function used by parseAddress() to parse IPv6 address with ':'.

    >>> print(_parseAddressIPv6('::'))
    0
    >>> print(_parseAddressIPv6('::1'))
    1
    >>> print(_parseAddressIPv6('0:0:0:0:0:0:0:1'))
    1
    >>> print(_parseAddressIPv6('0:0:0::0:0:1'))
    1
    >>> print(_parseAddressIPv6('0:0:0:0:0:0:0:0'))
    0
    >>> print(_parseAddressIPv6('0:0:0::0:0:0'))
    0

    >>> print(_parseAddressIPv6('FEDC:BA98:7654:3210:FEDC:BA98:7654:3210'))
    338770000845734292534325025077361652240
    >>> print(_parseAddressIPv6('1080:0000:0000:0000:0008:0800:200C:417A'))
    21932261930451111902915077091070067066
    >>> print(_parseAddressIPv6('1080:0:0:0:8:800:200C:417A'))
    21932261930451111902915077091070067066
    >>> print(_parseAddressIPv6('1080:0::8:800:200C:417A'))
    21932261930451111902915077091070067066
    >>> print(_parseAddressIPv6('1080::8:800:200C:417A'))
    21932261930451111902915077091070067066
    >>> print(_parseAddressIPv6('FF01:0:0:0:0:0:0:43'))
    338958331222012082418099330867817087043
    >>> print(_parseAddressIPv6('FF01:0:0::0:0:43'))
    338958331222012082418099330867817087043
    >>> print(_parseAddressIPv6('FF01::43'))
    338958331222012082418099330867817087043
    >>> print(_parseAddressIPv6('0:0:0:0:0:0:13.1.68.3'))
    218186755
    >>> print(_parseAddressIPv6('::13.1.68.3'))
    218186755
    >>> print(_parseAddressIPv6('0:0:0:0:0:FFFF:129.144.52.38'))
    281472855454758
    >>> print(_parseAddressIPv6('::FFFF:129.144.52.38'))
    281472855454758
    >>> print(_parseAddressIPv6('1080:0:0:0:8:800:200C:417A'))
    21932261930451111902915077091070067066
    >>> print(_parseAddressIPv6('1080::8:800:200C:417A'))
    21932261930451111902915077091070067066
    >>> print(_parseAddressIPv6('::1:2:3:4:5:6'))
    1208962713947218704138246
    >>> print(_parseAddressIPv6('1:2:3:4:5:6::'))
    5192455318486707404433266432802816
    is::s,%r: Invalid IPv6 address: more than one '::'iR�s%r: Invalid IPv6 addressi����iRhs)%r: Invalid IPv6 address: '::' after IPv4s%04xii��is,%r: Invalid IPv6 address: '::' is not neededRs/%r: Invalid IPv6 address: should have 8 hextetss+%r: Invalid IPv6 address: invalid hexlet %rN(	RjRvt
startswithRpR{R�RwRmR�(
tipstrtitemsR�tfill_posR�tpostvaluetdiffR�terror((s'/usr/lib/python2.7/site-packages/IPy.pyt_parseAddressIPv6�s`6



#' 
!

cCs
|jd�rdt|dd�}|dkrAtd|��n|dkrW|dfS|dfSn|jd	�d
kr�t|�dfSt|�dkr�t|d�dfS|jd�d
ks�t|�dkr�t|�d
kr�|jd�}t|�dkrtd��n|dgdt|�7}g|D]}t|�^q9}x9|D]1}|dksv|dkrXtd|��qXqXW|dd>|dd>|dd>|ddfSt|d�}|dkr�td��n|dkr�|dfS|dfSdS(s�
    Parse a string and return the corresponding IP address (as integer)
    and a guess of the IP version.

    Following address formats are recognized:

    >>> def testParseAddress(address):
    ...     ip, version = parseAddress(address)
    ...     print(("%s (IPv%s)" % (ip, version)))
    ...
    >>> testParseAddress('0x0123456789abcdef')           # IPv4 if <= 0xffffffff else IPv6
    81985529216486895 (IPv6)
    >>> testParseAddress('123.123.123.123')              # IPv4
    2071690107 (IPv4)
    >>> testParseAddress('123.123')                      # 0-padded IPv4
    2071658496 (IPv4)
    >>> testParseAddress('1080:0000:0000:0000:0008:0800:200C:417A')
    21932261930451111902915077091070067066 (IPv6)
    >>> testParseAddress('1080:0:0:0:8:800:200C:417A')
    21932261930451111902915077091070067066 (IPv6)
    >>> testParseAddress('1080:0::8:800:200C:417A')
    21932261930451111902915077091070067066 (IPv6)
    >>> testParseAddress('::1')
    1 (IPv6)
    >>> testParseAddress('::')
    0 (IPv6)
    >>> testParseAddress('0:0:0:0:0:FFFF:129.144.52.38')
    281472855454758 (IPv6)
    >>> testParseAddress('::13.1.68.3')
    218186755 (IPv6)
    >>> testParseAddress('::FFFF:129.144.52.38')
    281472855454758 (IPv6)
    t0xiil	���������s)%r: IP Address can't be bigger than 2^128IiiR�i����i Rhis#IPv4 Address with more than 4 bytesRi�is'%r: single byte must be 0 <= byte < 256iiiii
s%IP Address can't be bigger than 2^128I����N(R�RnRpR{R�RvRmRu(R�R�tbytesR�((s'/usr/lib/python2.7/site-packages/IPy.pyRwIs6#

9
2
cCs�t|�}|dkr+td|��nd}|dkr�|dkrbtdt|���nx6td�D](}t|d@�d|}|d	?}qoW|d
 }n�|dkrp|dkr�td
t|���ntjdkr�t|�d}nt|�dd
!}|jd�}xCtdd�D]2}|||}|ddkr-d|}q-q-W|d}ntd��|S(s/Transform an integer string into an IP address.isIPs can't be negative: %dR�iI����s2IPv4 Addresses can't be larger than 0xffffffff: %si�Rhii����il	���������sJIPv6 Addresses can't be larger than 0xffffffffffffffffffffffffffffffff: %siii ii!R�sonly IPv4 and IPv6 supported(RnRpR�R�Rstsyst
hexversiontzfill(RoR�R�R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��s2

cCs0|dkrdS|dkr dStd��dS(s�Return number of bits in address for a certain IP version.

    >>> _ipVersionToLen(4)
    32
    >>> _ipVersionToLen(6)
    128
    >>> _ipVersionToLen(5)
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "IPy.py", line 1076, in _ipVersionToLen
        raise ValueError("only IPv4 and IPv6 supported")
    ValueError: only IPv4 and IPv6 supported
    ii ii�sonly IPv4 and IPv6 supportedN(Rp(R�((s'/usr/lib/python2.7/site-packages/IPy.pyt_ipVersionToLen�s
cCs@t|�dkrdS|ddkr*dSdt|d�SdS(sDReturn number of elements containing 0 at the beginning of the list.iiN(RvR�(R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��s
t0000t0010t2t3t0100t4t0101t5t0110t6t0111t7t1000t8t1001t9t1010tat1011tbt1100tct1101tdtet1111tfcCs�|dkrtd��nt|�j�}d}|ddkrP|d }nx |dD]}|t|7}q[Wx0|ddkr�t|�dkr�|d}qvW|S(	s9Return the binary representation of an integer as string.isOnly positive values allowedR�i����R�iRi(RpR�R�t	_BitTableRv(tvalR�R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR��s
%cCs1d}x$|dkr,|d?}|d7}q	W|S(s,Find the highest bit set to 1 in an integer.ii((tnumR�((s'/usr/lib/python2.7/site-packages/IPy.pyRx�s

cCspt|�}|dkr+td|��nd}x8|dkrk|d@dkrTPn|d?}|d7}q4W|S(s,Find the highest bit set to 0 in an integer.is Only positive Numbers please: %si(RnRp(RR�((s'/usr/lib/python2.7/site-packages/IPy.pyt_count0Bits�s
cCsit|�}|dks$||kr(dS|dkrA|d}nt|�}|||kradSdSdS(sJCheck the validity of a prefix

    Checks if the variant part of a prefix only has 0s, and the length is
    correct.

    >>> _checkPrefix(0x7f000000, 24, 4)
    1
    >>> _checkPrefix(0x7f000001, 24, 4)
    0
    >>> repr(_checkPrefix(0x7f000001, -1, 4))
    'None'
    >>> repr(_checkPrefix(0x7f000001, 33, 4))
    'None'
    iiN(R�RjR(RoR�R�R�tzbits((s'/usr/lib/python2.7/site-packages/IPy.pyt_checkPrefixs
cCs�t|�}|}xD|d@dkrX|dkrX|d?}|d8}|dkrPqqWxM|dkr�|d@dkr�tdt|���n|d?}|d8}q\WdS(s2Checks if a netmask is expressable as a prefixlen.iis+Netmask %s can't be expressed as an prefix.N(RnRpR�(R�tmasklenRR�((s'/usr/lib/python2.7/site-packages/IPy.pyt
_checkNetmask(s


cCs|t||�@|kS(sBCheck if a base addess of a network is compatible with a prefixlen(R}(R�R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR~<scCs-t|�}t|�}t||�||S(snConvert an Integer representing a netmask to a prefixlen.

    E.g. 0xffffff00 (255.255.255.0) returns 24
    (RRxR(R�tnetlenR
((s'/usr/lib/python2.7/site-packages/IPy.pyR|As
cCsI|dkrdS|dkr+td��nd|d>dt|�|>S(s�Return a mask of n bits as a long integer.

    From 'IP address conversion functions with the builtin socket module'
    by Alex Martelli
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66517
    isPrefixlen must be > 0ii(RpR�(R�R�((s'/usr/lib/python2.7/site-packages/IPy.pyR}Ms
t__main__i(R�t__version__R�ttypesR�R�ReRyR�RwR�R�R�RR�RxRR	RR~R|R}R�tdoctestttestmodtfailuretnbtesttexit(((s'/usr/lib/python2.7/site-packages/IPy.pyt<module>s�

����	x	L	%		
				 				

MMCT - 2023