HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/iwtools.cpython-310.pyc
o

�N�g��@sZdZddlZddlZddlmZe�e�Zdd�Z	ddd�Z
dd	�Zd
d�Zddd
�Z
dS)z&
Support for Wireless Tools for Linux
�N)�SaltInvocationErrorcCstjj�d�r	dSdS)z7
    Only load the module if iwconfig is installed
    �iwconfigT)FzIThe iwtools execution module cannot be loaded: iwconfig is not installed.)�salt�utils�path�which�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/iwtools.py�__virtual__
sr
cCsht|�std��tdd|�d��}d|vr*tdd|�d��tdd|�d��}i}i}|��D]q}|��s9q2d|vr>q2|���d	�rX|�d
�}|d}|rX|||d<i}|�d
�}|d��dkrq|d�d��d�|d<|d��dkr�d|vr�g|d<|d�	d
�
|dd�����q2d
�
|dd����||d��<q2|||d<|dkr�|��S|S)z�
    List networks on a wireless interface

    CLI Examples:

    .. code-block:: bash

        salt minion iwtools.scan wlp3s0
        salt minion iwtools.scan wlp3s0 list
    �$The interface specified is not valid�cmd.runziwlist z scanzNetwork is downzip link set z upzScan completedZCellz - �ZAddress�:r�"ZIEN�list)�_valid_ifacer�__salt__�
splitlines�strip�
startswith�split�lstrip�rstrip�append�join�keys)�iface�style�out�ret�tmp�line�compsrrr	�scans>

"$r#cCsdt|�std��d}||vrtd�d�|����td|�tdd|�d|���}td	|�|S)
z�
    List networks on a wireless interface

    CLI Example:

    .. code-block:: bash

        salt minion iwtools.set_mode wlp3s0 Managed
    r)ZManagedzAd-HocZMasterZRepeaterZ	SecondaryZMonitorZAutoz0One of the following modes must be specified: {}z, zip.downrz	iwconfig z mode zip.up)rr�formatrr)r�modeZvalid_modesrrrr	�set_modeKs
	��r&cCst�}||vr	dSdS)z*
    Validate the specified interface
    TF)�list_interfaces)rZifacesrrr	rnsrcCs$i}d}d}tdd�}|��D]q}|sqd|vrq|���d�}|�d�s9|dur0|��||<|�d�}dgi}|D]E}d	|vrc|�d	�}|d��}	|d
��}
|	dkr^|
�d��d�}
|
||	<q;d
|vry|�d
�}|d
��||d��<q;|d�	|�q;q|��||<|dkr�|�
�S|S)z�
    List all of the wireless interfaces

    CLI Example:

    .. code-block:: bash

        salt minion iwtools.list_interfaces
    Nrrzno wireless extensionsz  � r�extrarr
ZESSIDr�=r)rrrrr�copy�poprrrr)rrr rrr!r"�item�parts�key�valuerrr	r'xs@





�r')N)�__doc__�loggingZsalt.utils.pathrZsalt.exceptionsr�	getLogger�__name__�logr
r#r&rr'rrrr	�<module>s

2#