3
ì2;Za ã @ s" d Z ddlZyddlZddlZW n( ek
rH ddljZddljZY nX ddl Z dd„ Z
G dd„ dejƒZG dd„ dej
ƒZG d d
„ d
ejejƒZedk�rddlZyeejd ƒZW n eefk
rÔ d
ZY nX ejee jdeƒƒZedejdƒjƒ jƒ ƒ edejdƒjƒ jƒ ƒ dS )zù
SocksiPy + urllib2 handler
version: 0.3
author: e
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...
é Nc C s | j ƒ }|j|ƒ |S )N)ÚcopyÚupdate)ÚaÚbÚd© r ú"/usr/lib/python3.6/sockshandler.pyÚ
merge_dict s
r c @ s e Zd Zddd„Zdd„ ZdS )ÚSocksiPyConnectionNTc O s* ||||||f| _ tjj| f|ž|Ž d S )N)Ú proxyargsÚhttplibÚHTTPConnectionÚ__init__) ÚselfÚ proxytypeÚ proxyaddrÚ proxyportÚrdnsÚusernameÚpasswordÚargsÚkwargsr r r r s zSocksiPyConnection.__init__c C sP t jƒ | _| jj| jŽ t| jƒttfkr8| jj | jƒ | jj
| j| jfƒ d S )N)
ÚsocksÚ
socksocketÚsockÚsetproxyr ÚtypeÚtimeoutÚintÚfloatÚ
settimeoutÚconnectÚhostÚport)r r r r r! s
zSocksiPyConnection.connect)NTNN)Ú__name__Ú
__module__Ú__qualname__r r! r r r r r
s
r
c @ s e Zd Zddd„Zdd„ ZdS )ÚSocksiPyConnectionSNTc O s* ||||||f| _ tjj| f|ž|Ž d S )N)r r ÚHTTPSConnectionr ) r r r r r r r r r r r r r ' s zSocksiPyConnectionS.__init__c C s\ t jƒ }|j| jŽ t| jƒttfkr2|j| jƒ |j | j
| jfƒ tj
|| j| jƒ| _d S )N)r r r r r r r r r r! r" r# ÚsslZwrap_socketZkey_fileZ cert_filer )r r r r r r! + s zSocksiPyConnectionS.connect)NTNN)r$ r% r&