Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/libcloud/utils/__pycache__/networking.cpython-39.pyc
Ðазад
a r�h| � @ sJ d dl Z d dlZg d�Zdd� Zdd� Ze jfdd�Zd d � Zdd� ZdS ) � N)�is_private_subnet�is_public_subnet�is_valid_ip_address�join_ipv4_segments�increment_ipv4_segmentsc C s� ddd�ddd�ddd�g}t �dt�| ��d } |D ]N}t �dt�|d ��d }t �dt�|d ��d }| |@ ||@ kr6 dS q6d S )z� Utility function to check if an IP address is inside a private subnet. :type ip: ``str`` :param ip: IP address to check :return: ``bool`` if the specified IP address is private. z10.0.0.0z 255.0.0.0)�subnet�maskz 172.16.0.0z255.240.0.0z192.168.0.0z255.255.0.0�Ir r r TF)�struct�unpack�socket� inet_aton)�ipZpriv_subnets�networkr r � r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/libcloud/utils/networking.pyr s �r c C s t | d� S )z� Utility function to check if an IP address is inside a public subnet. :type ip: ``str`` :param ip: IP address to check :return: ``bool`` if the specified IP address is public. �r )r r r r r r 5 s r c C s, zt �|| � W n t jy& Y dS 0 dS )a5 Check if the provided address is valid IPv4 or IPv6 address. :param address: IPv4 or IPv6 address to check. :type address: ``str`` :param family: Address family (socket.AF_INTET / socket.AF_INET6). :type family: ``int`` :return: ``bool`` True if the provided address is valid. FT)r � inet_pton�error)�address�familyr r r r A s r c C s d� dd� | D ��S )z� Helper method to join ip numeric segment pieces back into a full ip address. :param segments: IPv4 segments to join. :type segments: ``list`` or ``tuple`` :return: IPv4 address. :rtype: ``str`` �.c S s g | ]}t |��qS r )�str)�.0�sr r r � <listcomp>` � z&join_ipv4_segments.<locals>.<listcomp>)�join��segmentsr r r r U s r c C s� dd� | D �} | d d7 <