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__/proxy.cpython-310.pyc
o

�N�g�-�@s�dZddlZddlZddlZe�e�ZdZdd�Z	dd�Z
dd	�Zd$d
d�Z	d%d
d�Z
d&dd�Z				d'dd�Zd&dd�Z				d'dd�Zd&dd�Z				d'dd�Zd&dd�Zd&dd�Zd(d d!�Zd"d#�ZdS))zl
This module allows you to manage proxy settings

.. code-block:: bash

    salt '*' network.get_http_proxy
�N�proxycCs tjj��stjj��rdSdS)z)
    Only work on Mac OS and Windows
    T)Fz;Module proxy: module only works on Windows or MacOS systems)�salt�utils�platformZ	is_darwinZ
is_windows�rr�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/proxy.py�__virtual__srcCsdi}tdd|�d|���}t�d|�}|dur0|��}|ddkr$dnd}||d	|d
d�}|S)N�cmd.runznetworksetup -� z&Enabled: (.*)
Server: (.*)
Port: (.*)
rZYesTF��)�enabled�server�port)�__salt__�re�match�groups)�cmd_function�network_service�ret�outr�gr
rrr�_get_proxy_osxsrcCsHd�||||�}|dur|dur|d|�d|��}td|�}d|vS)Nznetworksetup -{} {} {} {}z On r
r	�error)�formatr)rrr�user�passwordr�cmdrrrr�_set_proxy_osx(s�rcCs�i}|dur
gd�}tddddd�d}|rFd|vrF|�d	�}|D]#}|s'q"d
|vr3|�d
�\}}n|}d}|�d�\}}||d�||<q"i}	|ret|�dkrV||d
S|D]}
|
|vrd||
|	|
<qXtddddd�ddk|	d<|	S)N��http�https�ftp�reg.read_value�HKEY_CURRENT_USER�;SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings�ProxyServer��hive�key�vname�vdata�=�;�:)rrrr�ProxyEnabler
)�	__utils__�split�len)�typesZproxiesZserversr2�sZserver_typerZ
proxy_typerrrrrr�_get_proxy_windows5sP��
�����	r6Tc	Cs�|durgd�}d}|D]}||�d|�d|�d�7}qtdddd	|d
�tdddddd
d�|durGd�d�|��}tdddd|d
�|rQd}td|�dS)Nr �r-r/r.z
reg.set_valuer%r&r')r)r*r+r,r0rZ	REG_DWORD)r)r*r+r,Zvtypez
<local>;{}�
ProxyOverridez$netsh winhttp import proxy source=ier	T)r1r�joinr)	rrr4�bypass_hostsZimport_winhttpZ
server_str�tZbypass_hosts_strrrrr�_set_proxy_windowsgs<���r<�EthernetcC�$tddkrtdgd�Std|d�S)z�
    Returns the current http proxy settings

    network_service
        The network service to apply the changes to, this only necessary on
        macOS

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.get_http_proxy Ethernet
    �os�Windowsr!�r4Zgetwebproxy�rr��
__grains__r6r�rrrr�get_http_proxy��rFcC�2tddkrt||dg|d�Std|||||d�S)a_
    Sets the http proxy settings. Note: On Windows this will override any other
    proxy settings you have, the preferred method of updating proxies on windows
    is using set_proxy.

    server
        The proxy server to use

    port
        The port used by the proxy server

    user
        The username to use for the proxy server if required

    password
        The password to use if required by the server

    network_service
        The network service to apply the changes to, this only necessary on
        macOS

    bypass_hosts
        The hosts that are allowed to by pass the proxy. Only used on Windows
        for other OS's use set_proxy_bypass to edit the bypass hosts.

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.set_http_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet
    r?r@r!�rrr4r:Zsetwebproxy�rrrrrr�rDr<r�rrrrrr:rrr�set_http_proxy��'
��rMcCr>)z�
    Returns the current https proxy settings

    network_service
        The network service to apply the changes to, this only necessary on
        macOS

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.get_https_proxy Ethernet
    r?r@r"rAZgetsecurewebproxyrBrCrErrr�get_https_proxy�s
�rOcCrH)aa
    Sets the https proxy settings. Note: On Windows this will override any other
    proxy settings you have, the preferred method of updating proxies on windows
    is using set_proxy.

    server
        The proxy server to use

    port
        The port used by the proxy server

    user
        The username to use for the proxy server if required

    password
        The password to use if required by the server

    network_service
        The network service to apply the changes to, this only necessary on
        macOS

    bypass_hosts
        The hosts that are allowed to by pass the proxy. Only used on Windows
        for other OS's use set_proxy_bypass to edit the bypass hosts.

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.set_https_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet
    r?r@r"rIZsetsecurewebproxyrJrKrLrrr�set_https_proxy�rNrPcCr>)z�
    Returns the current ftp proxy settings

    network_service
        The network service to apply the changes to, this only necessary on
        macOS

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.get_ftp_proxy Ethernet
    r?r@r#rAZgetftpproxyrBrCrErrr�
get_ftp_proxy'rGrQcCrH)a�
    Sets the ftp proxy settings

    server
        The proxy server to use

    port
        The port used by the proxy server

    user
        The username to use for the proxy server if required

    password
        The password to use if required by the server

    network_service
        The network service to apply the changes to, this only necessary on
        macOS

    bypass_hosts
        The hosts that are allowed to by pass the proxy. Only used on Windows
        for other OS's use set_proxy_bypass to edit the bypass hosts.

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.set_ftp_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet
    r?r@r#rIZsetftpproxyrJrKrLrrr�
set_ftp_proxy;s%
��rRcCs\tddkr tddddd�d}|d	urgS|�d
d��d�Std
d|���}|�d�S)a
    Returns the current domains that can bypass the proxy

    network_service
        The network service to get the bypass domains from, this is only
        necessary on macOS

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.get_proxy_bypass

    r?r@r$r%r&r8r(r,Nz<local>r7r.r	z$networksetup -getproxybypassdomains �
)rDr1�replacer2r)rZreg_valrrrr�get_proxy_bypassos��
rUcCs*d�|�}d�||�}td|�}d|vS)a[
    Sets the domains that can bypass the proxy

    domains
        An array of domains allowed to bypass the proxy

    network_service
        The network service to apply the changes to, this only necessary on
        macOS

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.set_proxy_bypass "['127.0.0.1', 'localhost']"

    r
z)networksetup -setproxybypassdomains {} {}r	r)r9rr)ZdomainsrZservers_strrrrrr�set_proxy_bypass�s
�rVcCs tddkrt||||d�SdS)a,
    Sets the http proxy settings, only works with Windows.

    server
        The proxy server to use

    password
        The password to use if required by the server

    types
        The types of proxy connections should be setup with this server. Valid
        types are:

            - ``http``
            - ``https``
            - ``ftp``

    bypass_hosts
        The hosts that are allowed to by pass the proxy.

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.set_http_proxy example.com 1080 types="['http', 'https']"
    r?r@rIN)rDr<rIrrr�
set_proxy_win�s
��rWcCstddkr	t�SdS)z�
    Gets all of the proxy settings in one call, only available on Windows

    CLI Example:

    .. code-block:: bash

        salt '*' proxy.get_proxy_win
    r?r@N)rDr6rrrr�
get_proxy_win�s
�rX)N)NNT)r=)NNr=N)NN)�__doc__�loggingrZsalt.utils.platformr�	getLogger�__name__�logZ__virtualname__rrrr6r<rFrMrOrPrQrRrUrVrWrXrrrr�<module>sD
	

3
�
*
�
6
�
6
�
4
!
!