
    f j.5              
      J   d dl mZ d dlZd dlZd dlZddlmZ ddlmZm	Z	 ddl
mZmZ ddlmZmZmZmZmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ  ej         d          Z!dddddZ"dddddddddd	Z#ddd/d*Z$ G d+ d,e          Z% G d- d.e          Z&dS )0    )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                     )authstreamr   hostbytesportintr#   tuple[bytes, bytes] | NonereturnNonec                  t           j                                        }|t           j        j        j        nt           j        j        j        }|                    t           j                            |g                     |                                }| 	                    |           | 
                    d          }|                    |          }t          |t           j        j                  sJ |j        |k    rQt                              |d          }	t                              |j        d          }
t#          d|	 d|
 d          |j        t           j        j        j        k    r|J |\  }}|                    t           j                            ||                     |                                }| 	                    |           | 
                    d          }|                    |          }t          |t           j        j                  sJ |j        st#          d          |                    t           j        j                            t           j        j        j        ||f                     |                                }| 	                    |           | 
                    d          }|                    |          }t          |t           j        j                  sJ |j        t           j        j        j        k    r3t:                              |j        d          }t#          d	| d          d S )
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)r$   r%   r'   r#   connauth_methodoutgoing_bytesincoming_bytesresponse	requested	respondedusernamepasswordrJ   s                 nC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\httpcore/_sync/socks_proxy.py_init_socks5_connectionrX   *   s    >**,,D
 	?'88^,> 
 	IIgn55{mDDEEE&&((N
LL    [[4[00N  00Hh >?????+% 
 $$[)<<	 $$X_i@@	LLL	LLL
 
 	
 '.9KK :!(		'.>>xRRSSS**,,^$$$  t44$$^44(GN$NOOOOO 	:8999 	II+88N(04,	
 	
  
 &&((N
LL    [[4[00N  00Hh :;;;;;gn<FF K __X%8(CC
IJIIIJJJK K    c                  @     e Zd ZdZ	 	 	 	 	 	 	 	 	 d d! fdZd"dZ xZS )#
SOCKSProxyzB
    A connection pool that sends requests via an HTTP proxy.
    N
   TFr   	proxy_urlURL | bytes | str
proxy_auth&tuple[bytes | str, bytes | str] | Nonessl_contextssl.SSLContext | Nonemax_connections
int | Nonemax_keepalive_connectionskeepalive_expiryfloat | Nonehttp1boolhttp2retriesr(   network_backendNetworkBackend | Noner*   r+   c           
     
   t                                          |||||||
|	           || _        t          |d          | _        |2|\  }}t          |d          }t          |d          }||f| _        dS d| _        dS )a&  
        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.
        )ra   rc   re   rf   rh   rj   rl   rk   r]   )nameNr_   )super__init___ssl_contextr   
_proxy_urlr   _proxy_auth)selfr]   r_   ra   rc   re   rf   rh   rj   rk   rl   rU   rV   username_bytespassword_bytes	__class__s                  rW   rq   zSOCKSProxy.__init__n   s    V 	#+&?-+ 	 		
 		
 		
 (%ikBBB 		$!+Hh*8,GGGN*8,GGGN<D
  $DrY   originr   r   c           
         t          | j        j        || j        | j        | j        | j        | j        | j                  S )N)proxy_originremote_originr_   ra   rf   rh   rj   rl   )	Socks5Connectionrs   ry   rt   rr   _keepalive_expiry_http1_http2_network_backendru   ry   s     rW   create_connectionzSOCKSProxy.create_connection   sF    / ')!3++ 1	
 	
 	
 		
rY   )	NNr\   NNTFr   N)r]   r^   r_   r`   ra   rb   rc   rd   re   rd   rf   rg   rh   ri   rj   ri   rk   r(   rl   rm   r*   r+   )ry   r   r*   r   )__name__
__module____qualname____doc__rq   r   __classcell__)rx   s   @rW   r[   r[   i   s          >B-1&(04)-15@$ @$ @$ @$ @$ @$ @$D

 

 

 

 

 

 

 

rY   r[   c                  l    e Zd Z	 	 	 	 	 	 d#d$dZd%dZd&dZd'dZd(dZd(dZd(dZ	d(dZ
d)d!Zd)d"ZdS )*r}   NTFr{   r   r|   r_   r)   ra   rb   rf   rg   rh   ri   rj   rl   rm   r*   r+   c	                    || _         || _        || _        || _        || _        || _        || _        |t                      n|| _        t                      | _
        d | _        d| _        d S )NF)_proxy_origin_remote_originrt   rr   r~   r   r   r   r   r   _connect_lock_connection_connect_failed)	ru   r{   r|   r_   ra   rf   rh   rj   rl   s	            rW   rq   zSocks5Connection.__init__   sx     *+%'!1 -IKMMM/ 	 "VV7;$rY   requestr   r   c                   |j                             di           }|j                             dd           }|                    dd           }| j        5  | j        D	 | j        j                            d          | j        j        |d}t          dt          ||          5 } | j
        j        di |}||_        d d d            n# 1 swxY w Y   || j        j                            d          | j        j        | j        d}t          dt          ||          5 }t          di | ||_        d d d            n# 1 swxY w Y   | j        j        d	k    r| j        t%                      n| j        }| j        rd
dgnd
g}	|                    |	           ||p| j        j                            d          |d}t          dt          ||          5 } |j        di |}||_        d d d            n# 1 swxY w Y   |                    d          }
|
d uo|
                                dk    }|s| j        r+| j        s$ddlm}  || j        || j                  | _        n!t9          | j        || j                  | _        nB# t:          $ r}d| _        |d }~ww xY w| j                                        stA                      d d d            n# 1 swxY w Y   | j        !                    |          S )Ntimeoutsni_hostnameconnectascii)r%   r'   r   connect_tcp)r$   r%   r'   r#   setup_socks5_connection   httpszhttp/1.1h2)ra   server_hostnamer   	start_tls
ssl_objectr   )HTTP2Connection)ry   r$   rf   T )"
extensionsrA   r   r   r   r%   decoder'   r   loggerr   r   return_valuer   rt   rX   schemerr   r   r   set_alpn_protocolsr   get_extra_infoselected_alpn_protocolr   rj   r   r~   r   	Exceptionr   is_availabler   handle_request)ru   r   timeoutsr   r   kwargstracer$   ra   alpn_protocolsr   http2_negotiatedr   excs                 rW   r   zSocks5Connection.handle_request   s   %)))R88)--ndCC,,y$// L	/ L	/ K/H !% 2 7 > >w G G $ 2 7#* F
 }fgvFF 4%!B!6!B!L!LV!L!L-3*4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 #) $ 3 8 ? ? H H $ 3 8 $ 0	 F 167F  4/99&999-3*	4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 *1X= 8  $03/111!%!2 $ 37+OZ..J< ' $66~FFF ,7/; 0H#27>>wGG'.	" " #;HH 8E%5V%5%?%?%?%?F17E.8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
 "(!6!6|!D!DJ"$. H&==??4G % ( ,0K ;:::::+:?#'#6#)-1-C, , ,(( ,<#'#6#)-1-C, , ,(
 !   +/D(I %2244 /,...YL	/ L	/ L	/ L	/ L	/ L	/ L	/ L	/ L	/ L	/ L	/ L	/ L	/ L	/ L	/\ ..w777s   	KAJ"C<JC	JC	AJD=1J=E	JE	BJG4(J4G8	8J;G8	<B	JK
J	JJ*KKKry   c                    || j         k    S N)r   r   s     rW   can_handle_requestz#Socks5Connection.can_handle_request-  s    ,,,rY   c                J    | j         | j                                          d S d S r   )r   closeru   s    rW   r   zSocks5Connection.close0  s2     	%""$$$$$	% 	%rY   c                    | j         '| j        o| j        j        dk    p| j         o| j         S | j                                         S )Nr   )r   r   r   r   r   r   r   r   s    rW   r   zSocks5Connection.is_available4  sZ     	
  -(/8;N4;-,,
 ,,...rY   c                P    | j         | j        S | j                                         S r   )r   r   has_expiredr   s    rW   r   zSocks5Connection.has_expired@  s+     	(''++---rY   c                P    | j         | j        S | j                                         S r   )r   r   is_idler   s    rW   r   zSocks5Connection.is_idleE  s+     	('''')))rY   c                P    | j         | j        S | j                                         S r   )r   r   	is_closedr   s    rW   r   zSocks5Connection.is_closedJ  s+     	(''))+++rY   strc                X    | j         | j        rdndS | j                                         S )NzCONNECTION FAILED
CONNECTING)r   r   infor   s    rW   r   zSocks5Connection.infoO  s7     	Q*.*>P&&LP$$&&&rY   c                L    d| j         j         d|                                  dS )N<z [z]>)rx   r   r   r   s    rW   __repr__zSocks5Connection.__repr__T  s(    =4>*==diikk====rY   )NNNTFN)r{   r   r|   r   r_   r)   ra   rb   rf   rg   rh   ri   rj   ri   rl   rm   r*   r+   )r   r   r*   r   )ry   r   r*   ri   )r*   r+   )r*   ri   )r*   r   )r   r   r   rq   r   r   r   r   r   r   r   r   r   r   rY   rW   r}   r}      s        
 26-1)-15% % % % %4S8 S8 S8 S8j- - - -% % % %
/ 
/ 
/ 
/. . . .
* * * *
, , , ,
' ' ' '
> > > > > >rY   r}   )
r$   r   r%   r&   r'   r(   r#   r)   r*   r+   )'
__future__r   loggingsslr1   _backends.syncr   _backends.baser   r   _exceptionsr   r	   _modelsr
   r   r   r   r   r   _sslr   _synchronizationr   _tracer   connection_poolr   http11r   
interfacesr   	getLoggerr   r@   rM   rX   r[   r}   r   rY   rW   <module>r      s   " " " " " "  



  ( ( ( ( ( ( : : : : : : : : < < < < < < < < P P P P P P P P P P P P P P P P & & & & & & # # # # # #       + + + + + + $ $ $ $ $ $ + + + + + +		+	,	, * $	  +0"!$)
 
$ (,<K <K <K <K <K <K~Q
 Q
 Q
 Q
 Q
 Q
 Q
 Q
hX> X> X> X> X>* X> X> X> X> X>rY   