404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.117.145.141: ~ $
3

\�me�[�@s�ddlZddlZddlZddlmZmZddlmZddlmZm	Z	ddl
mZddlm
Z
eje�Zggddd	�Zd
d�Ze	jdd
d�dd��Zdd�Zdd�Zd$dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd%d"d#�ZdS)&�N)�copy�deepcopy)�IPv4Network)�subp�util)�net_prefix_to_ipv4_mask)�SimpleTable�F)�ipv4�ipv6�hwaddr�upcCs\tj|�}i}�xF|D�]<}d|kr,|dng}|jd�dkrF|dnd}|td|ko\d|k�ggd�}x�|jd	g�D]�}|jd
�dkr�d|kr�ttd
|d���j�nd}|jdd�||jdd�|jdd�d�}	|dj|	�qv|d
dkrv|jdd�}
|
�r$|jd��r$|
�d|jdd���}
|
|jdd�d�}	|dj|	�qvW|||d<qW|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)rr
r
rZ	addr_infoZfamily�inet�	prefixlenz0.0.0.0/Zlocal�	broadcast�scope)�ip�mask�bcastrr
�inet6�/�@)r�scope6rZifname)�json�loads�get�bool�strr�netmask�append)Zipaddr_jsonZipaddr_data�devs�devrrZdev_info�addrrZparsed_addrr�r)�/usr/lib/python3.6/netinfo.py�_netdev_info_iproute_json+s6

 

r+z22.1zqRequired by old iproute2 versions that don't support ip json output. Consider upgrading to a more recent version.)Zdeprecated_versionZ
extra_messagecCs�i}d}�x�t|j��D�]�\}}tjd|�}|r~|jd�j�jd�d}|jd�jd�}ggdtd	|kopd
|k�d�||<qd|kr�tjd
|�}|s�tj	d||�q||dj
|j��qd|k�rLtjd|�}|s�tj	d||�q|j�}|jd�}|j
d�\}	}
}|�sd}||dj
|	|d�r4|dndt|�|dd��qd|krtjd|�}|�svtj	d||�q|jd�dk�r�|jd�||d<nd||d<qqqW|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+.*r'�@rr�,r	rr)r
rrr
rz?\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�32r
rr)rrrr�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_outr&Zdev_nameZnum�line�mrr4r.r(�_�prefixr)r)r*�_netdev_info_iprouteasd





rBc
Cs�i}�xz|j�D�]l}t|�dkr$q|ddkrf|j�d}|jd�rR|dd�}||krftt�||<|j�j�j�}t|�dkr�tj	d|d�r�d||d<�x�t
t|��D�]�}||d	kr�||djd
�\}}||dj|t|�d��q�||d
k�r ||d||ddd<q�||dk�rD||d||d<q�||dk�r�||ddk�r�||djd||di�n||djd||di�q�||dk�r�||dddd
||d}|||ddd<q�||j
d��r||jd�||dd d<q�||dkr�tjd||d�}	|	�r^|	jd�||dd!d<q�||d||dd"d<q�WqW|S)#Nr�	� �:�zflags=[x\d]+<up.*>Tr
rrr
)rrrrzaddress:rrzaddr:rr�rzscope:r�scopeidz	.*<(\S+)>)rCrD���rIrIrIrIrIrI)r2�lenr7�endswithr�DEFAULT_NETDEV_INFOr6�stripr3�search�ranger%r�
startswith�lstripr4r5)
�
ifconfig_datar&r>�curdev�toks�iZnetworkZnet_bits�addr6�resr)r)r*�_netdev_info_ifconfig_netbsd�sL
  $ $rXcCs.i}�x"|j�D�]}t|�dkr$q|ddkrf|j�d}|jd�rR|dd�}||krftt�||<|j�j�j�}|ddkr�d||d<n(t|�dkr�tj	d|d�r�d||d<�xjt
t|��D�]X}||d	k�r||d
jd||djd�i�q�||j
d
��r2||jd
�||d
d d<q�||dk�r^||d||d
d!d<q�||j
d��r�||jd�||d
d"d<q�||dk�r�||d||d
d#d<q�||dk�s�||dk�r�||d||d<q�||dk�rL||ddk�r,||djd||di�n||djd||di�q�||dk�r�||dd$dd||d}|||dd%d<q�||j
d��r�||jd�||dd&d<q�||dkr�tjd||d�}|�r|jd�||dd'd<q�||d||dd(d<q�WqW|S))NrrCrDrErFr
Tz
flags=\d+<up,rr
rzaddr:zbcast:rrzmask:rr$rrrrrGrrzscope:rrHz	.*<(\S+)>)rCrDrIrIrIrIrIrIrIrIrIrI)r2rJr7rKrrLr6rMr3rNrOr%rQrPr4r5)rRr&r>rSrTrUrVrWr)r)r*�_netdev_info_ifconfig�sZ
    $ $rYcs�i}tj�r0tjddgddgd�\}}t|�}n�tjd�r�y tjdddg�\}}t|�}Wq�tjk
r�tjddd	g�\}}t|�}Yq�Xn8tjd�r�tjddgddgd�\}}t|�}n
t	j
d
�|dkr�|Sttt
f�d��fd
d�	��||d�|S)NZifconfigz-arrF)�rcsrz--jsonr(Zshowz>Could not print networks: missing 'ip' and 'ifconfig' commandsr	�cspt|t�r|j�}n t|ttf�r,t|�}ntd��x6|D].\}}||krT|||<q:t|��r:�||�q:WdS)zQRecursively replace 'empty_vals' in data (dict, tuple, list)
        with new_valzUnexpected input to fillN)�
isinstance�dict�items�tuple�listr1�	TypeError)�data�new_valZ
empty_valsZmyiter�key�val)�fill�
recurse_typesr)r*rf9s




znetdev_info.<locals>.fill)rc�r	r[)r	rh)rZ	is_NetBSDrrX�whichr+�ProcessExecutionErrorrBrYr8r9r]r_r`)�emptyr&Z	ifcfg_out�_errr=r))rfrgr*�netdev_infos,




rmcCs�i}g|d<g|d<|j�}ddddddd�}�x<|D�]2}t|�}|sJq6|j�}dg}|ddkrvd|d	<d|d
<n^d|dkr�|djd�\}}	n"|d}d}	|jd
�t|	�|d
<||d	<t|	�|d
<d|d<xxtt|��D]h}
||
dk�r||
d|d<|jdd�||
dk�r.||
d|d<||
dkr�||
d|d<q�Wdj|�|d<|dj|�q6Wy(t	j	dddddddgddgd�\}}Wnt	j
k
�r�Y�nX|j�}
�x|
D�]�}i}|�s֐q�|j�}|ddk�r�d|d	<d|d<n|d|d	<d |d<d|d<x�tt|��D]�}
||
dk�rR||
d|d<d|d<||
dk�rp||
d|d<||
dk�r�||
d|d<||
d!k�r(|dd"|d<�q(W|dj|��q�W|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.
    r
rr	)�destinationr�gateway�genmask�iface�metric�Ur�defaultz0.0.0.0rnrprr/�HroZviarF�Gr'rqrrrrz	--onelinez-6�router`�table�all)rZz::/0ZUGz::Zexpires�e)r2rr7r%rrOrJ�insert�joinrrj)Ziproute_data�routes�entriesZdefault_route_entryr>�entryrTrr(ZcidrrUZ
iproute_data6�_err6�entries6r)r)r*�_netdev_route_info_iprouteMs�


r�c	Cs4i}g|d<g|d<|j�}x�|D]�}|s,q"|j�}t|�dks"|ddks"|ddks"|ddks"|ddks"|dd	kr~q"t|�d
kr�|jd�|jd�|d|d
<d|d<|d|d|d|d|d|d|d|d
d�}|dj|�q"Wy$tjdddddgddgd�\}}Wntjk
�r6Yn�X|j�}x�|D]�}|�sT�qF|j�}t|�d
k�sF|ddk�sF|ddk�sF|ddk�sF|ddk�sF|ddk�r��qF|d|d|d|d|d|d|dd�}|ddk�r��qF|djd��rtjd d!|d�|d<|dj|��qFW|S)"Nr
r�rZKernel�DestinationZInternetZ	Internet6ZRouting��-��rFrG��)rnrorprrr�ref�userq�netstatz-Arz--routez	--numeric)rZZProtoZActive)rnrorrrr�r�rqrq�lornz/128z\/128$r	)	r2r7rJr%rrjrKr3�sub)	Z
route_datar}r~r>rTrZroute_data6r�r�r)r)r*�_netdev_route_info_netstat�sx
	

 
r�cCsni}tjd�r.tjddddg�\}}t|�}n<tjd�r`tjddddgd	d
gd�\}}t|�}n
tjd�|S)
Nrz-orwr`r�z--routez	--numericz--extendrrF)rZz;Could not print routes: missing 'ip' and 'netstat' commands)rrir�r�r8r9)r}Ziproute_outrlZ	route_outr)r)r*�
route_info�s



r�cCs�g}d}yt|d�}WnDtk
rZ}z&|jtjdjt|�d�dd��WYdd}~X�n2X|sddSdd	d
ddd
g}t|�}x�t|j	��D]�\}}x@|j
d�D]2}|j||d|d|d|j
d|�|df�q�Wx<|j
d�D].}|j||d|d||j
d|�|df�q�Wt|j
d��t|j
d��dkr�|j||d||||df�q�W|j
�}	tt|	j�td��}
tjdd|
�}|j||	g�dj|�dS)N�.)rkz Net device info failed ({error}))�error�!�P�
ZDeviceZUpZAddressZMaskZScopez
Hw-Addressr
r
rrrrrrr)rdzNet device info�+)rm�	Exceptionr%r�center�formatr#r�sortedr^r!�add_rowrJ�
get_string�maxr2�extendr|)�linesrkZnetdevrzZfieldsZtblr'rbr(Znetdev_s�max_len�headerr)r)r*�netdev_pformat
sN

 r�c
CsNg}y
t�}WnTtk
rb}z6|jtjdjt|�d�dd��tjtd|�WYdd}~X�n�X|j	d��rLddd	d
ddg}t
|�}x�t|j	d��D]x\}}t|�}y2|j||d
|j	dd�|d|d|dg�Wq�t
k
�r}ztjtd|�WYdd}~Xq�Xq�W|j�}tt|j�td��}	tjdd|	�}
|j|
|g�|j	d��r@ddd	ddg}t
|�}x�t|j	d��D]�\}}t|�}|ddk�r��q~y,|j||d
|j	dd�|d|dg�Wn4t
k
�r}ztjtd|�WYdd}~XnX�q~W|j�}tt|j�td��}	tjdd|	�}
|j|
|g�dj|�dS)NzRoute info failed ({error}))r�r�r�zRoute info failed: %sr
ZRouter�ZGatewayZGenmaskZ	InterfaceZFlagsrnroz0.0.0.0rprqrzRoute info formatting error: %s)rdzRoute IPv4 infor�rr�z::zRoute IPv6 infor�)r�r�r%rr�r�r#Zlogexcr8r!rr1r��KeyErrorr�rJr�r2r�r|)
r�r}rzZ	fields_v4Ztbl_v4�n�rZroute_idZroute_sr�r�Z	fields_v6Ztbl_v6r)r)r*�
route_pformatAsr
$
&
(r��	ci-info: cCs�g}t�j�}|r4x*|D]}|jd||f�qWn
|j|�t�j�}|rnx*|D]}|jd||f�qRWn
|j|�dj|�S)Nz%s%sr�)r�r2r%r�r�r|)rAr�Znetdev_linesr>Zroute_linesr)r)r*�
debug_info�s





r�)r	)r�)rZloggingr3rrZ	ipaddressrZ	cloudinitrrZcloudinit.net.network_staterZcloudinit.simpletablerZ	getLogger�__name__r8rLr+Zdeprecate_callrBrXrYrmr�r�r�r�r�r�r)r)r)r*�<module>s,
6Q09
0XU4I

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 113 B 0644
__init__.cpython-36.pyc File 113 B 0644
apport.cpython-36.opt-1.pyc File 5.92 KB 0644
apport.cpython-36.pyc File 5.96 KB 0644
atomic_helper.cpython-36.opt-1.pyc File 2.05 KB 0644
atomic_helper.cpython-36.pyc File 2.05 KB 0644
cloud.cpython-36.opt-1.pyc File 3.08 KB 0644
cloud.cpython-36.pyc File 3.08 KB 0644
dmi.cpython-36.opt-1.pyc File 5.32 KB 0644
dmi.cpython-36.pyc File 5.32 KB 0644
event.cpython-36.opt-1.pyc File 1.97 KB 0644
event.cpython-36.pyc File 1.97 KB 0644
features.cpython-36.opt-1.pyc File 1.47 KB 0644
features.cpython-36.pyc File 1.47 KB 0644
gpg.cpython-36.opt-1.pyc File 3.76 KB 0644
gpg.cpython-36.pyc File 3.76 KB 0644
helpers.cpython-36.opt-1.pyc File 13.31 KB 0644
helpers.cpython-36.pyc File 13.31 KB 0644
importer.cpython-36.opt-1.pyc File 1.68 KB 0644
importer.cpython-36.pyc File 1.68 KB 0644
log.cpython-36.opt-1.pyc File 4.61 KB 0644
log.cpython-36.pyc File 4.61 KB 0644
netinfo.cpython-36.opt-1.pyc File 12.67 KB 0644
netinfo.cpython-36.pyc File 12.67 KB 0644
persistence.cpython-36.opt-1.pyc File 2.82 KB 0644
persistence.cpython-36.pyc File 2.82 KB 0644
registry.cpython-36.opt-1.pyc File 1.38 KB 0644
registry.cpython-36.pyc File 1.38 KB 0644
safeyaml.cpython-36.opt-1.pyc File 8 KB 0644
safeyaml.cpython-36.pyc File 8 KB 0644
settings.cpython-36.opt-1.pyc File 1.14 KB 0644
settings.cpython-36.pyc File 1.14 KB 0644
signal_handler.cpython-36.opt-1.pyc File 1.58 KB 0644
signal_handler.cpython-36.pyc File 1.58 KB 0644
simpletable.cpython-36.opt-1.pyc File 2.53 KB 0644
simpletable.cpython-36.pyc File 2.53 KB 0644
ssh_util.cpython-36.opt-1.pyc File 15.36 KB 0644
ssh_util.cpython-36.pyc File 15.36 KB 0644
stages.cpython-36.opt-1.pyc File 25.15 KB 0644
stages.cpython-36.pyc File 25.15 KB 0644
subp.cpython-36.opt-1.pyc File 9.97 KB 0644
subp.cpython-36.pyc File 9.97 KB 0644
temp_utils.cpython-36.opt-1.pyc File 2.81 KB 0644
temp_utils.cpython-36.pyc File 2.81 KB 0644
templater.cpython-36.opt-1.pyc File 4.55 KB 0644
templater.cpython-36.pyc File 4.55 KB 0644
type_utils.cpython-36.opt-1.pyc File 437 B 0644
type_utils.cpython-36.pyc File 437 B 0644
url_helper.cpython-36.opt-1.pyc File 21.03 KB 0644
url_helper.cpython-36.pyc File 21.03 KB 0644
user_data.cpython-36.opt-1.pyc File 8.25 KB 0644
user_data.cpython-36.pyc File 8.25 KB 0644
util.cpython-36.opt-1.pyc File 73.64 KB 0644
util.cpython-36.pyc File 73.64 KB 0644
version.cpython-36.opt-1.pyc File 429 B 0644
version.cpython-36.pyc File 429 B 0644
warnings.cpython-36.opt-1.pyc File 3.25 KB 0644
warnings.cpython-36.pyc File 3.25 KB 0644