
    ^h              
           S r SSKrSSKrSSKrSSKr\R                  " S5      r " S S\R                  5      r	 " S S\R                  5      rS\S	\S
\S\R                  SS4
S jrS/rg)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                        \ rS rSrSrSrSrSrg)ForwardServer!   z#A server to use for ssh forwarding.T N)__name__
__module____qualname____firstlineno____doc__daemon_threadsallow_reuse_address__static_attributes__r       T/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_client/ssh/forward.pyr   r   !   s    -Nr   r   c                   <    \ rS rSrSr\R                  S 5       rSrg)Handler(   zA handle for server requests.c           	      N    U R                   R                  SU R                  U R                  4U R                  R                  5       5      nUc/  [        R                  SU R                  U R                  4-  5        g[        R                  SR                  U R                  R                  5       UR                  5       U R                  U R                  45      5         [        R                  " U R                  U// / 5      u  p4nU R                  U;   a<  U R                  R                  S5      n[        U5      S:X  a  OTUR                  U5        X;   a<  UR                  S5      n[        U5      S:X  a  OU R                  R                  U5        M  UR                  5         U R                  R                  5         [        R                  S5        g! [         aB  n[        R                  SU R                  U R                  [        U5      4-  5         SnAgSnAff = f)	zHandle a request.zdirect-tcpipz$Incoming request to %s:%d failed: %sNz9Incoming request to %s:%d was rejected by the SSH server.z,Connected!  Tunnel open {!r} -> {!r} -> {!r}i   r   zTunnel closed )ssh_transportopen_channel
chain_host
chain_portrequestgetpeername	Exceptionloggerdebugreprformatselectrecvlensendclose)selfchanerwxdatas          r   handleHandler.handle+   s   
	%%22$//2((*D <LLK??DOO45 :AA((*  "$//2	
 mmT\\4$8"bAGA!||q ||((.t9>		$yyyt9>!!$'  	

%&C  	LL6$//4??\`ab\c9dd 		s   AG 
H$"8HH$r   N)	r   r	   r
   r   r   tno_type_checkr-   r   r   r   r   r   r   (   s    '__)' )'r   r   
local_portremote_hostremote_port	transportreturnc                 j   ^^^  " UUU4S jS[         5      n[        SU 4U5      R                  5         g)zForward an ssh tunnel.c                   (   > \ rS rSr Y r Yr YrSrg)!forward_tunnel.<locals>.SubHander^   r   N)r   r	   r
   r   r   r   r   r   )r2   r3   r4   s   r   	SubHanderr8   ^   s     
 
!r   r:   z	127.0.0.1N)r   r   serve_forever)r1   r2   r3   r4   r:   s    ``` r   forward_tunnelr<   X   s.    " "G "
 ;
+Y7EEGr   r<   )r   loggingr!   socketservertypingr/   	getLoggerr   ThreadingTCPServerr   BaseRequestHandlerr   intstrAnyr<   __all__r   r   r   <module>rG      s   0    			5	!L33 -'l-- -'`Hs H H3 HSTSXSX H]a H 
r   