Viewing File: /opt/alt/python35/lib/python3.5/site-packages/__pycache__/sockshandler.cpython-35.opt-1.pyc



"Ù@Waã@s‚dZddlZyddlZddlZWn0ek
r`ddljZddljZYnXddl	Z	dd„Z
Gdd„dejƒZGdd„dej
ƒZGd	d
„d
ejejƒZedkr~ddlZyeejdƒZWneefk
rd
ZYnXejee	jdeƒƒZedejdƒjƒjƒƒedejdƒjƒjƒƒdS)zù
SocksiPy + urllib2 handler

version: 0.3
author: e<e@tr0ll.in>

This module provides a Handler which you can use with urllib2 to allow it to tunnel your connection through a socks.sockssocket socket, with out monkey patching the original socket...
éNcCs|jƒ}|j|ƒ|S)N)ÚcopyÚupdate)ÚaÚbÚd©rú/sockshandler.pyÚ
merge_dicts
r	c@s4eZdZdddddd„Zdd„ZdS)ÚSocksiPyConnectionNTc	Os5||||||f|_tjj|||ŽdS)N)Ú	proxyargsÚhttplibÚHTTPConnectionÚ__init__)	ÚselfÚ	proxytypeÚ	proxyaddrÚ	proxyportÚrdnsÚusernameÚpasswordÚargsÚkwargsrrrrszSocksiPyConnection.__init__cCsptjƒ|_|jj|jŒt|jƒttfkrP|jj	|jƒ|jj
|j|jfƒdS)N)
ÚsocksÚ
socksocketÚsockÚsetproxyrÚtypeÚtimeoutÚintÚfloatÚ
settimeoutÚconnectÚhostÚport)rrrrr!s
zSocksiPyConnection.connect)Ú__name__Ú
__module__Ú__qualname__rr!rrrrr
sr
c@s4eZdZdddddd„Zdd„ZdS)ÚSocksiPyConnectionSNTc	Os5||||||f|_tjj|||ŽdS)N)rrÚHTTPSConnectionr)	rrrrrrrrrrrrr'szSocksiPyConnectionS.__init__cCs‚tjƒ}|j|jŒt|jƒttfkrG|j|jƒ|j	|j
|jfƒtj
||j|jƒ|_dS)N)rrrrrrrrr r!r"r#ÚsslZwrap_socketZkey_fileZ	cert_filer)rrrrrr!+szSocksiPyConnectionS.connect)r$r%r&rr!rrrrr'&sr'c@s4eZdZdd„Zdd„Zdd„ZdS)ÚSocksiPyHandlercOs&||_||_tjj|ƒdS)N)rÚkwÚurllib2ÚHTTPHandlerr)rrrrrrr4s		zSocksiPyHandler.__init__cs(dd‡fdd†}ˆj||ƒS)Nrc	s:tˆj|ƒ}tˆjd|d|d||Ž}|S)Nr"r#r)r	r+r
r)r"r#rrr+Úconn)rrrÚbuild:s$z(SocksiPyHandler.http_open.<locals>.build)Údo_open)rÚreqr/r)rrÚ	http_open9szSocksiPyHandler.http_opencs(dd‡fdd†}ˆj||ƒS)Nrc	s:tˆj|ƒ}tˆjd|d|d||Ž}|S)Nr"r#r)r	r+r'r)r"r#rrr+r.)rrrr/As$z)SocksiPyHandler.https_open.<locals>.build)r0)rr1r/r)rrÚ
https_open@szSocksiPyHandler.https_openN)r$r%r&rr2r3rrrrr*3sr*Ú__main__éiZ#Ú	localhostzHTTP: zhttp://httpbin.org/ipzHTTPS: zhttps://httpbin.org/ip) Ú__doc__r)r,rÚImportErrorZurllib.requestZrequestZhttp.clientÚclientrr	r
r
r(r'r-ZHTTPSHandlerr*r$ÚsysrÚargvr#Ú
ValueErrorÚ
IndexErrorZbuild_openerZPROXY_TYPE_SOCKS5ZopenerÚprintÚopenÚreadÚdecoderrrrÚ<module>	s*

#
Back to Directory File Manager