/snap/core22/2411/usr/lib/python3.10/__pycache__
NameSizeModeActions
abc.cpython-310.pyc67510644editdlrm
aifc.cpython-310.pyc246850644editdlrm
antigravity.cpython-310.pyc8220644editdlrm
argparse.cpython-310.pyc635390644editdlrm
ast.cpython-310.pyc557390644editdlrm
asynchat.cpython-310.pyc70250644editdlrm
asyncore.cpython-310.pyc160020644editdlrm
base64.cpython-310.pyc171620644editdlrm
bdb.cpython-310.pyc258320644editdlrm
binhex.cpython-310.pyc128700644editdlrm
bisect.cpython-310.pyc25880644editdlrm
bz2.cpython-310.pyc108700644editdlrm
calendar.cpython-310.pyc263030644editdlrm
cgi.cpython-310.pyc267230644editdlrm
cgitb.cpython-310.pyc99980644editdlrm
chunk.cpython-310.pyc48600644editdlrm
cmd.cpython-310.pyc127070644editdlrm
code.cpython-310.pyc99570644editdlrm
codecs.cpython-310.pyc332190644editdlrm
codeop.cpython-310.pyc55950644editdlrm
colorsys.cpython-310.pyc32650644editdlrm
compileall.cpython-310.pyc127330644editdlrm
configparser.cpython-310.pyc454580644editdlrm
contextlib.cpython-310.pyc208950644editdlrm
contextvars.cpython-310.pyc2460644editdlrm
copy.cpython-310.pyc69960644editdlrm
copyreg.cpython-310.pyc46830644editdlrm
cProfile.cpython-310.pyc51130644editdlrm
crypt.cpython-310.pyc35500644editdlrm
csv.cpython-310.pyc117980644editdlrm
dataclasses.cpython-310.pyc265780644editdlrm
datetime.cpython-310.pyc565330644editdlrm
decimal.cpython-310.pyc3620644editdlrm
difflib.cpython-310.pyc589050644editdlrm
dis.cpython-310.pyc156560644editdlrm
doctest.cpython-310.pyc761750644editdlrm
enum.cpython-310.pyc260630644editdlrm
filecmp.cpython-310.pyc87490644editdlrm
fileinput.cpython-310.pyc140720644editdlrm
fnmatch.cpython-310.pyc42440644editdlrm
fractions.cpython-310.pyc186000644editdlrm
ftplib.cpython-310.pyc289770644editdlrm
functools.cpython-310.pyc283350644editdlrm
genericpath.cpython-310.pyc39070644editdlrm
getopt.cpython-310.pyc63390644editdlrm
getpass.cpython-310.pyc42100644editdlrm
gettext.cpython-310.pyc182210644editdlrm
glob.cpython-310.pyc58520644editdlrm
graphlib.cpython-310.pyc76160644editdlrm
gzip.cpython-310.pyc185460644editdlrm
hashlib.cpython-310.pyc68450644editdlrm
heapq.cpython-310.pyc138650644editdlrm
hmac.cpython-310.pyc69730644editdlrm
imaplib.cpython-310.pyc424320644editdlrm
imghdr.cpython-310.pyc39050644editdlrm
imp.cpython-310.pyc97860644editdlrm
inspect.cpython-310.pyc851530644editdlrm
io.cpython-310.pyc36630644editdlrm
ipaddress.cpython-310.pyc626700644editdlrm
keyword.cpython-310.pyc9270644editdlrm
linecache.cpython-310.pyc41420644editdlrm
locale.cpython-310.pyc461540644editdlrm
lzma.cpython-310.pyc121000644editdlrm
mailbox.cpython-310.pyc600910644editdlrm
mailcap.cpython-310.pyc73200644editdlrm
mimetypes.cpython-310.pyc176190644editdlrm
modulefinder.cpython-310.pyc161660644editdlrm
netrc.cpython-310.pyc39330644editdlrm
nntplib.cpython-310.pyc316230644editdlrm
ntpath.cpython-310.pyc147040644editdlrm
nturl2path.cpython-310.pyc17470644editdlrm
numbers.cpython-310.pyc118660644editdlrm
opcode.cpython-310.pyc54470644editdlrm
operator.cpython-310.pyc135080644editdlrm
optparse.cpython-310.pyc477540644editdlrm
os.cpython-310.pyc315990644editdlrm
pathlib.cpython-310.pyc420520644editdlrm
pdb.cpython-310.pyc474400644editdlrm
pickle.cpython-310.pyc468820644editdlrm
pickletools.cpython-310.pyc677600644editdlrm
pipes.cpython-310.pyc77690644editdlrm
pkgutil.cpython-310.pyc183610644editdlrm
platform.cpython-310.pyc274290644editdlrm
plistlib.cpython-310.pyc237650644editdlrm
poplib.cpython-310.pyc136700644editdlrm
posixpath.cpython-310.pyc105600644editdlrm
pprint.cpython-310.pyc178750644editdlrm
profile.cpython-310.pyc143910644editdlrm
pstats.cpython-310.pyc236210644editdlrm
pty.cpython-310.pyc41430644editdlrm
pyclbr.cpython-310.pyc97750644editdlrm
pydoc.cpython-310.pyc856450644editdlrm
py_compile.cpython-310.pyc73390644editdlrm
queue.cpython-310.pyc107920644editdlrm
quopri.cpython-310.pyc57940644editdlrm
random.cpython-310.pyc227480644editdlrm
re.cpython-310.pyc142270644editdlrm
reprlib.cpython-310.pyc52500644editdlrm
rlcompleter.cpython-310.pyc59540644editdlrm
runpy.cpython-310.pyc94110644editdlrm
sched.cpython-310.pyc61150644editdlrm
secrets.cpython-310.pyc21750644editdlrm
selectors.cpython-310.pyc171050644editdlrm
shelve.cpython-310.pyc94920644editdlrm
shlex.cpython-310.pyc77820644editdlrm
shutil.cpython-310.pyc385360644editdlrm
signal.cpython-310.pyc29350644editdlrm
site.cpython-310.pyc179220644editdlrm
sitecustomize.cpython-310.pyc2250644editdlrm
smtpd.cpython-310.pyc261470644editdlrm
smtplib.cpython-310.pyc357660644editdlrm
sndhdr.cpython-310.pyc69620644editdlrm
socket.cpython-310.pyc289630644editdlrm
socketserver.cpython-310.pyc253470644editdlrm
sre_compile.cpython-310.pyc151940644editdlrm
sre_constants.cpython-310.pyc63570644editdlrm
sre_parse.cpython-310.pyc217550644editdlrm
ssl.cpython-310.pyc452710644editdlrm
stat.cpython-310.pyc42730644editdlrm
statistics.cpython-310.pyc370510644editdlrm
string.cpython-310.pyc71020644editdlrm
stringprep.cpython-310.pyc170750644editdlrm
struct.cpython-310.pyc3070644editdlrm
subprocess.cpython-310.pyc447410644editdlrm
sunau.cpython-310.pyc164820644editdlrm
symtable.cpython-310.pyc128350644editdlrm
sysconfig.cpython-310.pyc181510644editdlrm
tabnanny.cpython-310.pyc69500644editdlrm
tarfile.cpython-310.pyc706740644editdlrm
telnetlib.cpython-310.pyc185060644editdlrm
tempfile.cpython-310.pyc273390644editdlrm
textwrap.cpython-310.pyc138120644editdlrm
this.cpython-310.pyc12640644editdlrm
threading.cpython-310.pyc449690644editdlrm
timeit.cpython-310.pyc117690644editdlrm
token.cpython-310.pyc27380644editdlrm
tokenize.cpython-310.pyc171940644editdlrm
trace.cpython-310.pyc198700644editdlrm
traceback.cpython-310.pyc217120644editdlrm
tracemalloc.cpython-310.pyc175250644editdlrm
tty.cpython-310.pyc10790644editdlrm
turtle.cpython-310.pyc1288570644editdlrm
types.cpython-310.pyc95250644editdlrm
typing.cpython-310.pyc852770644editdlrm
uu.cpython-310.pyc38670644editdlrm
uuid.cpython-310.pyc224980644editdlrm
warnings.cpython-310.pyc136460644editdlrm
wave.cpython-310.pyc175940644editdlrm
weakref.cpython-310.pyc203430644editdlrm
webbrowser.cpython-310.pyc170000644editdlrm
xdrlib.cpython-310.pyc78800644editdlrm
zipapp.cpython-310.pyc60130644editdlrm
zipfile.cpython-310.pyc618450644editdlrm
zipimport.cpython-310.pyc170330644editdlrm
_aix_support.cpython-310.pyc28790644editdlrm
_bootsubprocess.cpython-310.pyc22940644editdlrm
_collections_abc.cpython-310.pyc329250644editdlrm
_compat_pickle.cpython-310.pyc58720644editdlrm
_compression.cpython-310.pyc45120644editdlrm
_distutils_system_mod.cpython-310.pyc54220644editdlrm
_markupbase.cpython-310.pyc75720644editdlrm
_osx_support.cpython-310.pyc115350644editdlrm
_pydecimal.cpython-310.pyc1577360644editdlrm
_pyio.cpython-310.pyc736540644editdlrm
_py_abc.cpython-310.pyc46830644editdlrm
_sitebuiltins.cpython-310.pyc35470644editdlrm
_strptime.cpython-310.pyc159450644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-310.pyc353850644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-310.pyc353790644editdlrm
_threading_local.cpython-310.pyc65390644editdlrm
_weakrefset.cpython-310.pyc76080644editdlrm
__future__.cpython-310.pyc41310644editdlrm
__phello__.foo.cpython-310.pyc1300644editdlrm
Edit: /snap/core22/2411/usr/lib/python3.10/__pycache__/ipaddress.cpython-310.pyc (62670B)
o `wi/@sdZdZddlZdZdZGdddeZGdd d eZd d Zd=d dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"ZGd#d$d$ZdaejGd%d&d&eZejGd'd(d(eZGd)d*d*ZGd+d,d,eeZGd-d.d.eZGd/d0d0eeZGd1d2d2Zee_Gd3d4d4ZGd5d6d6eeZ Gd7d8d8e Z!Gd9d:d:eeZ"Gd;d<d<Z#e#e _dS)>zA fast, lightweight IPv4/IPv6 manipulation library in Python. This library is used to create/poke/manipulate IPv4 and IPv6 addresses and networks. z1.0N c@eZdZdZdS)AddressValueErrorz%A Value Error related to the address.N__name__ __module__ __qualname____doc__r r /usr/lib/python3.10/ipaddress.pyrrc@r)NetmaskValueErrorz%A Value Error related to the netmask.Nrr r r r rr rc CRzt|WSttfyYnwzt|WSttfy!Ynwt|d)aTake 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 ValueErroraddressr r r ip_addresss  rTc CsVzt||WSttfyYnwzt||WSttfy#Ynwt|d)aTake 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)rstrictr r r ip_network9s  rc Cr)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 IPv6Interfacerrr r r ip_interfaceVs  rcC&z|ddWStytdw)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 IPv4to_bytes OverflowErrorrrr r r v4_int_to_packedxs  r#cCr)zRepresent 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 IPv6r rr r r v6_int_to_packeds   r%cCs,t|d}t|dkrtd||S)zAHelper to split the netmask and raise AddressValueError if needed/zOnly one '/' permitted in )strsplitlenr)raddrr r r _split_optional_netmasks r,ccsPt|}t|}}|D]}|j|jdkr||fV|}|}q ||fVdS)zFind 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)iternext_ip) addressesitfirstlastipr r r _find_address_ranges  r6cCs$|dkr|St|||d@S)zCount 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-)min bit_length)numberbitsr r r _count_righthand_zero_bitss r;ccst|tr t|tstd|j|jkrtd||f||kr%td|jdkr-t}n |jdkr5t}ntd|j}|j}|j}||krvt t ||||d d}||||f}|V|d|>7}|d|j krpdS||ksFdSdS) aSummarize 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%%s and %s are not of the same versionz*last IP address must be greater than firstrzunknown IP versionr-N) isinstance _BaseAddress TypeErrorversionrrr_max_prefixlenr0r7r;r8 _ALL_ONES)r3r4r5ip_bits first_intlast_intnbitsnetr r r summarize_address_ranges:      rIccst|}i}|r-|}|}||}|dur|||<n ||kr+||=|||s d}t|D]}|durB|j|jkrBq5|V|}q5dS)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)listpopsupernetgetappendsortedvaluesbroadcast_address)r1to_mergesubnetsrHrLexistingr4r r r _collapse_addresses_internals*     rUc Cs(g}g}g}|D]l}t|tr)|r#|dj|jkr#td||df||q|j|jkr[|rC|dj|jkrCtd||dfz||jWqtyZ||j Yqw|ro|dj|jkrotd||df||qt t |}|rt |D] \}}| t||qt||S)aCollapse 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. r<)r>r?_versionr@rN _prefixlenrBr5AttributeErrornetwork_addressrOsetr6extendrIrU)r1addrsipsnetsr5r3r4r r r collapse_addresses0s<       r`cCs(t|tr |St|tr|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. )r> _BaseNetwork_get_networks_keyr?_get_address_keyNotImplemented)objr r r get_mixed_type_keyfs  rfc@seZdZdZdZeddZeddZeddZed d Z d d Z d dZ e ddZ e ddZe ddZe ddZe ddZe ddZddZdS)_IPAddressBasezThe mother class.r cC|S)z:Return the longhand version of the IP address as a string.)_explode_shorthand_ip_stringselfr r r explodedz_IPAddressBase.explodedcCt|S)z;Return the shorthand version of the IP address as a string.r(rjr r r compressedrmz_IPAddressBase.compressedcCrh)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_pointerrjr r r reverse_pointer z_IPAddressBase.reverse_pointercCdt|f}t|)Nz%200s has no version specifiedtypeNotImplementedErrorrkmsgr r r rAsz_IPAddressBase.versioncCsF|dkrd}t|||jf||jkr!d}t|||j|jfdS)Nrz-%d (< 0) is not permitted as an IPv%d addressz2%d (>= 2**%d) is not permitted as an IPv%d address)rrWrCrB)rkrryr r r _check_int_addresss  z!_IPAddressBase._check_int_addresscCs.t|}||krd}t|||||jfdS)Nz6%r (len %d != %d) is not permitted as an IPv%d address)r*rrW)rkr expected_len address_lenryr r r _check_packed_addresssz$_IPAddressBase._check_packed_addresscCs|j|j|?AS)zTurn the prefix length into a bitwise netmask Args: prefixlen: An integer, the prefix length. Returns: An integer. )rC)cls prefixlenr r r _ip_int_from_prefixs z"_IPAddressBase._ip_int_from_prefixc Cs\t||j}|j|}||?}d|>d}||kr,|jd}||d}d}t|||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;rBr!r) r~ip_inttrailing_zeroesr leading_onesall_onesbyteslendetailsryr r r _prefix_from_ip_ints      z"_IPAddressBase._prefix_from_ip_intcCsd|}t|d)Nz%r is not a valid netmask)r)r~ netmask_strryr r r _report_invalid_netmasks z&_IPAddressBase._report_invalid_netmaskcCsj|r|s ||zt|}Wnty!||Ynwd|kr-|jks3n|||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)isasciiisdigitrintrrB)r~ prefixlen_strrr r r _prefix_from_prefix_strings    z)_IPAddressBase._prefix_from_prefix_stringcCsz||}Wnty||Ynwz||WSty%Ynw||jN}z||WSty@||YdSw)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_stringrrrrrC)r~ip_strrr r r _prefix_from_ip_strings       z%_IPAddressBase._prefix_from_ip_stringcCsHt|ttfr ||jfSt|tst|}t|dkr|S|d|jfS)zHelper function to parse address of Network/Interface. Arg: address: Argument of Network/Interface. Returns: (addr, prefix) tuple. r-r)r>bytesrrBtupler,r*)r~rr r r _split_addr_prefixs   z!_IPAddressBase._split_addr_prefixcCs|jt|ffSN) __class__r(rjr r r __reduce__-z_IPAddressBase.__reduce__N)rrr r __slots__propertyrlrprrrArzr} classmethodrrrrrrrr r r r rgs4          !  rgcsteZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZfddZZS)r?zA generic IP object. This IP class contains the version independent methods which are used by single IP addresses. r cC|jSrr0rjr r r __int__>sz_BaseAddress.__int__cCs2z |j|jko |j|jkWStytYSwr)r0rWrYrdrkotherr r r __eq__As   z_BaseAddress.__eq__cCsFt|tstS|j|jkrtd||f|j|jkr!|j|jkSdSNr<F)r>r?rdrWr@r0rr r r __lt__Hs    z_BaseAddress.__lt__cCs t|tstS|t||Srr>rrdrrr r r __add__T z_BaseAddress.__add__cCs t|tstS|t||Srrrr r r __sub__Yrz_BaseAddress.__sub__cCd|jjt|fSNz%s(%r)rrr(rjr r r __repr__^z_BaseAddress.__repr__cCst||jSr)r(_string_from_ip_intr0rjr r r __str__arz_BaseAddress.__str__cCsttt|jSr)hashhexrr0rjr r r __hash__dsz_BaseAddress.__hash__cCs |j|fSrrWrjr r r rcgs z_BaseAddress._get_address_keycCs|j|jffSr)rr0rjr r r rjsz_BaseAddress.__reduce__cs|r|ddkrtt||Stdurddl}|dat|}|s)t|S|\}}}|dkr>|j dkrd?Z%ed@dAZ&edBdCZ'edDdEZ(d-S)Graz}A generic IP network object. This IP class contains the version independent methods which are used by networks. cCrrrrjr r r rrz_BaseNetwork.__repr__cCd|j|jfSN%s/%d)rZrrjr r r rrz_BaseNetwork.__str__ccs:t|j}t|j}t|d|D]}||VqdS)zGenerate Iterator over usable hosts in a network. This is like __iter__ except it doesn't return the network or broadcast addresses. r-NrrZrQrange_address_classrknetwork broadcastrr r r hostss   z_BaseNetwork.hostsccs:t|j}t|j}t||dD]}||VqdSNr-rrr r r __iter__s   z_BaseNetwork.__iter__cCsht|j}t|j}|dkr|||krtd|||S|d7}|||kr-td|||S)Nrzaddress out of ranger-)rrZrQ IndexErrorr)rkrrrr r r __getitem__s    z_BaseNetwork.__getitem__cCs^t|tstS|j|jkrtd||f|j|jkr!|j|jkS|j|jkr-|j|jkSdSr)r>rardrWr@rZnetmaskrr r r rs      z_BaseNetwork.__lt__cCsFz|j|jko|j|jkot|jt|jkWSty"tYSwr)rWrZrrrYrdrr r r rs   z_BaseNetwork.__eq__cCstt|jt|jASr)rrrZrrjr r r rsz_BaseNetwork.__hash__cCs4|j|jkrdSt|trdS|j|jj@|jjkSNF)rWr>rar0rrZrr r r __contains__s  z_BaseNetwork.__contains__cCs(|j|vp|j|vp|j|vp|j|vS)z*Tell if self is partly contained in other.)rZrQrr r r overlapss   z_BaseNetwork.overlapscCs|t|jt|jBSr)rrrZhostmaskrjr r r rQs z_BaseNetwork.broadcast_addresscCs|t|j|jASr)rrrrCrjr r r rsz_BaseNetwork.hostmaskcCrr)rZrXrjr r r with_prefixlenz_BaseNetwork.with_prefixlencCrN%s/%s)rZrrjr r r with_netmaskrz_BaseNetwork.with_netmaskcCrr)rZrrjr r r with_hostmaskrz_BaseNetwork.with_hostmaskcCst|jt|jdS)z&Number of hosts in the current subnet.r-)rrQrZrjr r r num_addresses sz_BaseNetwork.num_addressescCrt)Nz%%200s has no associated address classrurxr r r rsz_BaseNetwork._address_classcCrr)rXrjr r r rz_BaseNetwork.prefixlenccs |j|jkstd||ft|tstd|||s'td||f||kr-dS|d|j|jf}| \}}||kru||kru||rU|V| \}}n||rd|V| \}}n t d|||f||kru||ksF||kr~|VdS||kr|VdSt d|||f)aRemove 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. r<z%s is not a network objectz%s not contained in %sNrz3Error performing exclusion: s1: %s s2: %s other: %s) rWr@r>ra subnet_ofrrrZrrSAssertionError)rkrs1s2r r r address_excludesB $         z_BaseNetwork.address_excludecCs`|j|jkrtd||f|j|jkrdS|j|jkrdS|j|jkr&dS|j|jkr.dSdS)aCompare 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 typerVr-r)rWr@rZrrr r r compare_networksgs !    z_BaseNetwork.compare_networkscCs|j|j|jfS)zNetwork-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(). )rWrZrrjr r r rbsz_BaseNetwork._get_networks_keyr-Nc cs|j|jkr |VdS|dur&||jkrtd|dkr!td||j}|dkr.td|j|}||jkr@td||ft|j}t|jd}t|jd|?}t|||D] }|||f}|Vq[dS)aThe 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-(cannot set prefixlen_diff and new_prefixrzprefix length diff must be > 0z0prefix length diff %d is invalid for netblock %s) rXrBrrrZrQrrr) rkprefixlen_diff new_prefix new_prefixlenstartendstepnew_addrcurrentr r r rSs4      z_BaseNetwork.subnetscCs|jdkr|S|dur!||jkrtd|dkrtd|j|}|j|}|dkr3td|j|f|t|jt|j|>@|fS)aThe 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-rz;current prefixlen is %d, cannot have a prefixlen_diff of %d)rXrrrrrZr)rkrrrr r r rLs&    z_BaseNetwork.supernetcC|jjo|jjSzTest 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. )rZ is_multicastrQrjr r r r z_BaseNetwork.is_multicastcCs^z|j|jkrt|d|d|j|jko|j|jkWSty.td|d|w)Nz and z are not of the same versionz*Unable to test subnet containment between )rWr@rZrQrY)arr r r _is_subnet_of s    z_BaseNetwork._is_subnet_ofcCs |||S)z1Return True if this network is a subnet of other.rrr r r r z_BaseNetwork.subnet_ofcCs |||S)z3Return True if this network is a supernet of other.rrr r r supernet_ofrz_BaseNetwork.supernet_ofcCr)Test if the address is otherwise IETF reserved. Returns: A boolean, True if the address is within one of the reserved IPv6 Network ranges. )rZ is_reservedrQrjr r r rrz_BaseNetwork.is_reservedcCrzTest if the address is reserved for link-local. Returns: A boolean, True if the address is reserved per RFC 4291. )rZ is_link_localrQrjr r r r+sz_BaseNetwork.is_link_localcCr)zTest 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. )rZ is_privaterQrjr r r r6rz_BaseNetwork.is_privatecC|j S)zTest 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. rrjr r r is_globalBrsz_BaseNetwork.is_globalcCr)Test if the address is unspecified. Returns: A boolean, True if this is the unspecified address as defined in RFC 2373 2.5.2. )rZis_unspecifiedrQrjr r r rMrz_BaseNetwork.is_unspecifiedcCr)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. )rZ is_loopbackrQrjr r r rYrz_BaseNetwork.is_loopback)r-N))rrr r rrrrrrrrrr functoolscached_propertyrQrrrrrrrrrrrbrSrLr staticmethodrrrrrrrrrr r r r rasf            K0 5)         rac@seZdZdZdZdZdedZeZiZ ddZ e dd Z e d d Z e d d Ze ddZddZeddZeddZdS)_BaseV4zyBase IPv4 object. The following methods are used by IPv4 objects in both single IP addresses and networks. r rr'r-cCrnrrorjr r r rixsz$_BaseV4._explode_shorthand_ip_stringcCs||jvrBt|tr|}d|kr|jksn||nz||}Wnty3||}Ynwt| |}||f|j|<|j|SaMake 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_cacher>rrBrrrrrrr~argrrr r r _make_netmask{s    z_BaseV4._make_netmaskc Csp|std|d}t|dkrtd|z tt|j|dWSty7}z td||fdd}~ww)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.rzExpected 4 octets in %rr%s in %rN)rr)r*r from_bytesmap _parse_octetr)r~roctetsexcr r r rs   z_BaseV4._ip_int_from_stringcCs|std|r|sd}t||t|dkr$d}t|||dkr6|ddkr6d}t||t|d}|d krEtd ||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 %rz$At most 3 characters permitted in %rrrz%Leading zeros are not permitted in %r zOctet %d (> 255) not permitted)rrrr*r)r~ octet_strry octet_intr r r rs      z_BaseV4._parse_octetcCsdtt|ddS)zTurns 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. rrr)joinrr(r!)r~rr r r rs z_BaseV4._string_from_ip_intcCs&t|dddd}d|dS)zReturn the reverse DNS pointer name for the IPv4 address. This implements the method described in RFC1035 3.5. rNrVz .in-addr.arpa)r(r)r)rkreverse_octetsr r r rqz_BaseV4._reverse_pointercCrrrBrjr r r max_prefixlenrz_BaseV4.max_prefixlencCrrrrjr r r rArz_BaseV4.versionN)rrr r rrW IPV4LENGTHrCrBr rirrrrrrqrr"rAr r r r r es*    #   r c@seZdZdZdZddZeddZeddZee d d Z ee d d Z ed dZ eddZeddZeddZdS)rz/Represent and manipulate single IPv4 Addresses.)r0 __weakref__cCstt|tr||||_dSt|tr#||dt|d|_dSt|}d|vr2td|| ||_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. Nrrr&Unexpected '/' in ) r>rrzr0rr}rr(rrrkraddr_strr r r __init__s    zIPv4Address.__init__cC t|jSz*The binary representation of this address.)r#r0rjr r r packed zIPv4Address.packedcC ||jjvS)zTest if the address is otherwise IETF reserved. Returns: A boolean, True if the address is within the reserved IPv4 Network range. ) _constants_reserved_networkrjr r r r  zIPv4Address.is_reservedcs4tfddjjDotfddjjDS)``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|]}|vVqdSrr .0rHrjr r =z)IPv4Address.is_private..c3|]}|vVqdSrr r3rjr r r5>r6)anyr._private_networksall_private_networks_exceptionsrjr rjr r+szIPv4Address.is_privatecCs||jjvo |j Sar``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``. )r._public_networkrrjr r r rAszIPv4Address.is_globalcCr-)zTest if the address is reserved for multicast use. Returns: A boolean, True if the address is multicast. See RFC 3171 for details. r._multicast_networkrjr r r rSr0zIPv4Address.is_multicastcCs ||jjkS)zTest if the address is unspecified. Returns: A boolean, True if this is the unspecified address as defined in RFC 5735 3. )r._unspecified_addressrjr r r r^r0zIPv4Address.is_unspecifiedcCr-)zTest if the address is a loopback address. Returns: A boolean, True if the address is a loopback per RFC 3330. )r._loopback_networkrjr r r ri zIPv4Address.is_loopbackcCr-)zTest if the address is reserved for link-local. Returns: A boolean, True if the address is link-local per RFC 3927. r._linklocal_networkrjr r r rsrBzIPv4Address.is_link_localN)rrr r rr(rr+rr lru_cacherrrrrrr r r r rs,#         rc@sxeZdZddZejddZddZddZd d Z d d Z e j Z e d dZe ddZe ddZe ddZdS)rcCD||\}}t||t||fdd|_|jj|_|jj|_dSNF)r)rrr(rrrrXrkrr+maskr r r r(   zIPv4Interface.__init__cC|jjSrrrrjr r r rzIPv4Interface.hostmaskcCd||j|jfSrrr0rXrjr r r rs zIPv4Interface.__str__cC@t||}|tus |s|Sz|j|jkWStyYdSwr)rrrdrrYrkr address_equalr r r r   zIPv4Interface.__eq__cCsLt||}|tur tSz|j|jkp|j|jko|WSty%YdSwr)rrrdrrYrkr address_lessr r r r   zIPv4Interface.__lt__cCt|j|jt|jjfSrrr0rXrrrZrjr r r rzIPv4Interface.__hash__cCr)r)rr0rjr r r r5 zIPv4Interface.ipcCrNrrOrjr r r r zIPv4Interface.with_prefixlencCrNrrr0rrjr r r rr[zIPv4Interface.with_netmaskcCrNrrr0rrjr r r rr[zIPv4Interface.with_hostmaskN)rrr r(rr rrrrrrgrrr5rrrr r r r r~s"      rc@s2eZdZdZeZdddZee ddZ 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||\}t|_||\|_|_t|j}|t|j@|kr5|r+td|t|t|j@|_|j|jdkrC|j |_ dS|j|jkrRfdd|_ dSdS)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 setr-c tgSr)rr r+r r  z&IPv4Network.__init__..N) rrrZrrrXrrrBrrrkrrrIr+r rar r(s#     zIPv4Network.__init__cCs&|jtdvo |jtdv o|j S)zTest 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)rZrrQrrjr r r rs  zIPv4Network.is_globalNT) rrr r rrr(rrrErr r r r rs 4rc@seZdZedZedZedZedZededededededed ed ed ed ed edededgZededgZ edZ e dZ dS)_IPv4Constantsz169.254.0.0/16z 127.0.0.0/8z 224.0.0.0/4rez 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/24z 240.0.0.0/4z255.255.255.255/32z 192.0.0.9/32z 192.0.0.10/32z0.0.0.0N) rrr rrDrAr?r=r9r;r/rr@r r r r rgs2 rgc@seZdZdZdZdZdedZdZe dZ eZ iZ e dd Ze d d Ze d d Ze ddZe dddZddZddZeddZeddZeddZdS)_BaseV6zyBase IPv6 object. The following methods are used by IPv6 objects in both single IP addresses and networks. r r=r'r-r0123456789ABCDEFabcdefcCsl||jvr1t|tr|}d|kr|jksn||n||}t||}||f|j|<|j|Sr )r r>rrBrrrrrr r r rPs    z_BaseV6._make_netmaskc Cs|std|d}d}t||krd||f}t|d|dvrVz t|j}WntyA}z td||fdd}~ww|d |d ?d @|d |d @|jd }t||krmd |d |f}t|d}td t|d D]} || s|durd|}t|| }qx|dur|} t||d } |ds| d 8} | rd}t|||ds| d 8} | rd}t|||j| | } | d krd}t||jd |fn3t||jkrd}t||j|f|dsd}t|||dsd}t||t|} d} d} z7d} t| D]} | d K} | | || O} q| d | K} t| dD]} | d K} | | || O} q/| WSt yX}z td||fdd}~ww)zTurn 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. r:rz At least %d parts expected in %rrrVrN%xr$r-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 %r) rr)r*rrKr0rN _HEXTET_COUNTr _parse_hextetr)r~rparts _min_partsryipv4_intr _max_parts skip_indexiparts_hiparts_lo parts_skippedrr r r rds             z_BaseV6._ip_int_from_stringcCs>|j|s td|t|dkrd}t||t|dS)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_DIGITS issupersetrr*r)r~ hextet_strryr r r rns     z_BaseV6._parse_hextetc Csd}d}d}d}t|D]\}}|dkr'|d7}|dkr|}||kr&|}|}q d}d}q |dkrO||}|t|kr?|dg7}dg|||<|dkrOdg|}|S)aCompresses 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. rVrrr-) enumerater*) r~hextetsbest_doublecolon_startbest_doublecolon_lendoublecolon_startdoublecolon_lenindexhextetbest_doublecolon_endr r r _compress_hextetss2   z_BaseV6._compress_hextetsNcsZ|dur t|j}||jkrtdd|fddtdddD}||}d |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 large%032xcs&g|]}dt||ddqS)rkrr$)rr4rhex_strr r +s&z/_BaseV6._string_from_ip_int..rrrrj)rr0rCrrrr)r~rr}r rr rs    z_BaseV6._string_from_ip_intcst|tr t|j}nt|trt|j}nt|}||}d|fddtdddD}t|ttfrAdd ||j fSd |S) zExpand a shortened IPv6 address. Args: ip_str: A string, the IPv6 address. Returns: A string, the expanded IPv6 address. rcsg|] }||dqS)rr rrr r rCsz8_BaseV6._explode_shorthand_ip_string..rrrrrj) r>rr(rZrr5rrrarrX)rkrrror rr ri0s     z$_BaseV6._explode_shorthand_ip_stringcCs&|jddddd}d|dS)zReturn the reverse DNS pointer name for the IPv6 address. This implements the method described in RFC3596 2.5. NrVrjr{rz .ip6.arpa)rlreplacer)rk reverse_charsr r r rqHr z_BaseV6._reverse_pointercCs@|d\}}}|sd}||fS|rd|vrtd|||fS)zHelper 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)rr+sepscope_idr r r _split_scope_idQs  z_BaseV6._split_scope_idcCrrr!rjr r r r"erz_BaseV6.max_prefixlencCrrrrjr r r rAirz_BaseV6.versionr)rrr r rrW IPV6LENGTHrCrm frozensetrxrBr rrrrnrrrirqr rrr"rAr r r r rh<s6   g  /   rhcseZdZdZdZddZfddZddZfd d Ze d d Z e d dZ e ddZ e ddZ e ddZe ddZe eddZe ddZe ddZe ddZe dd Ze d!d"Ze d#d$ZZS)%rz/Represent and manipulate single IPv6 Addresses.)r0 _scope_idr$cCst|tr||||_d|_dSt|tr)||dt|d|_d|_dSt|}d|vr8t d|| |\}|_| ||_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. Nr$rr&r%) r>rrzr0rrr}rr(rrrr&r r r r(ts    zIPv6Address.__init__cs"t}|jr|d|jS|S)Nr)rrr)rkrrr r rs zIPv6Address.__str__cCst|j|jfSr)rr0rrjr r r rrzIPv6Address.__hash__cs2t|}|tur tS|sdS|jt|ddkS)NFr)rrrdrgetattrrQrr r rs zIPv6Address.__eq__cCr)zIdentifier 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. )rrjr r r rs zIPv6Address.scope_idcCr)r*)r%r0rjr r r r+r,zIPv6Address.packedcCr-rr>rjr r r rr0zIPv6Address.is_multicastcstfddjjDS)rc3r2rr rrjr r r5r6z*IPv6Address.is_reserved..)r8r._reserved_networksrjr rjr rs zIPv6Address.is_reservedcCr-rrCrjr r r rrBzIPv6Address.is_link_localcCr-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._sitelocal_networkrjr r r is_site_locals zIPv6Address.is_site_localcsHj}|dur |jStfddjjDo#tfddjjDS)r1Nc3r2rr r3rjr r r5r6z)IPv6Address.is_private..c3r7rr r3rjr r r5r6) ipv4_mappedrr8r.r9r:r;)rkrr rjr rs zIPv6Address.is_privatecCrr<rrjr r r rszIPv6Address.is_globalcC |jdkS)rrrrjr r r r zIPv6Address.is_unspecifiedcCr)rr-rrjr r r rrzIPv6Address.is_loopbackcCs |jd?dkr dSt|jd@S)zReturn the IPv4 mapped address. Returns: If the IPv6 address is a v4 mapped address, return the IPv4 mapped address. Return None otherwise. rrlNr0rrjr r r r*s zIPv6Address.ipv4_mappedcCs4|jd?dkr dSt|jd?d@t|jd@fS)zTuple 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@rrrjr r r teredo7s  zIPv6Address.teredocCs$|jd?dkr dSt|jd?d@S)zReturn 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 NPrrrjr r r sixtofourFs zIPv6Address.sixtofour)rrr r rr(rrrrrr+rrrrrrErrrrrrrrr r rr rnsD (              rcseZdZddZejddZfddZddZd d Z d d Z e j Z e d dZe ddZe ddZe ddZe ddZe ddZZS)rcCrFrG)rrr(rrrrXrHr r r r(VrJzIPv6Interface.__init__cCrKrrLrjr r r r^rMzIPv6Interface.hostmaskcsdt|jfSr)rrrXrjrr r rbs zIPv6Interface.__str__cCrPr)rrrdrrYrQr r r rfrSzIPv6Interface.__eq__cCsLt||}|tur |Sz|j|jkp|j|jko|WSty%YdSwr)rrrdrrYrTr r r rrrVzIPv6Interface.__lt__cCrWrrXrjr r r r~rYzIPv6Interface.__hash__cCr)r)rr0rjr r r r5rZzIPv6Interface.ipcCrNrrOrjr r r rr[zIPv6Interface.with_prefixlencCrNrr\rjr r r rr[zIPv6Interface.with_netmaskcCrNrr]rjr r r rr[zIPv6Interface.with_hostmaskcC|jdko|jjS)Nr)r0rrrjr r r rzIPv6Interface.is_unspecifiedcCrr)r0rrrjr r r rrzIPv6Interface.is_loopback)rrr r(rr rrrrrrgrrr5rrrrrrr r rr rTs*         rc@s2eZdZdZeZd ddZddZeddZ 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 Tcr^)aInstantiate 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_r-cr`r)rr rar r rbrcz&IPv6Network.__init__..N) rrrZrrrXrrrBrrrdr rar r(s     zIPv6Network.__init__ccs>t|j}t|j}t|d|dD]}||VqdS)zGenerate Iterator over usable hosts in a network. This is like __iter__ except it doesn't return the Subnet-Router anycast address. r-Nrrr r r rs   zIPv6Network.hostscCrr)rZrrQrjr r r rs zIPv6Network.is_site_localNrf) rrr r rrr(rrrr r r r rs 0 rc@seZdZedZedZededededededed ed ed edg Zed ed ededededgZededededededededededededededed gZed!Z d"S)#_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/128z 2001: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) rrr rrDr?r9r;rrr r r r rs>       rrf)$r __version__rr#rrrrrrrr#r%r,r6r;rIrUr`rfrgrtotal_orderingr?rar rrrrgr.rhrrrrr r r r s\ "7163kH CR&4gK\ -