
    tfA	                         d Z ddlmZ ddlmZ  G d dej                  Z G d de          Z G d d	ej                  Z	 G d
 de          Z
 G d dej                  ZdS )z
A simple port forwarder.
    )protocol)logc                   (    e Zd ZdZdZd Zd Zd ZdS )ProxyTNc                     || _         d S N)peer)selfr	   s     \/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/protocols/portforward.pysetPeerzProxy.setPeer   s    			    c                     | j         '| j         j                                         d | _         d S | j        rt	          j        d|            d S d S )NzUnable to connect to peer: )r	   	transportloseConnectionnoisyr   msg)r
   reasons     r   connectionLostzProxy.connectionLost   s_    9 I..000DIIIZ 	<G:&::;;;;;	< 	<r   c                 D    | j         j                            |           d S r   )r	   r   write)r
   datas     r   dataReceivedzProxy.dataReceived   s!    	!!$'''''r   )__name__
__module____qualname__r   r	   r   r   r    r   r   r   r      sK        ED  < < <( ( ( ( (r   r   c                       e Zd Zd ZdS )ProxyClientc                 
   | j                             |            | j                            | j         j        d           | j         j                            | j        d           | j         j                                         d S )NT)r	   r   r   registerProducerresumeProducing)r
   s    r   connectionMadezProxyClient.connectionMade!   ss    	$ 	''	(;TBBB	,,T^TBBB 		++-----r   N)r   r   r   r"   r   r   r   r   r       s#        . . . . .r   r   c                   $    e Zd ZeZd Zd Zd ZdS )ProxyClientFactoryc                     || _         d S r   )server)r
   r&   s     r   	setServerzProxyClientFactory.setServer2   s    r   c                 n    t          j        j        | g|R i |}|                    | j                   |S r   )r   ClientFactorybuildProtocolr   r&   )r
   argskwprots       r   r*   z ProxyClientFactory.buildProtocol5   s>    %3DF4FFF2FFT[!!!r   c                 B    | j         j                                         d S r   )r&   r   r   )r
   	connectorr   s      r   clientConnectionFailedz)ProxyClientFactory.clientConnectionFailed:   s    ,,.....r   N)r   r   r   r   r   r'   r*   r0   r   r   r   r$   r$   /   sF        H    
/ / / / /r   r$   c                       e Zd ZeZdZd ZdS )ProxyServerNc                    | j                                          |                                 }|                    |            | j        ddlm} || _        | j                            | j        j        | j        j	        |           d S )Nr   )reactor)
r   pauseProducingclientProtocolFactoryr'   r4   twisted.internet
connectTCPfactoryhostport)r
   clientr4   s      r   r"   zProxyServer.connectionMadeB   s     	%%'''++--<000000"DL 14<3DfMMMMMr   )r   r   r   r$   r6   r4   r"   r   r   r   r2   r2   >   s3        .GN N N N Nr   r2   c                       e Zd ZdZeZd ZdS )ProxyFactoryz%
    Factory for port forwarder.
    c                 "    || _         || _        d S r   )r:   r;   )r
   r:   r;   s      r   __init__zProxyFactory.__init__X   s    				r   N)r   r   r   __doc__r2   r   r@   r   r   r   r>   r>   Q   s4          H    r   r>   N)rA   r7   r   twisted.pythonr   Protocolr   r   r)   r$   r2   Factoryr>   r   r   r   <module>rE      s"   
 & % % % % %      ( ( ( ( (H ( ( (&. . . . .% . . ./ / / / // / / /N N N N N% N N N&	 	 	 	 	8# 	 	 	 	 	r   