File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/paramiko/__pycache__/proxy.cpython-310.pyc
Back
o �h( � @ s� d dl Z d dlZd dlZd dlmZ d dlZd dlZd\ZZzd dlZW n ey8 Z ze ZW Y dZ [ ndZ [ ww d dl mZ d dlm Z G dd� de �ZdS )� N)�select)NN)�ProxyCommandFailure)�ClosingContextManagerc @ sP e Zd ZdZdd� Zdd� Zdd� Zdd � Zed d� �Z edd � �Z dd� ZdS )�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 C s@ t du rt�t�|�| _t j| jt jt jt jdd�| _d| _dS )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_line� r �A/usr/local/CyberCP/lib/python3.10/site-packages/paramiko/proxy.py�__init__3 s � zProxyCommand.__init__c C sF z| j j�|� W t|�S ty" } z td�| j�|j��d}~ww )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�er r r �sendG s ���zProxyCommand.sendc C s� zWd}t � � }t|�|k rUd}| jdur(t � � | }|| jkr#t�� �| j| }t| jjgg g |�\}}}|rO|d | jjkrO|t�| jj� � |t|� �7 }t|�|k s |W S tjyf |re| Y S � t y{ } z td�| j �| j��d} ~ ww )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 � Nr r )�timer r �socketr r r �os�read�filenor r r r r ) r �size�buffer�start�select_timeout�elapsed�r�w�xr r r r �recvX s2 �� ��zProxyCommand.recvc C s t �| jjtj� d S �N)r$ �killr �pid�signal�SIGTERM�r r r r �closey s zProxyCommand.closec C s | j jd uS r0 )r � returncoder5 r r r �closed| s zProxyCommand.closedc C s | j S r0 )r8 r5 r r r �_closed� s zProxyCommand._closedc C s || _ d S r0 )r )r r r r r � settimeout� s zProxyCommand.settimeoutN)�__name__� __module__�__qualname__�__doc__r r r/ r6 �propertyr8 r9 r: r r r r r '