Server IP : 184.154.167.98 / Your IP : 3.16.130.151 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 8.2.26 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python3.6/site-packages/netaddr/contrib/__pycache__/ |
Upload File : |
3 ��]� � @ s( d dl mZmZmZ G dd� de�ZdS )� )� IPNetwork�cidr_exclude� cidr_mergec @ s2 e Zd ZdZdd� Zddd�Zdd� Zd d � ZdS )�SubnetSplitterz� A handy utility class that takes a single (large) subnet and allows smaller subnet within its range to be extracted by CIDR prefix. Any leaving address space is available for subsequent extractions until all space is exhausted. c C s t t|�g�| _dS )z� Constructor. :param base_cidr: an IPv4 or IPv6 address with a CIDR prefix. (see IPNetwork.__init__ for full details). N)�setr �_subnets)�selfZ base_cidr� r �%/usr/lib/python3.6/subnet_splitter.py�__init__ s zSubnetSplitter.__init__Nc C sZ xT| j � D ]H}t|j||d��}|s&q | j|� | jjtt|t|�d ���| _|S W g S )z;Extract 1 or more subnets of size specified by CIDR prefix.)�countr ) �available_subnets�listZsubnet� remove_subnetr �unionr r r )r �prefixr ZcidrZsubnetsr r r �extract_subnet s zSubnetSplitter.extract_subnetc C s t | jdd� dd�S )z2Returns a list of the currently available subnets.c S s | j S )N)Z prefixlen)�xr r r �<lambda>* s z2SubnetSplitter.available_subnets.<locals>.<lambda>T)�key�reverse)�sortedr )r r r r r ( s z SubnetSplitter.available_subnetsc C s | j j|� dS )z:Remove a specified IPNetwork from available address space.N)r �remove)r Z ip_networkr r r r , s zSubnetSplitter.remove_subnet)N)�__name__� __module__�__qualname__�__doc__r r r r r r r r r s r N)Z netaddr.ipr r r �objectr r r r r �<module> s