
    VhA	                         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y)z
A simple port forwarder.
    )protocol)logc                   &    e Zd ZdZdZd Zd Zd Zy)ProxyTNc                     || _         y N)peer)selfr	   s     M/home/dcms/DCMS/lib/python3.12/site-packages/twisted/protocols/portforward.pysetPeerzProxy.setPeer   s	    	    c                     | j                   ,| j                   j                  j                          d | _         y | j                  rt	        j
                  d|        y y )NzUnable to connect to peer: )r	   	transportloseConnectionnoisyr   msg)r
   reasons     r   connectionLostzProxy.connectionLost   sI    99 II..0DIZZGG1&:; r   c                 N    | j                   j                  j                  |       y r   )r	   r   write)r
   datas     r   dataReceivedzProxy.dataReceived   s    		!!$'r   )__name__
__module____qualname__r   r	   r   r   r    r   r   r   r      s    ED<(r   r   c                       e Zd Zd Zy)ProxyClientc                 B   | j                   j                  |        | j                  j                  | j                   j                  d       | j                   j                  j                  | j                  d       | j                   j                  j	                          y )NT)r	   r   r   registerProducerresumeProducing)r
   s    r   connectionMadezProxyClient.connectionMade!   sj    		$ 	''		(;(;TB		,,T^^T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y)ProxyClientFactoryc                     || _         y r   )server)r
   r&   s     r   	setServerzProxyClientFactory.setServer2   s	    r   c                     t        j                  j                  | g|i |}|j                  | j                         |S r   )r   ClientFactorybuildProtocolr   r&   )r
   argskwprots       r   r*   z ProxyClientFactory.buildProtocol5   s7    %%33DF4F2FT[[!r   c                 L    | j                   j                  j                          y 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$   /   s    H
/r   r$   c                       e Zd ZeZdZd Zy)ProxyServerNc                 6   | j                   j                          | j                         }|j                  |        | j                  ddlm} || _        | j                  j                  | j                  j                  | j                  j                  |       y )Nr   )reactor)
r   pauseProducingclientProtocolFactoryr'   r4   twisted.internet
connectTCPfactoryhostport)r
   clientr4   s      r   r"   zProxyServer.connectionMadeB   sn     	%%'++-<<0"DL 1 14<<3D3DfMr   )r   r   r   r$   r6   r4   r"   r   r   r   r2   r2   >   s    .GNr   r2   c                       e Zd ZdZeZd Zy)ProxyFactoryz%
    Factory for port forwarder.
    c                      || _         || _        y 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   s     Hr   r>   N)rA   r7   r   twisted.pythonr   Protocolr   r   r)   r$   r2   Factoryr>   r   r   r   <module>rE      sb   
 & (H (&.% ./// /N% N&	8## 	r   