+
    i                        R t ^ RIHt  ^ RIHt ^ RIHtH	t	H
t
 ^ RIt^ RIHt ^ RIt^ RIt^ RIHt ^ RIt^ RIt^ RItRt]P*                  R8X  d   ]P,                  R38  d    ^ RIt]P0                  ! ]4      t^;tt^;tt^;tt R
]R]R] /t!]"! ]#! ]!PI                  4       ]!PK                  4       4      4      t&]P"                  ;t't(R t) ! R R]*4      t+ ! R R]+4      t, ! R R]+4      t- ! R R]+4      t. ! R R]+4      t/ ! R R]+4      t0 ! R R]+4      t1^[R^\R^]R/t2^R^R ^R!^R"^R#^R$^R%^R&/t3]R']R'] R(/t4R4R) lt5R* t6R+ t7]7t8R, t9]9t:R5R- lt; ! R. R/]P"                  4      t<R0 t=R6 FI  t]>! ]<]R4      t?]@! ]?]4      '       d   K  ]<P                  P                  ]4       ]C! ]<]]=! ]4      4       KK  	   ! R1 R2]<4      tDR#   ] d    ^ RIHt  ELi ; i  ] d
    ]! R	4      hi ; i)7a1  PySocks - A SOCKS proxy client and wrapper for Python.
Version 1.7.1

Copyright 2006 Dan-Haim. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.
3. Neither the name of Dan Haim nor the names of his contributors may be used
   to endorse or promote products derived from this software without specific
   prior written permission.

THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE.


This module provides a standard socket-like interface for Python
for tunneling connections through SOCKS proxies.

)	b64encode)Callable)
EOPNOTSUPPEINVALEAGAINN)BytesIO)SEEK_CURz1.7.1ntz8To run PySocks on Windows you must install win_inet_ptonSOCKS4SOCKS5HTTPc                 F   a  \         P                  ! S 4      V 3R  l4       pV# )c                    < V ^ ,          p VP                  4       pV^ 8X  d   VP                  R4       S! V / VB V^ 8X  d   VP                  R4       # #   \         d   ph Rp?ii ; i  X^ 8X  d   TP                  R4       i i ; i)    TFN)
gettimeoutsetblocking	Exception)argskwargsself_is_blockingefunctions   *,   "/config/qBittorrent/nova3/socks.pywrapper"set_self_blocking.<locals>.wrapperH   s    Aw
	(??,Lq   &T,V,
 q   ' !	  		 q   ' !s#   /A A& A!!A&&A) )B)	functoolswraps)r   r   s   f r   set_self_blockingr   F   s%    __X( ( N    c                   4   a  ] tR t^Yt o RtRR ltR tRtV tR# )
ProxyErrorz4Socket_err contains original socket.error exception.Nc                    Wn         W n        V'       d+   V ;P                   R P                  V4      ,          un         R# R# )z: {}N)msg
socket_errformat)r   r#   r$   s   &&&r   __init__ProxyError.__init__[   s+    $HHj11H r   c                    V P                   # N)r#   r   s   &r   __str__ProxyError.__str__b   s    xxr   )r#   r$   r)   )	__name__
__module____qualname____firstlineno____doc__r&   r+   __static_attributes____classdictcell____classdict__s   @r   r!   r!   Y   s     >2 r   r!   c                       ] tR t^ftRtR# )GeneralProxyError Nr-   r.   r/   r0   r2   r8   r   r   r7   r7   f       r   r7   c                       ] tR t^jtRtR# )ProxyConnectionErrorr8   Nr9   r8   r   r   r<   r<   j   r:   r   r<   c                       ] tR t^ntRtR# )SOCKS5AuthErrorr8   Nr9   r8   r   r   r>   r>   n   r:   r   r>   c                       ] tR t^rtRtR# )SOCKS5Errorr8   Nr9   r8   r   r   r@   r@   r   r:   r   r@   c                       ] tR t^vtRtR# )SOCKS4Errorr8   Nr9   r8   r   r   rB   rB   v   r:   r   rB   c                       ] tR t^ztRtR# )	HTTPErrorr8   Nr9   r8   r   r   rD   rD   z   r:   r   rD   zRequest rejected or failedzLRequest rejected because SOCKS server cannot connect to identd on the clientzPRequest rejected because the client program and identd report different user-idszGeneral SOCKS server failurez!Connection not allowed by rulesetzNetwork unreachablezHost unreachablezConnection refusedzTTL expiredz(Command not supported, or protocol errorzAddress type not supportedi8  i  c                    YY#V'       d   VP                  4       MRV'       d   VP                  4       MR3\        n        R# )zSets a default proxy.

All further socksocket objects will use the default unless explicitly
changed. All parameters are as for socket.set_proxy().N)encode
socksocketdefault_proxy)
proxy_typeaddrportrdnsusernamepasswords   &&&&&&r   set_default_proxyrO      s0     !+$5= 145= 14 IJr   c                  N    R V9   d   VP                  R 4      VR&   \        V / VB # 	proxytyperI   )poprO   )r   r   s   *,r   setdefaultproxyrT      s-    f%zz+6|d-f--r   c                 "    \         P                  # )z4Returns the default proxy, set by set_default_proxy.)rG   rH   r8   r   r   get_default_proxyrV      s    ###r   c                r    \         P                  '       d   \         V P                  n        R# \        R4      h)a  Attempts to replace a module's socket library with a SOCKS socket.

Must set a default proxy using set_default_proxy(...) first. This will
only work on modules that import socket directly into the namespace;
most of the Python Standard Library falls into this category.zNo default proxy specifiedN)rG   rH   socketr7   )modules   &r   wrap_modulerZ      s(     ) <==r   c
           	     J   V w  rV
P                  R4      '       d   V
P                  R4      p
V'       d)   VP                  R4      '       d   VP                  R4      pRp\        P                  ! WE^ \        P                  4       F  pVw  rpppRp \        WV4      pV	'       d   V	 F  pVP                  ! V!   K  	  \        V\        \        34      '       d   VP                  V4       V'       d   VP                  W4WVWx4       V'       d   VP                  V4       VP                  W34       Vu # 	  V'       d   Vh\        P                  ! R4      h  \        P                  \        3 d0   pTpT'       d   TP!                  4        Rp Rp?EK   Rp?EK  Rp?ii ; i)a  create_connection(dest_pair, *[, timeout], **proxy_args) -> socket object

Like socket.create_connection(), but connects to proxy
before returning the socket object.

dest_pair - 2-tuple of (IP/hostname, port).
**proxy_args - Same args passed to socksocket.set_proxy() if present.
timeout - Optional socket timeout value, in seconds.
source_address - tuple (host, port) for the socket to bind to as its source
address before connecting (only for compatibility)
[z[]Nzgai returned empty list.)
startswithstriprX   getaddrinfoSOCK_STREAMrG   
setsockopt
isinstanceintfloat
settimeout	set_proxybindconnecterrorr!   close)	dest_pairtimeoutsource_addressrI   
proxy_addr
proxy_port
proxy_rdnsproxy_usernameproxy_passwordsocket_optionsremote_hostremote_porterrrfamilysocket_typeproto	canonnamesasockoptr   s   &&&&&&&&&&            r   create_connectionr      s\   $  )Kc""!''-j++C00%%d+

C 
6;M;MN451UIr	f59D)COOS) * 'C<00(zz-?		.)LL+34K) O8 	
,,1
22 j) 	C

 	s%   A!E4E$EF"3FF"c                   8   a  ] tR t^t o RtR t]! 4       tRtV t	R# )_BaseSocketzBAllows Python 2 delegated methods such as send() to be overridden.c                    \         P                  ! V .VO5/ VB  \        4       V n        V P                   F&  p\        W4      V P                  V&   \        W4       K(  	  R # r)   )_orig_socketr&   dict_savedmethods
_savenamesgetattrdelattrr   poskwnames   &*, r   r&   _BaseSocket.__init__   sO    d/S/B/!VOOD'.t':Dt$D $r   r   N)
r-   r.   r/   r0   r1   r&   listr   r2   r3   r4   s   @r   r   r      s     L  Jr   r   c                    a  V 3R  l# )c                 6   < V P                   S,          ! V/ VB # r)   r   r   s   &*,r   <lambda>_makemethod.<locals>.<lambda>  s    D$6$6t$<c$HR$Hr   r8   )r   s   fr   _makemethodr     s	    HHr   c                   l  a a ] tR tRt oRtRt]P                  ]P                  ^ 3V 3R llt	R t
V 3R ltR tR tRR	 ltR
 tV 3R ltV 3R ltRV 3R lltRV 3R lltR tV 3R ltR t]tR t]tR t]tR tV 3R ltR tR tR t R t!]"] ]#]]$]!/t%]&R V 3R ll4       t']&R 4       t(R t)Rt*Vt+V ;t,# )!rG   i  a  socksocket([family[, type[, proto]]]) -> socket object

Open a SOCKS enabled socket. The parameters are the same as
those of the standard socket init. In order for SOCKS to work,
you must specify family=AF_INET and proto=0.
The "type" argument must be either SOCK_STREAM or SOCK_DGRAM.
Nc                J  < V\         P                  \         P                  39  d   R p\        VP	                  V4      4      h\
        \        V `  ! WV.VO5/ VB  RV n        V P                  '       d   V P                  V n
        MRV n
        RV n        RV n        RV n        R# )z0Socket type must be stream or datagram, not {!r}N)NNNNNN)rX   r`   
SOCK_DGRAM
ValueErrorr%   superrG   r&   
_proxyconnrH   proxyproxy_socknameproxy_peername_timeout)r   rx   typerz   r   r   r#   	__class__s   &&&&*, r   r&   socksocket.__init__  s    **F,=,=>>DCSZZ-..j$(uNtNvN++DJ=DJ""r   c                    Rp\        V4      V8  d?   VP                  V\        V4      ,
          4      pV'       g   \        R4      hW4,          pKN  V# )zReceive EXACTLY the number of bytes requested from the file object.

Blocks until the required number of bytes have been received.r   Connection closed unexpectedly)lenreadr7   )r   filecountdatads   &&&  r   _readallsocksocket._readall.  sG     $i%		%#d)+,A'(HIIIDr   c                   < Wn          V P                  4       p\        \        V `  V P                   4       R #   \
        P                   d     R # i ; ir)   )r   get_proxy_peernamer   rG   re   rX   ri   )r   rl   peerr   s   && r   re   socksocket.settimeout:  sD    	**,D*d.t}}=|| 		s   -8 AAc                    V P                   # r)   )r   r*   s   &r   r   socksocket.gettimeoutC  s    }}r   c                ^    V'       d   V P                  R 4       R # V P                  R4       R # )Ng        )re   )r   vs   &&r   r   socksocket.setblockingF  s    OOD!OOC r   c                |    YY4V'       d   VP                  4       MRV'       d   VP                  4       MR3V n        R# )a&  Sets the proxy to be used.

proxy_type -  The type of the proxy to be used. Three types
                are supported: PROXY_TYPE_SOCKS4 (including socks4a),
                PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
addr -        The address of the server (IP or DNS).
port -        The port of the server. Defaults to 1080 for SOCKS
                servers and 8080 for HTTP proxy servers.
rdns -        Should DNS queries be performed on the remote side
               (rather than the local side). The default is True.
               Note: This has no effect with SOCKS4 servers.
username -    Username to authenticate with to the server.
               The default is no authentication.
password -    Password to authenticate with to the server.
               Only relevant when username is also provided.N)rF   r   )r   rI   rJ   rK   rL   rM   rN   s   &&&&&&&r   rf   socksocket.set_proxyL  s.    " !+3hoo'+3hoo'?
r   c                \    R V9   d   VP                  R 4      VR&   V P                  ! V/ VB # rQ   )rS   rf   )r   r   r   s   &*,r   setproxysocksocket.setproxya  s1    & #)::k#:F< ~~t.v..r   c                  < V P                   w  r4rVppV'       d    V P                  \        P                  8w  d   \        P
                  ! V .VO5/ VB # V P                  '       d   \        P                  ! \        R4      hV\        8w  d   Rp	\        P                  ! \        V	4      h\        \        V `  ! V/ VB  V P                  4       w  rRV3p\	        4       V n        V P                  4       pV P                  P                  V4       RpV P!                  V P                  W4      w  rVw  pp
Vw  r\        \        V `?  VV34       \        \        V `G  V P$                  4       RV n        R# )zNImplements proxy connection for UDP sockets.

Happens during the bind() phase.z"Socket already bound to an addressz'UDP only supported by SOCKS5 proxy type0   N)0.0.0.0r   )r   r   rX   r   r   rg   r   ri   r   r   r   r   rG   getsockname_proxy_addrrh   _SOCKS5_requestre   r   r   )r   r   r   rI   rn   ro   rL   rM   rN   r#   _rK   dstr   UDP_ASSOCIATErelayhostr   s   &*,              r   rg   socksocket.bindf  s7   
 ZZ	8	TYY&*;*;;$$T6C6266???,,v'KLL;C,,z3//j$$c0R0
 ""$Dk&.  "&''L aj$'t5j$*4==9,r   c                  < V P                   \        P                  8w  d   \        \        V `  ! V.VO5/ VB # V P                  '       g   V P                  R4       VR,          pVRR p\        4       pRpVP                  V4       RpVP                  V4       V P                  WF4       \        \        V `.  ! VP                  4       V,           .VO5/ VB p	WP                  4       ,
          # ) Ns         r   r   )r   rX   r   r   rG   sendtor   rg   r   write_write_SOCKS5_addresssendgetvaluetell)r   bytesr   r   addressflagsheaderRSV
STANDALONEsentr   s   &&*,      r   r   socksocket.sendto  s    99)))T1%I$I&IIIIgr(Sb	S
Z ""73Z+FOO,=,E 6 6.46kkm##r   c                   < V P                   \        P                  8X  d   V P                  ! WV P                  3/ VB # \
        \        V `  ! W3/ VB # r)   )r   rX   r   r   r   r   rG   r   )r   r   r   r   r   s   &&&,r   r   socksocket.send  sH    99)));;uT-@-@KFKKT/GGGr   c                ^  < V P                   \        P                  8w  d   \        \        V `  W4      # V P                  '       g   V P                  R4       \        \        \        V `'  VR,           V4      4      pVP                  ^\        4       VP                  ^4      p\        V4      '       d   \        R4      hV P                  V4      w  rVV P                   '       d9   V P                   w  rxWW8w  g
   V^ V39  d   \        P"                  ! \$        R4      hVP                  V4      WV33# )r   i   zReceived UDP packet fragmentzPacket filteredr   )r   rX   r   r   rG   recvfromr   rg   r   recvseekr   r   ordNotImplementedError_read_SOCKS5_addressr   ri   r   )
r   bufsizer   buffragfromhostfromportpeerhostpeerportr   s
   &&&      r   r   socksocket.recvfrom  s    99)))T3GCCIIgeJ27T>5IJHxx{t99%&DEE!66s;!%!4!4H#x8}'Dll6+<==!H#788r   c                .    V P                   ! V/ VB w  r4V# r)   )r   )r   r   r   r   r   s   &*,  r   r   socksocket.recv  s    ==#,,r   c                   < V P                   '       d   V P                   P                  4        \        \        V `  4       # r)   )r   rj   r   rG   )r   r   s   &r   rj   socksocket.close  s,    ???OO!!#Z,..r   c                    V P                   # )z:Returns the bound IP address and port number at the proxy.)r   r*   s   &r   get_proxy_socknamesocksocket.get_proxy_sockname  s    """r   c                "    V P                  4       # )z.
Returns the IP and port number of the proxy.
)getpeernamer*   s   &r   r   socksocket.get_proxy_peername  s     !!r   c                    V P                   # )zoReturns the IP address and port number of the destination machine.

Note: get_proxy_peername returns the proxy.)r   r*   s   &r   get_peernamesocksocket.get_peername  s     """r   c                H    RpV P                  WV4      w  V n        V n        R# )z7Negotiates a stream connection through a SOCKS5 server.   N)r   r   r   )r   	dest_addrCONNECTs   &* r   _negotiate_SOCKS5socksocket._negotiate_SOCKS5  s'    373G3G94&0T0r   c                  < V P                   w  rErgrVP                  R4      p
VP                  R^ 4      p V'       d   V	'       d   V
P                  R4       MV
P                  R4       V
P                  4        V P	                  V^4      pVR,          R8w  d   \        R4      hVR,          R	8X  d   V'       d	   V	'       g   \        R
4      hV
P                  R\        \        V4      4      P                  4       ,           V,           \        \        V	4      4      P                  4       ,           V	,           4       V
P                  4        V P	                  V^4      pVR,          R8w  d   \        R4      hVR,          R8w  d   \        R4      hM2VR,          R8w  d%   VR,          R8X  d   \        R4      h\        R4      hV
P                  RV,           R,           4       V P                  W:4      pV
P                  4        V P	                  V^4      pVR,          R8w  d   \        R4      h\        VR,          4      pV^ 8w  d2   \        P                  VR4      p\        RP                  VV4      4      hV P!                  V4      p\"        \$        V `O  V P(                  4       VV3VP+                  4        V
P+                  4        #   TP+                  4        T
P+                  4        i ; i)zy
Send SOCKS5 request with given command (CMD field) and
address (DST field). Returns resolved DST address that was used.
wbrbs    s    r      N   %SOCKS5 proxy server sent invalid datar     N   zPNo username/password supplied. Server requested username/password authenticationr   r   zSOCKS5 authentication failed   z7All offered SOCKS5 authentication methods were rejectedUnknown error{:#04x}: {})r   makefiler   flushr   r7   r>   chrr   rF   r   r   SOCKS5_ERRORSgetr@   r%   r   r   rG   re   r   rj   )r   conncmdr   rI   rJ   rK   rL   rM   rN   writerreaderchosen_authauth_statusresolvedrespstatusri   bndr   s   &&&&               r   r   socksocket._SOCKS5_request  s   
 <@::8
$ht$tQ'W	H 01 _- LLN--2K37* (;= =
 37* !X * +< = = Ws3x='9'@'@'BB'("3x=188:;  (( ) "mmFA6s#w.+?A As#w.)*HII / S!W,s#w.)$% % ,?A A LL30111#>HLLN ==+DCyG#';= = c^F~%))&/B!-"6"6vu"EFF ++F3C*d.t}}=c?LLNLLN LLNLLNs   K A3K :K G%K "K*c                `   Vw  r4V P                   w  p rgr\        P                  R\        P                  R/p
\        P                  \        P                  3 Fw  p \        P                  ! W4      pVP                  W,          V,           4       \        P                  ! W4      pVP                  \        P                  ! RV4      4       W43u # 	  V'       dR   VP                  R4      pVP                  R\        \        V4      4      P                  4       ,           V,           4       M\        P                  ! W4\        P                  \        P                  \        P                   \        P"                  4      pV^ ,          pV^ ,          pV^,          ^ ,          p\        P                  ! W4      pVP                  W,          V,           4       \        P                  ! W4      pVP                  \        P                  ! RV4      4       W43#   \        P                   d     EK  i ; i)zf
Return the host and port packed for the SOCKS5 protocol,
and the resolved address as a tuple object.
r      >Hidnar   )r   rX   AF_INETAF_INET6	inet_ptonr   	inet_ntopstructpackri   rF   r  r   r_   	AF_UNSPECr`   IPPROTO_TCPAI_ADDRCONFIG)r   rJ   r   r   rK   rI   r   rL   rM   rN   family_to_byterx   
addr_bytes
host_bytes	addressestarget_addrs   &&&             r   r    socksocket._write_SOCKS5_address@  s   
 
59ZZ2
Aq ..'6??GL
 ~~v7F#--f;


>1J>?'';

6;;tT23z! 8 V,JJJwS_!5!<!<!>>KL **4v7G7G+1+=+=+1+=+=+1+?+?AI $A,K ^Fq>!$D))&7JJJ~-
:;##F7D

6;;tT*+z1 << s   A2HH-,H-c                   V P                  V^4      pVR8X  d(   \        P                  ! V P                  V^4      4      pM}VR8X  d/   V P                  V^4      pV P                  V\        V4      4      pMHVR8X  d7   \        P                  ! \        P
                  V P                  V^4      4      pM\        R4      h\        P                  ! RV P                  V^4      4      ^ ,          pW53# )r  r   r   r  r  r  )	r   rX   	inet_ntoar   r"  r   r7   r#  unpack)r   r   atyprJ   lengthrK   s   &&    r   r   socksocket._read_SOCKS5_addressm  s    }}T1%7?##DMM$$:;DW_]]4+F==s6{3DW_##FOOT]]45LMD#$KLL}}T4==q#9:1=zr   c                   V P                   w  r4rVrxV P                  R4      p	V P                  R^ 4      p
 Rp \        P                  ! V4      pV	P                  \        P                  ! R^^V4      4       V	P                  V4       V'       d   V	P                  V4       V	P                  R4       V'       d(   V	P                  VP                  R4      R,           4       V	P                  4        V P                  V
^4      pVR	,          R8w  d   \        R
4      h\        VR,          4      pV^Z8w  d1   \        P                  VR4      p\!        RP#                  W4      4      h\        P$                  ! VR,          4      \        P&                  ! RVR,          4      ^ ,          3V n        V'       d   \        P$                  ! V4      V3V n        MW3V n        V
P-                  4        V	P-                  4        R#   \        P                   d>    T'       d   RpRp EL\        P                  ! \        P
                  ! T4      4      p ELi ; i  T
P-                  4        T	P-                  4        i ; i)z0Negotiates a connection through a SOCKS4 server.r   r   Fs      Tz>BBHr   r  r  z%SOCKS4 proxy server sent invalid datar  r	  r
  :   NNr  :r  r5  NN)r   r  rX   	inet_atonri   gethostbynamer   r#  r$  rF   r  r   r7   r   SOCKS4_ERRORSr  rB   r%   r/  r0  r   r   rj   )r   r   	dest_portrI   rJ   rK   rL   rM   rN   r  r  remote_resolver)  r  r  ri   s   &&&             r   _negotiate_SOCKS4socksocket._negotiate_SOCKS4|  s   ;?::8
$ht$tQ'4	"N	9#--i8
 LLVT4CDLL$ X&LL!
 Y--f5?@LLN ==+DCyG#';= = c^F~%))&/B!-"6"6v"EFF $*#3#3DH#=#)==tCy#A!#D#FD&,&6&6z&BI&M#&/&:#LLNLLN_ << 9!4J%)N!'!1!1,,Y7"9J9\ LLNLLNsT   I G; A I )I 9C9I 3&I ;III *I	I II "I2c                   V P                   w  r4rVrxV'       d   TM\        P                  ! V4      pRVP                  R4      ,           R,           \	        V4      P                  4       ,           R,           RVP                  R4      ,           .p	V'       d8   V'       d0   V	P                  R\        VR,           V,           4      ,           4       V	P                  R4       V P                  RP                  V	4      4       V P                  4       p
V
P                  4       pV
P                  4        V'       g   \        R4      h VP                  R	^4      w  rpTP                  R4      '       g   \        R4      h \!        T4      pT^8w  d-   RP%                  Y4      pTR9   d
   TR,          p\#        T4      hRT n        YB3T n        R#   \         d    \        R
4      hi ; i  \         d    \#        R4      hi ; i)zoNegotiates a connection through an HTTP server.

NOTE: This currently only supports HTTP CONNECT-style proxies.s   CONNECT r     :s	    HTTP/1.1s   Host: s   Proxy-Authorization: basic s   
r    z'HTTP proxy server sent invalid responsezHTTP/z0Proxy server does not appear to be an HTTP proxyz4HTTP proxy server did not return a valid HTTP statusz{}: {}za
[*] Note: The HTTP proxy server may not be supported by PySocks (must be a CONNECT tunnel proxy)N)i  i  i  )s   0.0.0.0r   )r   rX   r7  rF   strappendr   sendalljoinr  readlinerj   r7   splitr   r]   rc   rD   r%   r   r   )r   r   r9  rI   rJ   rK   rL   rM   rN   http_headersfobjstatus_linerz   status_code
status_msgri   s   &&&             r   _negotiate_HTTPsocksocket._negotiate_HTTP  s    <@::8
$h !yf&:&:9&E 4;;v..59~$$&')56	((00
  >"+HtOh,F"G!H I 	G$W\\,/0 }}mmo

#$DEE	O-8->->sA-F*E
 ((#BD D	Hk*K
 #OOK<Eo-  $ % E""-"o1  	O#$MNN	O  	HFH H	Hs   G 9G" G"G9c                  < \        V4      ^8w  g   V^ ,          P                  R4      '       d'   \        P                  ! R\	        V4      ,          4      hVw  r4V P
                  \        P                  8X  d\   V P                  '       g   V P                  R
4       \        P                  ! V4      pVR8X  d   V'       g
   RV n
        R# W43V n
        R# V P                  w  rVrxp	p
\        V\        \        34      '       d/   \        V4      ^8w  g   V'       d   \        V\        4      '       g   \!        R4      h\"        \$        V `O  V P(                  4       Vf:   Wn
        \"        \$        V `O  V P(                  4       \"        \$        V `W  W434       R# V P-                  4       p \"        \$        V `W  V4        V P.                  V,          pV! WV4       R#   \        P                   d,   pT'       g   T P1                  4        \!        RT4      hThRp?i\2         d    T P1                  4        h i ; i  \        P                   du   pT P1                  4        T'       gV   Tw  rgRP5                  Yg4      p\6        T,          pRP5                  TT4      p\8        P;                  R	Y4       \=        Y4      hThRp?ii ; i)z
Connects to the specified destination through a proxy.
Uses the same API as socket's connect().
To select the proxy server, use set_proxy().

dest_pair - 2-tuple of (IP/hostname, port).
r\   z PySocks doesn't support IPv6: %sr   Nz0Invalid destination-connection (host, port) pairzSocket errorz{}:{}zError connecting to {} proxy {}z%s due to: %sr   )r   r]   rX   ri   r@  r   r   r   rg   r7  r   r   rb   r   tuplerc   r7   r   rG   re   r   rh   r   _proxy_negotiatorsrj   r!   r%   PRINTABLE_PROXY_TYPESlogdebugr<   )r   rk   catch_errorsr   r9  rI   rn   ro   rL   rM   rN   	negotiateri   proxy_serverprintable_typer#   r   s   &&&             r   rh   socksocket.connect  sN    y>Q)A,"9"9#">"> ,,A!$Y 0 1 1  )	99)))???		'",,Y7I I%i&*#  (1&<# ZZ	8	 9tUm44y>Q& !)S11#BD D
 	j$*4==9"+*d.t}}=*d+Y,BC%%'
#	*d+J7& 33J?	$95<<  #JJL+NEBBK 

9 || 	JJL)3&
&~~jE!6z!B7>>~DPR		/36*366	s7   %H5 9G H2,&HH2H25J>
A/J99J>c                     V P                  VRR7       ^ #   \         d*   pTP                  '       d   TP                  u Rp?# h Rp?ii ; i)a  https://docs.python.org/3/library/socket.html#socket.socket.connect_ex
Like connect(address), but return an error indicator instead of raising an exception for errors returned by the C-level connect() call (other problems, such as "host not found" can still raise exceptions).
T)rS  N)rh   OSErrorerrno)r   rk   r   s   && r   
connect_exsocksocket.connect_exV  sA    
		LLL6 	 wwwww	s    AAAAAc                    V P                   w  rr4ppT;'       g    \        P                  V4      pV'       g   \        R4      hW#3# )z4
Return proxy address to connect to as tuple object
zInvalid proxy type)r   DEFAULT_PORTSr  r7   )r   rI   rn   ro   rL   rM   rN   s   &      r   r   socksocket._proxy_addrf  sI    
 ZZ	8	@@=#4#4Z#@
#$899%%r   )r   r   r   r   r   NNNTNN)r   r)   )-r-   r.   r/   r0   r1   rH   rX   r  r`   r&   r   re   r   r   rf   r   rg   r   r   r   r   rj   r   getproxysocknamer   getproxypeernamer   r   r   r   r   r   r;  rK  r
   r   r   rO  r   rh   r[  r   r2   r3   __classcell__)r   r5   s   @@r   rG   rG     s      M$nn63E3E$
!?*/
#-J$(H9(/
# *" *# K&`D+Z:x9.x "#4!#4 Z Zx  	& 	&r   rG   )   r   r`  )	NNNNNTNNN)r   r   r   r   )Er1   base64r   collections.abcr   ImportErrorcollectionsrZ  r   r   r   r   ior   loggingosr   rX   r#  sys__version__r   version_infowin_inet_pton	getLoggerr-   rQ  PROXY_TYPE_SOCKS4r
   PROXY_TYPE_SOCKS5r   PROXY_TYPE_HTTPr   PROXY_TYPESr   zipvalueskeysrP  
_orgsocketr   r   IOErrorr!   r7   r<   r>   r@   rB   rD   r8  r  r^  rO   rT   rV   getdefaultproxyrZ   
wrapmoduler   r   r   r   methodrb   r   rA  setattrrG   r8   r   r   <module>r~     so  @ %( - ,    	    
 77d?s''&0H
 !  F  F $664@S!3!3!5{7G7G7IJK "MM )
\&
 
	
 		: 		j 		* 		* 		
 	 	
&  !	 	
(
-


-
4
&	 vtT48I.$ $	> 
:3z
&-- 
I2D[$-F fh''%%d+T;t#45 3^	& ^	&[  %$$%$  HFH 	HHs   G #G GGG'