Ë ‚Ö¦i> ã óH — d Z dZddlZdZdZ G d„ de« Z G d„ d e« Zd „ Zd2d„Z d„ Z d „ Zd„ Zd„ Z d„ Zd„ Zd„ Zd„ Zd„ Zd„ Z G d„ d« Zdaej, G d„ de« « Zej, G d„ de« « Z G d„ d« Zee_ G d„ d« Z G d „ d!ee« Z G d"„ d#e« Z G d$„ d%ee« Z G d&„ d'« Zee_ ee_ G d(„ d)« Z G d*„ d+e e« Z! G d,„ d-e!« Z" G d.„ d/e e« Z# G d0„ d1« Z$e$e!_ e$e#_ y)3z•A fast, lightweight IPv4/IPv6 manipulation library in Python. This library is used to create/poke/manipulate IPv4 and IPv6 addresses and networks. z1.0é Né é€ c ó — e Zd ZdZy)ÚAddressValueErrorz%A Value Error related to the address.N©Ú__name__Ú __module__Ú__qualname__Ú__doc__© ó ú"/usr/lib64/python3.12/ipaddress.pyr r ó „ Ú/r r c ó — e Zd ZdZy)ÚNetmaskValueErrorz%A Value Error related to the netmask.Nr r r r r r r r r c ó¢ — t | « S # t t f$ r Y nw xY w t | « S # t t f$ r Y nw xY wt | ›d�« ‚)a® Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP address. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. Returns: An IPv4Address or IPv6Address object. Raises: ValueError: if the *address* passed isn't either a v4 or a v6 address z. does not appear to be an IPv4 or IPv6 address)ÚIPv4Addressr r ÚIPv6AddressÚ ValueError©Úaddresss r Ú ip_addressr sg € ð ܘ7Ó#Ð#øÜÔ0Ð1ò Ùð úð ܘ7Ó#Ð#øÜÔ0Ð1ò Ùð úô ˜�{Ð"PÐQÓ RÐRó ‚ �ž£ . ®A ¿A c ó¦ — t | |« S # t t f$ r Y nw xY w t | |« S # t t f$ r Y nw xY wt | ›d�« ‚)aÐ Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP network. Either IPv4 or IPv6 networks may be supplied; integers less than 2**32 will be considered to be IPv4 by default. Returns: An IPv4Network or IPv6Network object. Raises: ValueError: if the string passed isn't either a v4 or a v6 address. Or if the network has host bits set. z. does not appear to be an IPv4 or IPv6 network)ÚIPv4Networkr r ÚIPv6Networkr )r Ústricts r Ú ip_networkr 9 sk € ð ܘ7 FÓ+Ð+øÜÔ0Ð1ò Ùð úð ܘ7 FÓ+Ð+øÜÔ0Ð1ò Ùð úô ˜�{Ð"PÐQÓ RÐRs ‚ Ž Ÿ ¤0 °AÁAc ó¢ — t | « S # t t f$ r Y nw xY w t | « S # t t f$ r Y nw xY wt | ›d�« ‚)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. z0 does not appear to be an IPv4 or IPv6 interface)Ú IPv4Interfacer r Ú IPv6Interfacer r s r Úip_interfacer" V sg € ð* ܘWÓ%Ð%øÜÔ0Ð1ò Ùð úð ܘWÓ%Ð%øÜÔ0Ð1ò Ùð úô ˜�{Ð"RÐSÓ TÐTr c óV — | j d« S # t $ r t d« ‚w xY w)a` Represent an address as 4 packed bytes in network (big-endian) order. Args: address: An integer representation of an IPv4 IP address. Returns: The integer address packed as 4 bytes in network (big-endian) order. Raises: ValueError: If the integer is negative or too large to be an IPv4 IP address. é z&Address negative or too large for IPv4©Úto_bytesÚ OverflowErrorr r s r Úv4_int_to_packedr( x s6 € ðCØ×Ñ Ó"Ð"øÜò CÜÐAÓBÐBðCúó ‚ “(c óV — | j d« S # t $ r t d« ‚w xY w)zõRepresent an address as 16 packed bytes in network (big-endian) order. Args: address: An integer representation of an IPv6 IP address. Returns: The integer address packed as 16 bytes in network (big-endian) order. é z&Address negative or too large for IPv6r% r s r Úv6_int_to_packedr, Œ s6 € ðCØ×Ñ Ó#Ð#øÜò CÜÐAÓBÐBðCúr) c ór — t | « j d« }t |« dkD rt d| ›�« ‚|S )zAHelper to split the netmask and raise AddressValueError if neededÚ/é zOnly one '/' permitted in )ÚstrÚsplitÚlenr )r Úaddrs r Ú_split_optional_netmaskr4 œ s9 € äˆw‹<×јcÓ"€DÜ ˆ4ƒy�1‚}ÜÐ"<¸W¸KÐ HÓIÐIØ€Kr c # ó¢ K — t | « }t |« x}}|D ]( }|j |j dz k7 r||f–— |}|}Œ* ||f–— yw)zÏFind a sequence of sorted deduplicated IPv#Address. Args: addresses: a list of IPv#Address objects. Yields: A tuple containing the first and last IP addresses in the sequence. é N)ÚiterÚnextÚ_ip)Ú addressesÚitÚfirstÚlastÚips r Ú_find_address_ranger? ¤ s] è ø€ ô ˆi‹€Bܘ“8ЀEˆDÛˆØ �6‰6�T—X‘X ‘\Ò!ؘ�+ÒØˆE؉ð ð �ˆ+Óùs ‚A Ac óR — | dk( r|S t || | dz z 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 r6 )ÚminÚ bit_length)ÚnumberÚbitss r Ú_count_righthand_zero_bitsrE ¸ s1 € ð �‚{؈܈t�v�g ¨¡Ñ*×6Ñ6Ó8Ó9Ð9r c # óV K — t | t « rt |t « st d« ‚| j |j k7 rt | ›d|›d�« ‚| |kD rt d« ‚| j dk( rt }n!| j dk( rt }nt d« ‚| j }| j }|j }||k r`t t ||« ||z dz j « dz « } ||||z f« }|–— |d|z z }|dz |j k( ry ||k rŒ_y y w) a¤ Summarize a network range given the first and last IP addresses. Example: >>> list(summarize_address_range(IPv4Address('192.0.2.0'), ... IPv4Address('192.0.2.130'))) ... #doctest: +NORMALIZE_WHITESPACE [IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/31'), IPv4Network('192.0.2.130/32')] Args: first: the first IPv4Address or IPv6Address in the range. last: the last IPv4Address or IPv6Address in the range. Returns: An iterator of the summarized IPv(4|6) network objects. Raise: TypeError: If the first and last objects are not IP addresses. If the first and last objects are not the same version. ValueError: If the last object is not greater than the first. If the version of the first address is not 4 or 6. z1first and last must be IP addresses, not networksú and ú are not of the same versionz*last IP address must be greater than firstr$ é zunknown IP versionr6 N) Ú isinstanceÚ_BaseAddressÚ TypeErrorÚversionr r r Ú_max_prefixlenr9 rA rE rB Ú _ALL_ONES)r<