← Back
Editing: portforward.cpython-38.pyc
U W[O � @ sv d Z ddlmZ ddlmZ G dd� dej�ZG dd� de�ZG dd � d ej�Z G d d� de�Z G dd � d ej�ZdS )z A simple port forwarder. � )�protocol)�logc @ s, e Zd ZdZdZdd� Zdd� Zdd� ZdS ) �ProxyTNc C s || _ d S �N)�peer)�selfr � r �?/usr/lib/python3/dist-packages/twisted/protocols/portforward.py�setPeer s z Proxy.setPeerc C s8 | j d k r| j j�� d | _ n| jr4t�d|f � d S )NzUnable to connect to peer: %s)r � transport�loseConnection�noisyr �msg)r �reasonr r r �connectionLost s zProxy.connectionLostc C s | j j�|� d S r )r r �write)r �datar r r �dataReceived s zProxy.dataReceived)�__name__� __module__�__qualname__r r r r r r r r r r s r c @ s e Zd Zdd� ZdS )�ProxyClientc C s@ | j �| � | j�| j jd� | j j�| jd� | j j�� d S )NT)r r r ZregisterProducerZresumeProducing)r r r r �connectionMade$ s zProxyClient.connectionMadeN)r r r r r r r r r # s r c @ s( e Zd ZeZdd� Zdd� Zdd� ZdS )�ProxyClientFactoryc C s || _ d S r )�server)r r r r r � setServer7 s zProxyClientFactory.setServerc O s$ t jj| f|�|�}|�| j� |S r )r � ClientFactory� buildProtocolr r )r �args�kwZprotr r r r ; s z ProxyClientFactory.buildProtocolc C s | j j�� d S r )r r r )r Z connectorr r r r �clientConnectionFailedA s z)ProxyClientFactory.clientConnectionFailedN)r r r r r r r r r r r r r 3 s r c @ s e Zd ZeZdZdd� ZdS )�ProxyServerNc C sT | j �� | �� }|�| � | jd kr8ddlm} || _| j�| jj| jj |� d S )Nr )�reactor) r ZpauseProducing�clientProtocolFactoryr r"