
    f                         d Z ddlZddlZddlZ ej                  d      Z G d dej                        Z G d dej                        Z	d Z
d	gZy)
a  
Sample script showing how to do local port forwarding over paramiko.

This script connects to the requested SSH server and sets up local port
forwarding (the openssh -L option) from a local port through a tunneled
connection to a destination reachable from the SSH server machine.
    Nsshc                       e Zd ZdZdZy)ForwardServerTN)__name__
__module____qualname__daemon_threadsallow_reuse_address     J/var/www/cvtools/html/venv/lib/python3.12/site-packages/zmq/ssh/forward.pyr   r   #   s    Nr   r   c                       e Zd Zd Zy)Handlerc           	      .   	 | j                   j                  d| j                  | j                  f| j                  j                               }|/t        j                  d| j                  | j                  fz         y t        j                  d| j                  j                         d|j                         d| j                  | j                  f       	 t        j                  | j                  |gg g       \  }}}| j                  |v r;| j                  j                  d      }t        |      dk(  rnQ|j                  |       ||v r;|j                  d      }t        |      dk(  rn| j                  j                  |       |j                          | j                  j                          t        j                  d       y # t        $ rB}t        j                  d| j                  | j                  t        |      fz         Y d }~y d }~ww xY w)	Nzdirect-tcpipz$Incoming request to %s:%d failed: %sz9Incoming request to %s:%d was rejected by the SSH server.zConnected!  Tunnel open z -> i   r   zTunnel closed )ssh_transportopen_channel
chain_host
chain_portrequestgetpeername	Exceptionloggerdebugreprselectrecvlensendclose)selfchanerwxdatas          r   handlezHandler.handle)   s   	%%22$//2((*D <LLK??DOO45 &t||'?'?'A&DDIYIYI[H^^bdhdsdsuy  vE  vE  dF  cI  J	
 mmT\\4$8"bAGAq!||q ||((.t9>		$qyyyt9>!!$'  	

%&=  	LL6??DOOT!W=> 	s   AG	 		H8HHN)r   r   r   r'   r   r   r   r   r   (   s    %'r   r   c                 h     G fddt               }t        d| f|      j                          y )Nc                        e Zd ZW  ZW ZW Zy)!forward_tunnel.<locals>.SubHanderN)r   r   r   r   r   r   )remote_hostremote_port	transports   r   	SubHanderr*   U   s     
 
!r   r.   z	127.0.0.1)r   r   serve_forever)
local_portr+   r,   r-   r.   s    ``` r   forward_tunnelr1   Q   s.    " "G "
 ;
+Y7EEGr   r1   )__doc__loggingr   socketserver	getLoggerr   ThreadingTCPServerr   BaseRequestHandlerr   r1   __all__r   r   r   <module>r9      s\   (   			5	!L33 
&'l-- &'R	H 
r   