File: //usr/lib/python3/dist-packages/twisted/conch/ssh/__pycache__/forwarding.cpython-310.pyc
o
�b! � @ s� d Z ddlZddlmZmZ ddlmZmZ ddlm Z m
Z
G dd� dej�ZG dd � d ej
�ZG d
d� de�ZG dd
� d
e�ZG dd� dej
�Zdd� ZG dd� dej�Zdd� ZeZdd� ZeZdd� Zdd� ZdS )z�
This module contains the implementation of the TCP forwarding, which allows
clients and servers to forward arbitrary TCP data across the connection.
Maintainer: Paul Swartz
� N)�channel�common)�protocol�reactor)�HostnameEndpoint�connectProtocolc @ s e Zd Zdd� Zdd� ZdS )�SSHListenForwardingFactoryc C s || _ || _|| _d S �N)�conn�hostport�klass)�self�
connectionr r � r �>/usr/lib/python3/dist-packages/twisted/conch/ssh/forwarding.py�__init__ s
z#SSHListenForwardingFactory.__init__c C sF | j | jd�}t|�}||_|j|jf}t| j|�}| j�||� |S )N)r
) r r
�SSHForwardingClient�client�host�port�packOpen_direct_tcpipr �openChannel)r
�addrr r � addrTuple�channelOpenDatar r r �
buildProtocol s z(SSHListenForwardingFactory.buildProtocolN)�__name__�
__module__�__qualname__r r r r r r r s r c @ s4 e Zd Zdd� Zdd� Zdd� Zdd� Zd d
� ZdS )�SSHListenForwardingChannelc C sH | j jd| jd� t| jj�dkr| jjdd � }| �|� d| j_d S )Nzopened forwarding channel {id}��id� � )�_log�infor! �lenr �buf�write)r
�specificData�br r r �channelOpen$ s
z&SSHListenForwardingChannel.channelOpenc C s | � � d S r )�closed�r
�reasonr r r �
openFailed+ s z%SSHListenForwardingChannel.openFailedc C s | j j�|� d S r )r � transportr( �r
�datar r r �dataReceived. s z'SSHListenForwardingChannel.dataReceivedc C s | j j�� d S r )r r0 �loseConnection�r
r r r �eofReceived1 s z&SSHListenForwardingChannel.eofReceivedc C s4 t | d�r| jjd| jd� | jj�� | `d S d S )Nr z%closing local forwarding channel {id}r )�hasattrr$ r% r! r r0 r4 r5 r r r r, 4 s
�z!SSHListenForwardingChannel.closedN)r r r r+ r/ r3 r6 r, r r r r r # s r c @ � e Zd ZdZdS )� SSHListenClientForwardingChannels direct-tcpipN�r r r �namer r r r r9 ; � r9 c @ r8 )� SSHListenServerForwardingChannels forwarded-tcpipNr: r r r r r= @ r<