
    6=g.5              
      V   S SK Jr  S SKrS SKrS SKrSSKJr  SSKJrJ	r	  SSK
JrJr  SSKJrJrJrJrJrJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  \R@                  " S5      r!SSSSS.r"SSSSSSSSSS.	r#SS.         S%S  jjr$ " S! S"\5      r% " S# S$\5      r&g)&    )annotationsN   )SyncBackend)NetworkBackendNetworkStream)ConnectionNotAvailable
ProxyError)URLOriginRequestResponseenforce_bytesenforce_url)default_ssl_context)Lock)Trace   )ConnectionPool)HTTP11Connection)ConnectionInterfacezhttpcore.sockszNO AUTHENTICATION REQUIREDGSSAPIzUSERNAME/PASSWORDzNO ACCEPTABLE METHODS)             	SucceededzGeneral SOCKS server failurez!Connection not allowed by rulesetzNetwork unreachablezHost unreachablezConnection refusedzTTL expiredzCommand not supportedzAddress type not supported)	r   r   r                     )authc                  [         R                  R                  5       nUc$  [         R                  R                  R                  O#[         R                  R                  R
                  nUR                  [         R                  R                  U/5      5        UR                  5       nU R                  U5        U R                  SS9nUR                  U5      n[        U[         R                  R                  5      (       d   eUR                  U:w  aH  [        R!                  US5      n	[        R!                  UR                  S5      n
[#        SU	 SU
 S35      eUR                  [         R                  R                  R
                  :X  a  Uc   eUu  pUR                  [         R                  R%                  X5      5        UR                  5       nU R                  U5        U R                  SS9nUR                  U5      n[        U[         R                  R&                  5      (       d   eUR(                  (       d  [#        S5      eUR                  [         R                  R*                  R-                  [         R                  R.                  R0                  X45      5        UR                  5       nU R                  U5        U R                  SS9nUR                  U5      n[        U[         R                  R2                  5      (       d   eUR4                  [         R                  R6                  R8                  :w  a/  [:        R!                  UR4                  S5      n[#        S	U S35      eg )
Ni   )	max_bytesUNKNOWNz
Requested z from proxy server, but got .zInvalid username/passwordUNKOWNz Proxy Server could not connect: )socksiosocks5SOCKS5ConnectionSOCKS5AuthMethodNO_AUTH_REQUIREDUSERNAME_PASSWORDsendSOCKS5AuthMethodsRequestdata_to_sendwritereadreceive_data
isinstanceSOCKS5AuthReplymethodAUTH_METHODSgetr	   SOCKS5UsernamePasswordRequestSOCKS5UsernamePasswordReplysuccessSOCKS5CommandRequestfrom_addressSOCKS5CommandCONNECTSOCKS5Reply
reply_codeSOCKS5ReplyCode	SUCCEEDEDREPLY_CODES)streamhostportr#   connauth_methodoutgoing_bytesincoming_bytesresponse	requested	respondedusernamepasswordrB   s                 </usr/lib/python3/dist-packages/httpcore/_sync/socks_proxy.py_init_socks5_connectionrS   *   s    >>**,D
 < 	''88^^,,>> 
 	IIgnn55{mDE&&(N
LL  [[4[0N  0Hh > >????+% $$[)<	 $$X__i@	#?	{!L
 	
 '..99KKK!		'..>>xRS**,^$  t4$$^4(GNN$N$NOOOO899 	II++88NN((004,	

 &&(N
LL  [[4[0N  0Hh : :;;;;gnn<<FFF __X%8%8(C
;J<qIJJ G    c                  z   ^  \ rS rSrSr         S                     SU 4S jjjrSS jrSrU =r$ )	
SOCKSProxyi   z:
A connection pool that sends requests via an HTTP proxy.
c                   > [         TU ]  UUUUUUU
U	S9  X0l        [        USS9U l        Ub"  Uu  p[        USS9n[        USS9nUU4U l        gSU l        g)aF  
A connection pool for making HTTP requests.

Parameters:
    proxy_url: The URL to use when connecting to the proxy server.
        For example `"http://127.0.0.1:8080/"`.
    ssl_context: An SSL context to use for verifying connections.
        If not specified, the default `httpcore.default_ssl_context()`
        will be used.
    max_connections: The maximum number of concurrent HTTP connections that
        the pool should allow. Any attempt to send a request on a pool that
        would exceed this amount will block until a connection is available.
    max_keepalive_connections: The maximum number of idle HTTP connections
        that will be maintained in the pool.
    keepalive_expiry: The duration in seconds that an idle HTTP connection
        may be maintained for before being expired from the pool.
    http1: A boolean indicating if HTTP/1.1 requests should be supported
        by the connection pool. Defaults to True.
    http2: A boolean indicating if HTTP/2 requests should be supported by
        the connection pool. Defaults to False.
    retries: The maximum number of retries when trying to establish
        a connection.
    local_address: Local address to connect from. Can also be used to
        connect using a particular address family. Using
        `local_address="0.0.0.0"` will connect using an `AF_INET` address
        (IPv4), while using `local_address="::"` will connect using an
        `AF_INET6` address (IPv6).
    uds: Path to a Unix Domain Socket to use instead of TCP sockets.
    network_backend: A backend instance to use for handling network I/O.
)ssl_contextmax_connectionsmax_keepalive_connectionskeepalive_expiryhttp1http2network_backendretries	proxy_url)nameN
proxy_auth)super__init___ssl_contextr   
_proxy_urlr   _proxy_auth)selfra   rc   rY   rZ   r[   r\   r]   r^   r`   r_   rP   rQ   username_bytespassword_bytes	__class__s                  rR   re   SOCKSProxy.__init__n   s    V 	#+&?-+ 	 		
 (%ikB!!+H*8,GN*8,GN<D
  $DrT   c                    [        U R                  R                  UU R                  U R                  U R
                  U R                  U R                  U R                  S9$ )N)proxy_originremote_originrc   rY   r\   r]   r^   r_   )	Socks5Connectionrg   originrh   rf   _keepalive_expiry_http1_http2_network_backendri   rr   s     rR   create_connectionSOCKSProxy.create_connection   sQ    // ''))!33++++ 11	
 		
rT   )rh   rg   rf   )	NN
   NNTFr   N)ra   zURL | bytes | strrc   z&tuple[bytes | str, bytes | str] | NonerY   ssl.SSLContext | NonerZ   
int | Noner[   r|   r\   float | Noner]   boolr^   r~   r`   intr_   NetworkBackend | NonereturnNone)rr   r   r   r   )	__name__
__module____qualname____firstlineno____doc__re   rx   __static_attributes____classcell__)rl   s   @rR   rV   rV   i   s     >B-1&(04)-15@$$@$ ;@$ +	@$
 $@$ $.@$ '@$ @$ @$ @$ /@$ 
@$ @$D

 

rT   rV   c                      \ rS rSr      S                 SS jjrSS jrSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSS jrSS jrSrg)rq      Nc	                    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Uc
  [        5       OUU l        [        5       U l
        S U l        SU l        g )NF)_proxy_origin_remote_originrh   rf   rs   rt   ru   r   rv   r   _connect_lock_connection_connect_failed)	ri   ro   rp   rc   rY   r\   r]   r^   r_   s	            rR   re   Socks5Connection.__init__   s^     *+%'!1 -4KM/ 	 "V7;$rT   c                   UR                   R                  S0 5      nUR                   R                  SS 5      nUR                  SS 5      nU R                     U R                  Gc\   U R                  R
                  R                  S5      U R                  R                  US.n[        S[        X5       nU R                  R                  " S0 UD6nXvl        S S S 5        WU R                  R
                  R                  S5      U R                  R                  U R                  S.n[        S[        X5       n[        S0 UD6  Xvl        S S S 5        U R                  R                   S	:X  a  U R"                  c
  [%        5       OU R"                  nU R&                  (       a  S
S/OS
/n	UR)                  U	5        UU=(       d%    U R                  R
                  R                  S5      US.n[        S[        X5       nUR*                  " S0 UD6nXvl        S S S 5        UR-                  S5      n
U
S L=(       a    U
R/                  5       S:H  nU(       d"  U R&                  (       a9  U R0                  (       d(  SSKJn  U" U R                  UU R6                  S9U l        ON[9        U R                  UU R6                  S9U l        O)U R                  R?                  5       (       d
  [A        5       eS S S 5        U R                  RC                  U5      $ ! , (       d  f       GN== f! , (       d  f       GN= f! , (       d  f       GN$= f! [:         a  nSU l        UeS nAff = f! , (       d  f       Nz= f)Ntimeoutsni_hostnameconnectascii)rG   rH   r   connect_tcp)rF   rG   rH   r#   setup_socks5_connection   httpszhttp/1.1h2)rY   server_hostnamer   	start_tls
ssl_objectr   )HTTP2Connection)rr   rF   r\   T )"
extensionsr9   r   r   r   rG   decoderH   r   loggerrv   r   return_valuer   rh   rS   schemerf   r   ru   set_alpn_protocolsr   get_extra_infoselected_alpn_protocolrt   r^   r   rs   r   	Exceptionr   is_availabler   handle_request)ri   requesttimeoutsr   r   kwargstracerF   rY   alpn_protocolsr   http2_negotiatedr   excs                 rR   r   Socks5Connection.handle_request   s   %%)))R8))--ndC,,y$/'H !% 2 2 7 7 > >w G $ 2 2 7 7#*F
 }fgF%!%!6!6!B!B!LV!L-3* G #) $ 3 3 8 8 ? ? H $ 3 3 8 8 $ 0 0	F 167/9&9-3*	 **11X=  $008 01!%!2!2 $ 37++Z.J< ' $66~F ,7/; 0H#2277>>wG'.	" #;HE%+%5%5%?%?F17. I
 "(!6!6|!DJ"$. H&==?4G % (DKK:+:#'#6#6#)-1-C-C,( ,<#'#6#6#)-1-C-C,( %%2244,..Y  \ ..w77K GF 0 IH8 ! +/D(IQ  s   M'AM5#LA!M9L B1M<L2BMM$M*M
L	M 
L/	*M2
M	<M
M	MMM
M-c                    XR                   :H  $ N)r   rw   s     rR   can_handle_request#Socks5Connection.can_handle_request-  s    ,,,,rT   c                T    U R                   b  U R                   R                  5         g g r   )r   closeri   s    rR   r   Socks5Connection.close0  s%    '""$ (rT   c                   U R                   c\  U R                  =(       aI    U R                  R                  S:H  =(       d    U R                  (       + =(       a    U R
                  (       + $ U R                   R                  5       $ )Nr   )r   ru   r   r   rt   r   r   r   s    rR   r   Socks5Connection.is_available4  sh    #
  -((//8;N4;;-,,,
 ,,..rT   c                h    U R                   c  U R                  $ U R                   R                  5       $ r   )r   r   has_expiredr   s    rR   r   Socks5Connection.has_expired@  s/    #'''++--rT   c                h    U R                   c  U R                  $ U R                   R                  5       $ r   )r   r   is_idler   s    rR   r   Socks5Connection.is_idleE  s/    #'''''))rT   c                h    U R                   c  U R                  $ U R                   R                  5       $ r   )r   r   	is_closedr   s    rR   r   Socks5Connection.is_closedJ  s/    #'''))++rT   c                z    U R                   c  U R                  (       a  S$ S$ U R                   R                  5       $ )NzCONNECTION FAILED
CONNECTING)r   r   infor   s    rR   r   Socks5Connection.infoO  s7    #*.*>*>&PLP$$&&rT   c                X    SU R                   R                   SU R                  5        S3$ )N<z [z]>)rl   r   r   r   s    rR   __repr__Socks5Connection.__repr__T  s(    4>>**+2diik]"==rT   )r   r   r   rt   ru   rs   rv   rh   r   r   rf   )NNNTFN)ro   r   rp   r   rc   tuple[bytes, bytes] | NonerY   r{   r\   r}   r]   r~   r^   r~   r_   r   r   r   )r   r   r   r   )rr   r   r   r~   )r   r   )r   r~   )r   str)r   r   r   r   re   r   r   r   r   r   r   r   r   r   r   r   rT   rR   rq   rq      s    
 26-1)-15%% % /	%
 +% '% % % /% 
%4S8j-%
/.
*
,
'
>rT   rq   )
rF   r   rG   bytesrH   r   r#   r   r   r   )'
__future__r   loggingsslr)   _backends.syncr   _backends.baser   r   _exceptionsr   r	   _modelsr
   r   r   r   r   r   _sslr   _synchronizationr   _tracer   connection_poolr   http11r   
interfacesr   	getLoggerr   r8   rE   rS   rV   rq   r   rT   rR   <module>r      s    "  
  ( : < P P & #  + $ +			+	, * $	 +0"!$)
$ (,<K<K <K 	<K
 %<K 
<K~Q
 Q
hX>* X>rT   