%PDF- %PDF-
Direktori : /snap/core20/2379/lib/python3/dist-packages/probert/__pycache__/ |
Current File : //snap/core20/2379/lib/python3/dist-packages/probert/__pycache__/network.cpython-38.pyc |
U T{)_Tk � @ s� d dl Z d dlmZ d dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl mZ e�d�Z zd dlmZmZ W n. ek r� Z ze �de� W 5 dZ[X Y nX dZdZd Zd ZdZdZd ZdZdZdZdZdZdZ dZ!dZ"dZ#dddddddgZ$dddd d!gZ%d"d#gZ&d$d%d&d'd(d)d*d+d,d-gd.d&d'd,d/id,d/id,d0id,d/id,d/id1�d2�d3�d,d/id&d'd,d4id,d4id5d,d/id,d6igid.d,d/id3�d5d/e$d7�d,d6igid5d/e%d7�d,d6igid5d/e&d7�d,d6igid8�d2�d&d9d&d5d,d/id,d6igid:�id5d,d/id,d6igid;�d&d,d0id,d0id,d0id,d0id,d/id<�d=�d&d'd,d4id,d4id.d,d/id3�d&d,d/id:�d>�d2�d&d'd,d6d/gid.d,d/id3�d,d6d/gid?�d2�d@�dA�Z'dBdC� Z(dDdE� Z)dFdG� Z*dHdI� Z+dJdK� Z,G dLdM� dM�Z-dNdOd%dPdQdR�Z.G dSdT� dT�Z/G dUdV� dVe j0�Z1G dWdX� dXe j0�Z2G dYdZ� dZe2�Z3d[d\� Z4d]d^� Z5ej6d_d`� �Z7G dadb� dbe1�Z8G dcdd� dd�Z9G dedf� df�Z:e;dgk�r�d dl<Z<d dl=Z=e8� Z>e>�?� Z@e<�<e>jA� e=�B� ZCe@D ]ZDeC�EeDe=jF� �q�eC�G� ZHeHD ]\ZDZe>�IeD� �q�e<�<e>jA� �q�dS )h� N)�OrderedDict)�udev_get_attributeszprobert.network)�_nl80211� _rtnetlinkz)Failed import network library modules: %s� � � � � � �@ � � � i i i i i @ z balance-rrz active-backupzbalance-xorZ broadcastz802.3adzbalance-tlbzbalance-albZlayer2zlayer2+3zlayer3+4zencap2+3zencap3+4ZslowZfastz'http://json-schema.org/draft-04/schema#�link�objectF� addresses�bond�bridge�netlink_data�type� udev_dataZarray�stringZinteger)�address�ip�family�source�scope)r �additionalProperties� properties)r �itemsZbooleanZoneOfZnull)r �enum�Z is_masterZis_slave�masterZslaves�mode�xmit_hash_policy� lacp_rate�attrs)r r )r r r )�ifindex�flags�arptyper �name)r r �Z is_bridgeZis_portZ interfaces�options)�ssid� visible_ssids� scan_state)r r r r r r �wlan)z$schema�titler r Zrequiredr c C s. | sdS t j�d| �}t j�|�s6t�d�|�� d S d}|dkr�d}t j�t j�|d��srt j�t j�|d��rxd}nxt j�t j�|d ��r�d }n\t j�t j�|d ��r�d}n@t j� t j�|d��r�d }n$t j�t j�d| ��r�| � d�r�d}n�|dk�rd}n�|dk�rNt j�t j�|d ���r*d}n"t j�t j�|d���rHd}nd}n�|dk�r^d}n~|dk�rnd}nn|dk�r~d}n^|dk�r�d}nN|dk�r�d}n>|dk�r�d }n.|d!k�r�d"}n|d#k�r�d$}n|d%k�r�d&}| � d'��s�| � d(��r�d(}n| � d)��r d)}t|�d*k�r*td+�| �� d S |S ),Nz???�/sys/class/netzNo sysfs path to {}r ZethZwirelessZphy80211r1 r Zbondingr Z tun_flagsZtapz/sys/devices/virtual/netZdummy� r Zcreate_childZibZibchildr Zpppi Zipipi Zip6tnli �loi Zsiti Zgrei Zirdai! Zwlan_auxi�� ZtunZipppZisdnZmip6mnhar z)Failed to determine interface type for {}) �os�path�join�exists�log�debug�format�isdir�islink�isfile� startswith�len�print)Zifacer* Z sysfs_pathZDEV_TYPE� rC �1/usr/lib/python3/dist-packages/probert/network.py� _compute_type� st �� rE c sj �fdd�� �fdd��� �fdd�}��fdd�}� �fd d �}� � �� |� |� |d�|d�|d �d�S )Nc s t � t@ �dkS �Nr )�bool� IFF_MASTERrC �r) rC rD �_iface_is_master s z&_get_bonding.<locals>._iface_is_masterc s t � t@ �dkS rF )rG � IFF_SLAVErC rI rC rD �_iface_is_slave s z%_get_bonding.<locals>._iface_is_slavec sH z*� � r"t d� ��� } | �� W S g W S W n tk rB g Y S X d S )Nz /sys/class/net/%s/bonding/slaves��open�read�split�IOError)r �rJ �ifnamerC rD �_get_slave_iface_list s z+_get_bonding.<locals>._get_slave_iface_listc sH z,� � r$t �d� �} t j�| �W S W d S W n tk rB Y d S X d S )Nz/sys/class/net/%s/master)r6 �readlinkr7 �basenamerQ )r# )rL rS rC rD �_get_bond_master s z&_get_bonding.<locals>._get_bond_masterc sd zH� � rFd�| f }t |��}|�� �� }W 5 Q R X |r@|d nd W S W n tk r^ Y d S X d S )Nz/sys/class/net/%s/bonding/%sr rM )ZparamZ bond_paramZbprR rC rD �_get_bond_param( s z%_get_bonding.<locals>._get_bond_paramr$ r% r&