Warning: Cannot modify header information - headers already sent by (output started at /var/www/jonas-eriksen.dk/pic/private/index.php:1) in /var/www/jonas-eriksen.dk/pic/private/index.php on line 215
!A?h> d Z dZddlZdZdZ G d de Z G d d e Zd
Zd3dZ 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/ d0e e Z# G d1 d2 Z$e$e!_ e$e#_ dS )4zA 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 ZdZdS )AddressValueErrorz%A Value Error related to the address.N__name__
__module____qualname____doc__ "/usr/lib64/python3.11/ipaddress.pyr r ////r
r c e Zd ZdZdS )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
ValueErroraddresss r
ip_addressr s
7###01
7###01
QQQ
R
RR %%8 AATc 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 s
7F+++01
7F+++01
QQQ
R
RRs &&: 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 s *
W%%%01
W%%%01
SSS
T
TTr c h | 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 IPv4to_bytes
OverflowErrorr r s r v4_int_to_packedr( x sJ C""" C C CABBBC 1c h | d S # t $ r t d w xY w)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.
z&Address negative or too large for IPv6r% r s r v6_int_to_packedr, sJ C### C C CABBBCr) c t | d }t | dk rt d| |S )zAHelper to split the netmask and raise AddressValueError if needed/ zOnly one '/' permitted in )strsplitlenr )r addrs r _split_optional_netmaskr4 sF w<<c""D
4yy1}} HW H HIIIKr
c # K t | }t | x}}|D ]}|j |j dz k r||fV |}|} ||fV dS )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) addressesitfirstlastips r _find_address_ranger? sw
iB88ED
6TX\!!+E
+r
c d | dk r|S t || | dz
z 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.
r r6 )min
bit_length)numberbitss r _count_righthand_zero_bitsrE s9 {{tvg*6688999r
c # j K t | t rt |t st d | j |j k rt | d|d | |k rt d | j dk rt
}n"| j dk rt }nt d | j }| j }|j }||k rmt t || ||z
dz dz
} ||||z
f }|V |d|z z
}|dz
|j k rd S ||k kd S d 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 networks and are not of the same versionz*last IP address must be greater than firstr$ zunknown IP versionr6 N)
isinstance_BaseAddress TypeErrorversionr r r _max_prefixlenr9 rA rE rB _ALL_ONES)r<