
    Ii(                         S SK r S SKrS SKrS SKJr  S SKrS SKrSu  rr S SKrS SK
Jr  S SKJr   " S S\5      rg! \ a  r	\	r Sr	C	N%Sr	C	ff = f)    N)select)NN)ProxyCommandFailure)ClosingContextManagerc                   V    \ rS rSrSrS rS rS rS r\	S 5       r
\	S 5       rS	 rS
rg)ProxyCommand'   a  
Wraps a subprocess running ProxyCommand-driven programs.

This class implements a the socket-like interface needed by the
`.Transport` and `.Packetizer` classes. Using this class instead of a
regular socket makes it possible to talk with a Popen'd command that will
proxy traffic between the client and a server hosted in another machine.

Instances of this class may be used as context managers.
c                    [         c  [        e[        R                  " U5      U l        [         R
                  " U R                  [         R                  [         R                  [         R                  SS9U l        SU l        g)z
Create a new CommandProxy instance. The instance created by this
class can be passed as an argument to the `.Transport` class.

:param str command_line:
    the command that should be executed and used as the proxy.
Nr   )stdinstdoutstderrbufsize)	
subprocesssubprocess_import_errorshlexsplitcmdPopenPIPEprocesstimeout)selfcommand_lines     4/venv/lib/python3.13/site-packages/paramiko/proxy.py__init__ProxyCommand.__init__3   sZ     ));;|,!''HH//????
     c                      U R                   R                  R                  U5        [        U5      $ ! [         a4  n[	        SR                  U R                  5      UR                  5      eSnAff = f)z
Write the content received from the SSH client to the standard
input of the forked command.

:param str content: string to be sent to the forked command
 N)	r   r
   writeIOErrorr   joinr   strerrorlen)r   contentes      r   sendProxyCommand.sendG   s`    	FLL$$W- 7|  	F
 &chhtxx&8!**EE	Fs   %2 
A0/A++A0c                     Sn[         R                   " 5       n[        U5      U:  a  SnU R                  bK  [         R                   " 5       U-
  nXPR                  :  a  [        R                  " 5       eU R                  U-
  n[	        U R
                  R                  // / U5      u  pgnU(       ae  US   U R
                  R                  :X  aH  U[        R                  " U R
                  R                  R                  5       U[        U5      -
  5      -  n[        U5      U:  a  M  U$ ! [        R                   a    W(       a  Us $ e [         a4  n	[        SR                  U R                  5      U	R                  5      eSn	A	ff = f)z
Read from the standard output of the forked program.

:param int size: how many chars should be read

:return: the string of bytes read, which may be shorter than requested
r   Nr   r   )timer#   r   socketr   r   r   osreadfilenor    r   r!   r   r"   )
r   sizebufferstartselect_timeoutelapsedrwxr%   s
             r   recvProxyCommand.recvX   s3   	FFIIKEf+$!%<<+"iikE1G,,.$nn..%)\\G%;N $,,"5"5!6BOa1!4!44bgg++224dS[6H F f+$ M~~ 	 	F%chhtxx&8!**EE	Fs$   D!D' %D' 'F
F/E??Fc                 v    [         R                  " U R                  R                  [        R
                  5        g N)r+   killr   pidsignalSIGTERMr   s    r   closeProxyCommand.closey   s    
  &..1r   c                 2    U R                   R                  S L$ r9   )r   
returncoder>   s    r   closedProxyCommand.closed|   s    ||&&d22r   c                     U R                   $ r9   )rC   r>   s    r   _closedProxyCommand._closed   s     {{r   c                     Xl         g r9   )r   )r   r   s     r   
settimeoutProxyCommand.settimeout   s    r   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r&   r6   r?   propertyrC   rF   rI   __static_attributes__ r   r   r   r   '   sJ    	("FB2 3 3  r   r   )r+   r   r<   r   r*   r)   r   r   ImportErrorr%   paramiko.ssh_exceptionr   paramiko.utilr   r   rR   r   r   <module>rV      s]   ( 
      '1 #
#  7 /_( _    s   = AA

A