
    >Tf                     h   d dl Z d dlmZ d dlmZmZmZ d dlmZm	Z	 ddl
mZ  e j        d          Z G d d	e          Z G d
 dee	          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZdS )    N)urlparse)PoolManagerHTTPConnectionPoolHTTPSConnectionPool)HTTPConnectionHTTPSConnection   )HTTP_PROXY_SOCK_RDNS_SCHEMASznetbox.utilitiesc                   ,     e Zd ZdZdZ fdZd Z xZS )ProxyHTTPConnectionz
    A Proxy connection class that uses a SOCK proxy - used to create
    a urllib3 PoolManager that routes connections via the proxy.
    This is for an HTTP (not HTTPS) connection
    Fc                 ~    |                     d          }|d         | _         t                      j        |i | d S )N_socks_options	proxy_url)pop
_proxy_urlsuper__init__)selfargskwargssocks_options	__class__s       4/var/www/html/netbox-4.1.3/netbox/utilities/socks.pyr   zProxyHTTPConnection.__init__   sC    

#344'4$)&)))))    c                     	 ddl m} n.# t          $ r!}t                              d           |d }~ww xY w|                    | j        | j                  }|                    | j	        | j
        | j                  S )Nr   )ProxyzjConfiguring an HTTP proxy using SOCKS requires the python_socks library. Check that it has been installed.)rdns)	dest_host	dest_porttimeout)python_socks.syncr   ModuleNotFoundErrorloggerinfofrom_urlr   use_rdnsconnecthostportr    )r   r   eproxys       r   	_new_connzProxyHTTPConnection._new_conn   s    	///////" 	 	 	KK  E  F  F  FG	 tT]CC}}iiL  
 
 	
s   	 
4/4)__name__
__module____qualname____doc__r&   r   r,   __classcell__r   s   @r   r   r      sX         
 H* * * * *

 
 
 
 
 
 
r   r   c                       e Zd ZdZdS )ProxyHTTPSConnectionzF
    A Proxy connection class for an HTTPS (not HTTP) connection.
    N)r-   r.   r/   r0    r   r   r4   r4   (   s          	Dr   r4   c                       e Zd ZdZdZdS )RdnsProxyHTTPConnectionzq
    A Proxy connection class for an HTTP remote-dns connection.
    I.E. socks4a, socks4h, socks5a, socks5h
    TNr-   r.   r/   r0   r&   r5   r   r   r7   r7   /             HHHr   r7   c                       e Zd ZdZdZdS )RdnsProxyHTTPSConnectionzr
    A Proxy connection class for an HTTPS remote-dns connection.
    I.E. socks4a, socks4h, socks5a, socks5h
    TNr8   r5   r   r   r;   r;   7   r9   r   r;   c                       e Zd ZeZdS )ProxyHTTPConnectionPoolN)r-   r.   r/   r   ConnectionClsr5   r   r   r=   r=   ?   s        'MMMr   r=   c                       e Zd ZeZdS )ProxyHTTPSConnectionPoolN)r-   r.   r/   r4   r>   r5   r   r   r@   r@   C   s        (MMMr   r@   c                       e Zd ZeZdS )RdnsProxyHTTPConnectionPoolN)r-   r.   r/   r7   r>   r5   r   r   rB   rB   G   s        +MMMr   rB   c                       e Zd ZeZdS )RdnsProxyHTTPSConnectionPoolN)r-   r.   r/   r;   r>   r5   r   r   rD   rD   K   s        ,MMMr   rD   c                         e Zd Zd fd	Z xZS )ProxyPoolManager   
   Nc                    t          |          j        t          v x}rT|                    dd                              dd          }|                    dd                              dd          }d|i|d<   ||d	<    t	                      j        ||fi | |rt          t          d
| _        d S t          t          d
| _        d S )Nzsocks5h:zsocks5:zsocks5a:zsocks4h:zsocks4:zsocks4a:r   r   r    )httphttps)r   schemer
   replacer   r   rB   rD   pool_classes_by_schemer=   r@   )r   r   r    	num_poolsheadersconnection_pool_kwr&   r   s          r   r   zProxyPoolManager.__init__P   s      	**15QQQ8 	`!))*i@@HHU^__I!))*i@@HHU^__I0;Y/G+,(/9%GBB/ABBB 		35+ +D''' 01+ +D'''r   )rG   rH   N)r-   r.   r/   r   r1   r2   s   @r   rF   rF   O   s=                 r   rF   )loggingurllib.parser   urllib3r   r   r   urllib3.connectionr   r   	constantsr
   	getLoggerr#   r   r4   r7   r;   r=   r@   rB   rD   rF   r5   r   r   <module>rX      s
    ! ! ! ! ! ! H H H H H H H H H H > > > > > > > > 3 3 3 3 3 3 
	-	.	.
 
 
 
 
. 
 
 
8	 	 	 	 	. 	 	 	    1       3   ( ( ( ( (0 ( ( () ) ) ) )2 ) ) ), , , , ,"4 , , ,- - - - -#6 - - -    {     r   