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: //usr/local/lib/python3.7/site-packages/urllib3/contrib/__pycache__/socks.cpython-37.pyc
B

���g#�@stdZddlmZyddlZWn6ek
rRddlZddlmZe�de��YnXddl	Z	ddl
mZddl
mZmZdd	lmZmZdd
lmZmZddlmZddlmZyddlZWnek
r�dZYnXy dd
l	mZGdd�de�ZWn&ek
�re	jee	jfZYnXGdd�de�ZGdd�dee�Z Gdd�de�Z!Gdd�de�Z"Gdd�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/contrib.html#socks-proxies)�timeout)�HTTPConnection�HTTPSConnection)�HTTPConnectionPool�HTTPSConnectionPool)�ConnectTimeoutError�NewConnectionError)�PoolManager)�	parse_url)�	TypedDictc@s>eZdZUded<ded<ded<ded<ded<ded	<d
S)�_TYPE_SOCKS_OPTIONS�int�
socks_versionz
str | None�
proxy_host�
proxy_port�username�password�bool�rdnsN)�__name__�
__module__�__qualname__�__annotations__�rr�?/usr/local/lib/python3.7/site-packages/urllib3/contrib/socks.pyrMs
rcs:eZdZdZddddd��fdd�Zdd	�d
d�Z�ZS)�SOCKSConnectionzG
    A plain-text HTTP connection that connects via a SOCKS proxy.
    rz
typing.Any�None)�_socks_options�args�kwargs�returncs||_t�j||�dS)N)r �super�__init__)�selfr r!r")�	__class__rrr%^szSOCKSConnection.__init__zsocks.socksocket)r#c
Csti}|jr|j|d<|jr$|j|d<yTtj|j|jff|jd|jd|jd|jd|jd|jd|jd	�|��}Wn�tk
r�}z"t	|d
|j�d|j�d��|�Wd
d
}~XYn�tj
k
�r:}zb|j�r|j}t|t��rt	|d
|j�d|j�d��|�nt
|d|����nt
|d|���|�Wd
d
}~XYn6tk
�rn}zt
|d|���|�Wd
d
}~XYnX|S)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�portr r�
SocketTimeoutr
�
ProxyErrorZ
socket_err�
isinstancer�OSError)r&�extra_kw�conn�e�errorrrr�	_new_conngsN

zSOCKSConnection._new_conn)rrr�__doc__r%r8�
__classcell__rr)r'rrYs	rc@seZdZdS)�SOCKSHTTPSConnectionN)rrrrrrrr;�sr;c@seZdZeZdS)�SOCKSHTTPConnectionPoolN)rrrr�
ConnectionClsrrrrr<�sr<c@seZdZeZdS)�SOCKSHTTPSConnectionPoolN)rrrr;r=rrrrr>�sr>cs<eZdZdZeed�Zd
dddddd	d
��fdd�
Z�ZS)�SOCKSProxyManagerzh
    A version of the urllib3 ProxyManager that routes connections via the
    defined SOCKS proxy.
    )�http�httpsN�
�strz
str | Nonerztyping.Mapping[str, str] | Nonez
typing.Any)�	proxy_urlrr�	num_pools�headers�connection_pool_kwcs�t|�}|dkrB|dkrB|jdk	rB|j�d�}t|�dkrB|\}}|jdkrXtj}	d}
nP|jdkrntj}	d}
n:|jdkr�tj}	d}
n$|jdkr�tj}	d}
ntd	|����||_	|	|j
|j|||
d
�}||d<t�j
||f|�tj|_dS)N�:rZsocks5FZsocks5hTZsocks4Zsocks4az'Unable to determine SOCKS version from )rrrrrrr )r
�auth�split�len�schemer,ZPROXY_TYPE_SOCKS5ZPROXY_TYPE_SOCKS4�
ValueErrorrDr.r/r$r%r?�pool_classes_by_scheme)r&rDrrrErFrG�parsedrJrrZ
socks_options)r'rrr%�s8	



zSOCKSProxyManager.__init__)NNrBN)	rrrr9r<r>rNr%r:rr)r'rr?�sr?)$r9�
__future__rr,�ImportError�warnings�
exceptionsr�warn�typing�socketrr0�
connectionrr�connectionpoolrr	r
r�poolmanagerrZutil.urlr
�sslrr�DictrC�Anyrr;r<r>r?rrrr�<module>'s>
M