Your IP : 3.15.225.164


Current Path : /opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyc

�
�Rec@@s�dZddlmZyddlZWn@ek
rhddlZddlmZejde��nXddl	m
ZmZ
ddlmZmZdd	lmZmZdd
lmZmZddlmZddlmZyddlZWnek
r
dZnXd
efd��YZdeefd��YZdefd��YZdefd��YZdefd��YZ dS(s_
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::

    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::

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

i(tabsolute_importNi(tDependencyWarnings�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(terrorttimeout(tHTTPConnectiontHTTPSConnection(tHTTPConnectionPooltHTTPSConnectionPool(tConnectTimeoutErrortNewConnectionError(tPoolManager(t	parse_urltSOCKSConnectioncB@s eZdZd�Zd�ZRS(sG
    A plain-text HTTP connection that connects via a SOCKS proxy.
    cO@s/|jd�|_tt|�j||�dS(Nt_socks_options(tpopR
tsuperRt__init__(tselftargstkwargs((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyRJscC@s�i}|jr|j|d<n|jr8|j|d<nyytj|j|jfd|jdd|jdd|jdd|jd	d
|jdd|jd
d|j|�}Wn�tk
r�t	|d|j|jf��n�tj
k
rd}|jrN|j}t|t�r8t	|d|j|jf��qat
|d|��q�t
|d|��n&tk
r�}t
|d|��nX|S(sA
        Establish a new connection via the SOCKS proxy.
        tsource_addresstsocket_optionst
proxy_typet
socks_versiont
proxy_addrt
proxy_hostt
proxy_porttproxy_usernametusernametproxy_passwordtpasswordt
proxy_rdnstrdnsRs0Connection to %s timed out. (connect timeout=%s)s(Failed to establish a new connection: %s(RRtsockstcreate_connectionthosttportR
Rt
SocketTimeoutRt
ProxyErrort
socket_errt
isinstanceR	tSocketError(Rtextra_kwtconnteR((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyt	_new_connNsJ		







		(t__name__t
__module__t__doc__RR-(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyREs	tSOCKSHTTPSConnectioncB@seZRS((R.R/(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyR1�stSOCKSHTTPConnectionPoolcB@seZeZRS((R.R/Rt
ConnectionCls(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyR2�stSOCKSHTTPSConnectionPoolcB@seZeZRS((R.R/R1R3(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyR4�stSOCKSProxyManagercB@s7eZdZied6ed6Zddddd�ZRS(sh
    A version of the urllib3 ProxyManager that routes connections via the
    defined SOCKS proxy.
    thttpthttpsi
cK@srt|�}|dkri|dkri|jdk	ri|jjd�}t|�dkri|\}}qin|jdkr�tj}	t}
ns|jdkr�tj}	t	}
nR|jdkr�tj
}	t}
n1|jdkr�tj
}	t	}
ntd|��||_i|	d6|j
d	6|jd
6|d6|d6|
d
6}||d<tt|�j|||�tj|_dS(Nt:itsocks5tsocks5htsocks4tsocks4as)Unable to determine SOCKS version from %sRRRRRR R
(RtNonetauthtsplittlentschemeR!tPROXY_TYPE_SOCKS5tFalsetTruetPROXY_TYPE_SOCKS4t
ValueErrort	proxy_urlR#R$RR5Rtpool_classes_by_scheme(RRGRRt	num_poolstheaderstconnection_pool_kwtparsedR?RR t
socks_options((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyR�s<	'									




N(R.R/R0R2R4RHR=R(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyR5�s
(!R0t
__future__RR!tImportErrortwarningst
exceptionsRtwarntsocketRR)RR%t
connectionRRtconnectionpoolRRRR	tpoolmanagerR
tutil.urlRtsslR=RR1R2R4R5(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/socks.pyt<module>$s2


H

?>