HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/osm/venv/lib64/python3.10/site-packages/urllib3/contrib/__pycache__/socks.cpython-310.pyc
o

<i}�@s6dZddlmZzddlZWney&ddlZddlmZe�de��wddl	Z	ddl
mZddl
mZmZdd	lmZmZdd
lmZmZddlmZddlmZzddlZWneyfdZYnwGd
d�de	j�ZGdd�de�ZGdd�dee�ZGdd�de�ZGdd�de�ZGdd�de�Z dS)a�
This module contains provisional support for SOCKS proxies from within
urllib3. This module supports SOCKS4, SOCKS4A (an extension of SOCKS4), and
SOCKS5. To enable its functionality, either install PySocks or install this
module with the ``socks`` extra.

The SOCKS implementation supports the full range of urllib3 features. It also
supports the following SOCKS features:

- SOCKS4A (``proxy_url='socks4a://...``)
- SOCKS4 (``proxy_url='socks4://...``)
- SOCKS5 with remote DNS (``proxy_url='socks5h://...``)
- SOCKS5 with local DNS (``proxy_url='socks5://...``)
- Usernames and passwords for the SOCKS proxy

.. note::
   It is recommended to use ``socks5h://`` or ``socks4a://`` schemes in
   your ``proxy_url`` to ensure that DNS resolution is done from the remote
   server instead of client-side when connecting to a domain name.

SOCKS4 supports IPv4 and domain names with the SOCKS4A extension. SOCKS5
supports IPv4, IPv6, and domain names.

When connecting to a SOCKS4 proxy the ``username`` portion of the ``proxy_url``
will be sent as the ``userid`` section of the SOCKS request:

.. code-block:: python

    proxy_url="socks4a://<userid>@proxy-host"

When connecting to a SOCKS5 proxy the ``username`` and ``password`` portion
of the ``proxy_url`` will be sent as the username/password to authenticate
with the proxy:

.. code-block:: python

    proxy_url="socks5h://<username>:<password>@proxy-host"

�)�annotationsN�)�DependencyWarningz�SOCKS support in urllib3 requires the installation of optional dependencies: specifically, PySocks.  For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#socks-proxies)�timeout)�HTTPConnection�HTTPSConnection)�HTTPConnectionPool�HTTPSConnectionPool)�ConnectTimeoutError�NewConnectionError)�PoolManager)�	parse_urlc@s>eZdZUded<ded<ded<ded<ded<ded	<d
S)�_TYPE_SOCKS_OPTIONS�int�
socks_version�
str | None�
proxy_host�
proxy_port�username�password�bool�rdnsN)�__name__�
__module__�__qualname__�__annotations__�rr�C/opt/osm/venv/lib/python3.10/site-packages/urllib3/contrib/socks.pyrKs
rcs,eZdZdZd�fd	d
�Zddd
�Z�ZS)�SOCKSConnectionzG
    A plain-text HTTP connection that connects via a SOCKS proxy.
    �_socks_optionsr�args�
typing.Any�kwargs�return�Nonecs||_t�j|i|��dS)N)r�super�__init__)�selfrr r"��	__class__rrr&YszSOCKSConnection.__init__�socks.socksocketc
CsHi}|jr
|j|d<|jr|j|d<z+tj|j|jff|jd|jd|jd|jd|jd|jd|jd	�|��}W|StyX}zt	|d
|j�d|j�d��|�d
}~wtj
y�}z+|jr�|j}t|t�rzt	|d
|j�d|j�d��|�t
|d|����t
|d|���|�d
}~wty�}z	t
|d|���|�d
}~ww)zA
        Establish a new connection via the SOCKS proxy.
        �source_address�socket_optionsrrrrrr)�
proxy_typeZ
proxy_addrrZproxy_usernameZproxy_passwordZ
proxy_rdnsrzConnection to z timed out. (connect timeout=�)Nz&Failed to establish a new connection: )r+r,�socks�create_connection�host�portrr�
SocketTimeoutr
�
ProxyErrorZ
socket_err�
isinstancer�OSError)r'�extra_kw�conn�e�errorrrr�	_new_connbsn


��	�,����
��
�
���
����zSOCKSConnection._new_conn)rrr r!r"r!r#r$)r#r*)rrr�__doc__r&r;�
__classcell__rrr(rrTs	rc@seZdZdS)�SOCKSHTTPSConnectionN)rrrrrrrr>�sr>c@�eZdZeZdS)�SOCKSHTTPConnectionPoolN)rrrr�
ConnectionClsrrrrr@��r@c@r?)�SOCKSHTTPSConnectionPoolN)rrrr>rArrrrrC�rBrCcs6eZdZdZeed�Z				dd�fdd�
Z�ZS)�SOCKSProxyManagerzh
    A version of the urllib3 ProxyManager that routes connections via the
    defined SOCKS proxy.
    )�http�httpsN�
�	proxy_url�strrrr�	num_poolsr�headers�typing.Mapping[str, str] | None�connection_pool_kwr!cs�t|�}|dur!|dur!|jdur!|j�d�}t|�dkr!|\}}|jdkr,tj}	d}
n(|jdkr7tj}	d}
n|jdkrBtj}	d}
n|jdkrMtj}	d}
ntd	|����||_	|	|j
|j|||
d
�}||d<t�j
||fi|��tj|_dS)N�:rZsocks5FZsocks5hTZsocks4Zsocks4az'Unable to determine SOCKS version from )rrrrrrr)r
�auth�split�len�schemer/ZPROXY_TYPE_SOCKS5ZPROXY_TYPE_SOCKS4�
ValueErrorrHr1r2r%r&rD�pool_classes_by_scheme)r'rHrrrJrKrM�parsedrPrrZ
socks_optionsr(rrr&�s:	



�zSOCKSProxyManager.__init__)NNrGN)rHrIrrrrrJrrKrLrMr!)	rrrr<r@rCrTr&r=rrr(rrD�s��rD)!r<�
__future__rr/�ImportError�warnings�
exceptionsr�warn�typing�socketrr3�
connectionrr�connectionpoolrr	r
r�poolmanagerrZutil.urlr
�ssl�	TypedDictrrr>r@rCrDrrrr�<module>s>(���	M