o
    >h"                     @   s   d dl Z e   d dlmZ d dlmZ d dlmZmZ d dl	m
Z
mZ d dlmZ G dd deZG d	d
 d
eZG dd deZG dd dejZG dd dejZdd ZdS )    N)usage)inlineCallbacks)FactoryProtocol)clientFromStringserverFromString)servicec                   @   s,   e Zd Ze Zdd Zdd Zdd ZdS )DestEndpointForwardingProtocolc                 C   s   | j d d S )N-DestEndpointForwardingProtocol.connectionMade)logdebugself r   z/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/autobahn/twisted/forwarder.pyconnectionMade)   s   r
   c                 C   0   | j jd|d | jjr| jjj| d S d S )Nz3DestEndpointForwardingProtocol.dataReceived: {data}data)r   r   factory_sourceProtocol	transportwriter   r   r   r   r   dataReceived-      z+DestEndpointForwardingProtocol.dataReceivedc                 C   *   | j d | jjr| jjj  d S d S )N-DestEndpointForwardingProtocol.connectionLost)r   r   r   r   r   loseConnectionr   reasonr   r   r   connectionLost5      r   N)	__name__
__module____qualname__txaiomake_loggerr   r   r   r!   r   r   r   r   r	   %   s
    r	   c                   @   s   e Zd Zdd Zdd ZdS )DestEndpointForwardingFactoryc                 C   s   || _ d | _d S N)r   _proto)r   sourceProtocolr   r   r   __init__=   s   
z&DestEndpointForwardingFactory.__init__c                 C   s   t  | _| | j_| jS r)   )r	   r*   r   )r   addrr   r   r   buildProtocolA   s   z+DestEndpointForwardingFactory.buildProtocolN)r#   r$   r%   r,   r.   r   r   r   r   r(   ;   s    r(   c                   @   s0   e Zd Ze Zedd Zdd Zdd Z	dS )EndpointForwardingProtocolc                 c   sF    | j d t| | _t| jjj| jjj| _	| j	
| jV | _d S )N)EndpointForwardingProtocol.connectionMade)r   r   r(   _destFactoryr   r   r   _reactor_destEndpointDescriptor_destEndpointconnect_destEndpointPortr   r   r   r   r   K   s   

r0   c                 C   r   )Nz/EndpointForwardingProtocol.dataReceived: {data}r   )r   r   r1   r*   r   r   r   r   r   r   r   S   r   z'EndpointForwardingProtocol.dataReceivedc                 C   r   )N)EndpointForwardingProtocol.connectionLost)r   r   r1   r*   r   r   r   r   r   r   r!   [   r"   r7   N)
r#   r$   r%   r&   r'   r   r   r   r   r!   r   r   r   r   r/   G   s    
r/   c                   @   s*   e Zd ZdddZedd Zdd ZdS )	EndpointForwardingServiceNc                 C   s*   |d u r
ddl m} || _|| _|| _d S )Nr   )reactor)twisted.internetr9   r2   _endpointDescriptorr3   )r   endpointDescriptordestEndpointDescriptorr9   r   r   r   r,   c   s
   
z"EndpointForwardingService.__init__c                 c   s6    t t}| |_t| j| j| _| j|V | _	d S r)   )
r   forProtocolr/   r   r   r2   r;   	_endpointlisten_endpointPort)r   r   r   r   r   startServicej   s
   
z&EndpointForwardingService.startServicec                 C   s
   | j  S r)   )rA   stopListeningr   r   r   r   stopServiceq   s   
z%EndpointForwardingService.stopServicer)   )r#   r$   r%   r,   r   rB   rD   r   r   r   r   r8   a   s
    

r8   c                   @   s$   e Zd ZdZdZg dg dgZdS )Optionsz	[options]zEndpoint Forwarder.)endpointeNzSource endpoint.)dest_endpointdNzDestination endpoint.N)r#   r$   r%   synopsislongdescoptParametersr   r   r   r   rE   u   s    rE   c                 C   s   t | d | d }|S )NrF   rH   )r8   )configr   r   r   r   makeService~   s   rN   )r&   use_twistedtwisted.pythonr   twisted.internet.deferr   twisted.internet.protocolr   r   twisted.internet.endpointsr   r   twisted.applicationr   r	   r(   r/   Servicer8   rE   rN   r   r   r   r   <module>   s   	