Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/urllib3/contrib/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/urllib3/contrib/__pycache__/socks.cpython-311.pyc

�

�܋f#����dZddlmZ	ddlZn%#e$rddlZddlmZejde���wxYwddl	Z	ddl
mZddl
mZmZdd	lmZmZdd
lmZmZddlmZddlmZ	ddlZn
#e$rdZYnwxYw	dd
l	mZGd�de��Zn#e$re	jee	jfZYnwxYwGd�de��ZGd�dee��Z Gd�de��Z!Gd�de��Z"Gd�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�L�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__���L/opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/contrib/socks.pyrrMsU����������������������������
�
�
�
�
r rc�,��eZdZdZd�fd	�Zd
d�Z�xZS)�SOCKSConnectionzG
    A plain-text HTTP connection that connects via a SOCKS proxy.
    �_socks_optionsr�args�
typing.Any�kwargs�return�Nonec�H��||_t��j|i|��dS)N)r$�super�__init__)�selfr$r%r'�	__class__s    �r!r,zSOCKSConnection.__init__^s/���-��������$�)�&�)�)�)�)�)r �socks.socksocketc���i}|jr
|j|d<|jr
|j|d<	tj|j|jff|jd|jd|jd|jd|jd|jd|jd	�|��}n�#t$r'}t|d
|j�d|j�d���|�d
}~wtj
$rq}|jrQ|j}t|t��r"t|d
|j�d|j�d���|�t|d|�����t|d|����|�d
}~wt$r}t|d|����|�d
}~wwxYw|S)zA
        Establish a new connection via the SOCKS proxy.
        �source_address�socket_optionsrrrrrr)�
proxy_type�
proxy_addrr�proxy_username�proxy_password�
proxy_rdnsrzConnection to z timed out. (connect timeout=�)Nz&Failed to establish a new connection: )r1r2�socks�create_connection�host�portr$r�
SocketTimeoutr�
ProxyError�
socket_err�
isinstancer�OSError)r-�extra_kw�conn�e�errors     r!�	_new_connzSOCKSConnection._new_conngs��+-����	=�)-�)<�H�%�&���	=�)-�)<�H�%�&�+	��*���D�I�&�
��.��?��.�|�<��.�|�<�#�2�:�>�#�2�:�>��.�v�6���
�
��
�
�D�D���	�	�	�%��X���X�X���X�X�X����
�����
��	�	�	��|�
�����e�]�3�3�
�-��`���`�`�QU�Q]�`�`�`�����-��N�u�N�N����)��F�1�F�F����������	�	�	�$��B�q�B�B����
�����	����
�s1�A-B�
E$�"C�E$�A,D>�>
E$�E�E$)r$rr%r&r'r&r(r))r(r/)rrr�__doc__r,rF�
__classcell__�r.s@r!r#r#Ys[���������*�*�*�*�*�*�8�8�8�8�8�8�8�8r r#c��eZdZdS)�SOCKSHTTPSConnectionN)rrrrr r!rKrK�s�������Dr rKc��eZdZeZdS)�SOCKSHTTPConnectionPoolN)rrrr#�
ConnectionClsrr r!rMrM�s������#�M�M�Mr rMc��eZdZeZdS)�SOCKSHTTPSConnectionPoolN)rrrrKrNrr r!rPrP�s������(�M�M�Mr rPc�8��eZdZdZeed�Z				dd�fd�
Z�xZS)�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�*��t|��}|�;|�9|j�2|j�d��}t|��dkr|\}}|jdkrt
j}	d}
n`|jdkrt
j}	d}
nF|jdkrt
j}	d}
n,|jdkrt
j}	d}
ntd	|�����||_	|	|j
|j|||
d
�}||d<t��j
||fi|��tj|_dS)N�:r�socks5F�socks5hT�socks4�socks4az'Unable to determine SOCKS version from )rrrrrrr$)r�auth�split�len�schemer9�PROXY_TYPE_SOCKS5�PROXY_TYPE_SOCKS4�
ValueErrorrVr;r<r+r,rR�pool_classes_by_scheme)
r-rVrrrXrYr[�parsedrcrr�
socks_optionsr.s
            �r!r,zSOCKSProxyManager.__init__�sE����9�%�%����� 0�V�[�5L��K�%�%�c�*�*�E��5�z�z�Q���%*�"��(��=�H�$�$�!�3�M��D�D�
�]�i�
'�
'�!�3�M��D�D�
�]�h�
&�
&�!�3�M��D�D�
�]�i�
'�
'�!�3�M��D�D��R�y�R�R�S�S�S�"���+� �+� �+� � ��

�
�
�0=��+�,�������G�B�B�/A�B�B�B�&7�&N��#�#�#r )NNrUN)rVrWrrrrrXrrYrZr[r&)	rrrrGrMrPrir,rHrIs@r!rRrR�sz���������(�)���� $�#��37�
,O�,O�,O�,O�,O�,O�,O�,O�,O�,O�,Or rR)$rG�
__future__rr9�ImportError�warnings�
exceptionsr�warn�typing�socketrr=�
connectionrr�connectionpoolr	r
rr�poolmanagerr
�util.urlr�sslrr�DictrW�Anyr#rKrMrPrRrr r!�<module>rzs���&�&�P#�"�"�"�"�"�
��L�L�L�L���

�

�

��O�O�O�.�.�.�.�.�.��H�M�
R�	�
���
�

�����
�
�
�+�+�+�+�+�+�8�8�8�8�8�8�8�8�D�D�D�D�D�D�D�D�@�@�@�@�@�@�@�@�%�%�%�%�%�%� � � � � � ���J�J�J�J������
�C�C�C�����7� � � � � � ������i�������7�7�7� �+�c�6�:�o�6����7����F�F�F�F�F�n�F�F�F�Z	�	�	�	�	�?�O�	�	�	�$�$�$�$�$�0�$�$�$�)�)�)�)�)�2�)�)�)�7O�7O�7O�7O�7O��7O�7O�7O�7O�7Os,��"1�#A(�(A2�1A2�6B�B'�&B'

Hacked By AnonymousFox1.0, Coded By AnonymousFox