Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/protocols/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/protocols/__pycache__/loopback.cpython-310.pyc
o

�b�.�@s$dZddlZddlmZddlmZmZmZmZddl	m
Z
ddlmZddl
mZddlmZGd	d
�d
�Zee
�Gdd�d��Zeejej�Gd
d�d��Zdd�Zdd�Zefdd�Zdd�Zdd�Zeejej�Gdd�d��ZGdd�dej�ZGdd�dej�Zd$d d!�Z d%d"d#�Z!dS)&zF
Testing support for protocols -- loopback between client and server.
�N)�implementer)�defer�
interfaces�main�protocol)�IAddress)�
deferLater)�policies)�failurec@s<eZdZdZdZdZdd�Zdd�Zdd	�ZeZ	d
d�Z
dS)�_LoopbackQueuez�
    Trivial wrapper around a list to give it an interface like a queue, which
    the addition of also sending notifications by way of a Deferred whenever
    the list has something added to it.
    NFcCs
g|_dS�N)�_queue��self�r�</usr/lib/python3/dist-packages/twisted/protocols/loopback.py�__init__"�
z_LoopbackQueue.__init__cCs6|j�|�|jdur|jd}|_|�d�dSdSr)r
�append�_notificationDeferred�callback)r�v�drrr�put%s

�z_LoopbackQueue.putcCs
t|j�Sr)�boolr
rrrr�__nonzero__+rz_LoopbackQueue.__nonzero__cCs|j�d�S�Nr)r
�poprrrr�get0sz_LoopbackQueue.get)�__name__�
__module__�__qualname__�__doc__r�
disconnectrrr�__bool__rrrrrrsrc@seZdZdS)�_LoopbackAddressN)rr r!rrrrr%4sr%c@sdeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�_LoopbackTransportFNcC�
||_dSr)�q)rr(rrrr?rz_LoopbackTransport.__init__cCs"t|t�s	td��|j�|�dS)Nz"Can only write bytes to ITransport)�
isinstance�bytes�	TypeErrorr(r�r�datarrr�writeBs
z_LoopbackTransport.writecCs|j�d�|��dS�N�)r(r�join�r�iovecrrr�
writeSequenceGsz _LoopbackTransport.writeSequencecCsd|j_|j�d�dS)NT)r(r#rrrrr�loseConnectionJsz!_LoopbackTransport.loseConnectioncCs|��dS)zB
        Abort the connection. Same as L{loseConnection}.
        N)r5rrrr�abortConnectionNsz"_LoopbackTransport.abortConnectioncC�t�Sr�r%rrrr�getPeerT�z_LoopbackTransport.getPeercCr7rr8rrrr�getHostWr:z_LoopbackTransport.getHostcCs&|jdusJ�||_||_|��dSr)�producer�streamingProducer�
_pollProducer�rr<�	streamingrrr�registerProducer[sz#_LoopbackTransport.registerProducercCs|jdusJ�d|_dSr�r<rrrr�unregisterProduceras
z%_LoopbackTransport.unregisterProducercCs&|jdur|js|j��dSdSdSr)r<r=�resumeProducingrrrrr>es�z _LoopbackTransport._pollProducer)rr r!�
disconnectingr<rr.r4r5r6r9r;rArCr>rrrrr&9sr&cCs.|r|��}|durdS|�|�|sdSdS)z�
    L{identityPumpPolicy} is a policy which delivers each chunk of data written
    to the given queue as-is to the target.

    This isn't a particularly realistic policy.

    @see: L{loopbackAsync}
    N)r�dataReceived)�queue�targetr*rrr�identityPumpPolicyjs	
�rIcCsDg}|r|��}|dur
n|�|�|s|r |�d�|��dSdS)z�
    L{collapsingPumpPolicy} is a policy which collapses all outstanding chunks
    into a single string and delivers it to the target.

    @see: L{loopbackAsync}
    Nr0)rrrFr1)rGrHr*�chunkrrr�collapsingPumpPolicyzs
��rKcCs8t�}t�}|�t|��|�t|��t|||||�S)a
    Establish a connection between C{server} and C{client} then transfer data
    between them until the connection is closed. This is often useful for
    testing a protocol.

    @param server: The protocol instance representing the server-side of this
        connection.

    @param client: The protocol instance representing the client-side of this
        connection.

    @param pumpPolicy: When either C{server} or C{client} writes to its
        transport, the string passed in is added to a queue of data for the
        other protocol.  Eventually, C{pumpPolicy} will be called with one such
        queue and the corresponding protocol object.  The pump policy callable
        is responsible for emptying the queue and passing the strings it
        contains to the given protocol's C{dataReceived} method.  The signature
        of C{pumpPolicy} is C{(queue, protocol)}.  C{queue} is an object with a
        C{get} method which will return the next string written to the
        transport, or L{None} if the transport has been disconnected, and which
        evaluates to C{True} if and only if there are more items to be
        retrieved via C{get}.

    @return: A L{Deferred} which fires when the connection has been closed and
        both sides have received notification of this.
    )r�makeConnectionr&�_loopbackAsyncBody)�server�client�
pumpPolicy�serverToClient�clientToServerrrr�
loopbackAsync�s
�rSc
s��fdd�}	d}}}||||�}||||�}|s3|s3t��}	|	|_|	|_|	�t||||��|	S|jr?d}||||�n|jrJd}||||�|rc|�t�t	j
��|�t�t	j
��t�d�Sq)ak
    Transfer bytes from the output queue of each protocol to the input of the other.

    @param server: The protocol instance representing the server-side of this
    connection.

    @param serverToClient: The L{_LoopbackQueue} holding the server's output.

    @param client: The protocol instance representing the client-side of this
    connection.

    @param clientToServer: The L{_LoopbackQueue} holding the client's output.

    @param pumpPolicy: See L{loopbackAsync}.

    @return: A L{Deferred} which fires when the connection has been closed and
        both sides have received notification of this.
    cs,d}|r�||�d}|r|s|j��|S)NFT)�	transportr>)�sourcer(rH�sent�rPrr�pump�s

z _loopbackAsyncBody.<locals>.pump�FTN)r�Deferredr�addCallback�_loopbackAsyncContinuer#�connectionLostr
�Failurer�CONNECTION_DONE�succeed)
rNrQrOrRrPrXr#�
clientSent�
serverSentrrrWrrM�s:�
�rMc	Cs.d|_d|_ddlm}t|dt|||||�S)Nr��reactor)r�twisted.internetrdrrM)�ignoredrNrQrOrRrPrdrrrr\�s�r\c@sneZdZdZdZdZdZddd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�
LoopbackRelayr0rNcCs||_||_dSr)rH�logFile)rrHrhrrrrs
zLoopbackRelay.__init__cCs.|j||_|jr|j�dt|��dSdS)Nzloopback writing %s
)�bufferrhr.�reprr,rrrr.s�zLoopbackRelay.writecCs|�d�|��dSr/)r.r1r2rrrr4"szLoopbackRelay.writeSequencecCs�|jdkrdS|jr|j��|jr,|jr |j�dt|j��|j}d|_|j�|�|jdkr@d|_|j�	t
�tj
��dSdS)N���zloopback receiving %s
r0rY)�
shouldLoser<rDrirhr.rjrHrFr]r
r^rr_)rrirrr�clearBuffer%s


�zLoopbackRelay.clearBuffercCs|jdkr
d|_dSdS)NrkrY)rlrrrrr55s

�zLoopbackRelay.loseConnectioncC�dS�N�loopbackrrrrrr;9�zLoopbackRelay.getHostcCrnrorrrrrr9<rqzLoopbackRelay.getPeercCr'rrBr?rrrrA?rzLoopbackRelay.registerProducercCs
d|_dSrrBrrrrrCBrz LoopbackRelay.unregisterProducercCsd|jjj�d�S)Nz	Loopback(�))rH�	__class__rrrrr�	logPrefixEszLoopbackRelay.logPrefixr)rr r!rirlrEr<rr.r4rmr5r;r9rArCrtrrrrrgs
rgc@s$eZdZdd�Zdd�Zdd�ZdS)�LoopbackClientFactorycCsd|_t��|_||_dSr)�disconnectedrrZ�deferredr)rrrrrrJs

zLoopbackClientFactory.__init__cCs|jSr)r)r�addrrrr�
buildProtocolOr:z#LoopbackClientFactory.buildProtocolcCsd|_|j�d�dS)NrY)rvrwr)r�	connector�reasonrrr�clientConnectionLostRsz*LoopbackClientFactory.clientConnectionLostN)rr r!rryr|rrrrruIsruc@seZdZdd�Zdd�ZdS)�_FireOnClosecCstj�|||�t��|_dSr)r	�ProtocolWrapperrrrZrw)rr�factoryrrrrXsz_FireOnClose.__init__cCstj�||�|j�d�dSr)r	r~r]rwr)rr{rrrr]\sz_FireOnClose.connectionLostN)rr r!rr]rrrrr}Wsr}Tcs�ddlm}t�t���}t||��||_�fdd�|_|j	||dd��t
|�}||_|�d���j
|�|j}|��fdd��|��fdd��|S)	zBRun session between server and client protocol instances over TCP.rrcc��Srr�rx��
serverWrapperrr�<lambda>h�zloopbackTCP.<locals>.<lambda>z	127.0.0.1)�	interfacec��jSr�rw��xr�rrr�n�c����Sr��
stopListeningr���
serverPortrrr�o�)rerdr	�WrappingFactoryr�Factoryr}�noisyry�	listenTCPru�
connectTCPr;�portrwr[)rNrOr�r�rd�f�clientFrr�r�r�r�loopbackTCPas
r�cs�t��}ddlm}t�t���}t||��||_	�fdd�|_
|�||��t|�}||_	|�
||�|j}|��fdd��|��fdd��|S)zJRun session between server and client protocol instances over UNIX socket.rrccr�rrr�r�rrr�{r�zloopbackUNIX.<locals>.<lambda>cr�rr�r�r�rrr��r�cr�rr�r�r�rrr��r�)�tempfile�mktemprerdr	r�rr�r}r�ry�
listenUNIXru�connectUNIXrwr[)rNrOr��pathrdr�r�rrr�r�loopbackUNIXss
r�)rT)T)"r"r��zope.interfacerrerrrr�twisted.internet.interfacesr�twisted.internet.taskr�twisted.protocolsr	�twisted.pythonr
rr%�
ITransport�	IConsumerr&rIrKrSrMr\rg�
ClientFactoryrur~r}r�r�rrrr�<module>s00&G6



Spamworldpro Mini