%PDF- %PDF-
Direktori : /lib/python3/dist-packages/paramiko/__pycache__/ |
Current File : //lib/python3/dist-packages/paramiko/__pycache__/proxy.cpython-312.pyc |
� �ec( � � � d dl Z d dlZd dlZd dlmZ d dlZd dlZd\ ZZ d dlZd dl mZ d dlm Z G d� de � Zy# e$ rZ e ZY dZ [ �$dZ [ ww xY w)� N)�select)NN)�ProxyCommandFailure)�ClosingContextManagerc �N � e Zd ZdZd� Zd� Zd� Zd� Zed� � Z ed� � Z d� Zy ) �ProxyCommanda� 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 � � t �t �t j |� | _ t j | j t j t j t j d�� | _ d| _ y)a 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 �0/usr/lib/python3/dist-packages/paramiko/proxy.py�__init__zProxyCommand.__init__3 sZ � � ��)�)��;�;�|�,���!�'�'��H�H��/�/��?�?��?�?�� ��� ��� c �� � | j j j |� t |� S # t $ r4}t dj | j � |j � �d}~ww xY w)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 �sendzProxyCommand.sendG s` � � F��L�L���$�$�W�-� �7�|��� � F� &�c�h�h�t�x�x�&8�!�*�*�E�E�� F�s �%2 � A/�/A*�*A/c �� � d}t j � }t |� |k r�d}| j �It j � |z }|| j k\ rt j � �| j |z }t | j j gg g |� \ }}}|rc|d | j j k( rG|t j | j j j � |t |� z � z }t |� |k r��|S # t j $ r r|cY S � t $ r4} t dj | j � | j � �d} ~ ww xY w)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 �recvzProxyCommand.recvX s7 � � F��F��I�I�K�E��f�+��$�!%���<�<�+�"�i�i�k�E�1�G��$�,�,�.�$�n�n�.�.�%)�\�\�G�%;�N� �$�,�,�"5�"5�!6��B��O���1�a���1�����!4�!4�4��b�g�g����+�+�2�2�4�d�S��[�6H�� �F� �f�+��$� �M���~�~� ��� ��� F�%�c�h�h�t�x�x�&8�!�*�*�E�E�� F�s$ �DD �D �E0�3 E0�</E+�+E0c �t � t j | j j t j � y �N)r( �killr �pid�signal�SIGTERM�r s r �closezProxyCommand.closey s � � ������ � �&�.�.�1r c �2 � | j j d uS r5 )r � returncoder: s r �closedzProxyCommand.closed| s � ��|�|�&�&�d�2�2r c � � | j S r5 )r>