§
    Ètºfý  ã                   ó  — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZmZ ddlmZ  ee¦  «         G d	„ d
¦  «        ¦   «         Z eee¦  «          ee¦  «         G d„ de¦  «        ¦   «         Z eee¦  «         dS )z$
Utilities for Twisted.names tests.
é    )Ú	randrange)Úimplementer)ÚverifyClass)ÚIPv4Address)Úsucceed)ÚIReactorUDPÚIUDPTransport)ÚClockc                   ó>   — e Zd ZdZd„ Zd„ Zd„ Zd
d„Zd„ Zd„ Z	d	„ Z
dS )ÚMemoryDatagramTransporta¬  
    This L{IUDPTransport} implementation enforces the usual connection rules
    and captures sent traffic in a list for later inspection.

    @ivar _host: The host address to which this transport is bound.
    @ivar _protocol: The protocol connected to this transport.
    @ivar _sentPackets: A C{list} of two-tuples of the datagrams passed to
        C{write} and the addresses to which they are destined.

    @ivar _connectedTo: L{None} if this transport is unconnected, otherwise an
        address to which all traffic is supposedly sent.

    @ivar _maxPacketSize: An C{int} giving the maximum length of a datagram
        which will be successfully handled by C{write}.
    c                 óL   — || _         || _        g | _        d | _        || _        d S ©N)Ú_hostÚ	_protocolÚ_sentPacketsÚ_connectedToÚ_maxPacketSize)ÚselfÚhostÚprotocolÚmaxPacketSizes       ú[/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/names/test/test_util.pyÚ__init__z MemoryDatagramTransport.__init__&   s.   € ØˆŒ
Ø!ˆŒØˆÔØ ˆÔØ+ˆÔÐÐó    c                 ó&   — t          dg| j        ¢R Ž S )z_
        Return the address which this transport is pretending to be bound
        to.
        ÚUDP)r   r   ©r   s    r   ÚgetHostzMemoryDatagramTransport.getHost-   s   € õ
 ˜5Ð. 4¤:Ð.Ð.Ð.Ð.r   c                 óD   — | j         �t          d¦  «        ‚||f| _         dS )z>
        Connect this transport to the given address.
        NzAlready connected)r   Ú
ValueError)r   r   Úports      r   ÚconnectzMemoryDatagramTransport.connect4   s.   € ð ÔÐ(ÝÐ0Ñ1Ô1Ð1Ø! 4˜LˆÔÐÐr   Nc                 óÀ   — |€| j         }|€t          d¦  «        ‚t          |¦  «        | j        k    rt          d¦  «        ‚| j                             ||f¦  «         dS )z*
        Send the given datagram.
        NzNeed an addresszPacket too big)r   r    Úlenr   r   Úappend)r   ÚdatagramÚaddrs      r   ÚwritezMemoryDatagramTransport.write<   sj   € ð ˆ<ØÔ$ˆDØˆ<ÝÐ.Ñ/Ô/Ð/Ýˆx‰=Œ=˜4Ô.Ò.Ð.ÝÐ-Ñ.Ô.Ð.ØÔ× Ò  (¨DÐ!1Ñ2Ô2Ð2Ð2Ð2r   c                 óR   — | j                              ¦   «          t          d¦  «        S )z+
        Shut down this transport.
        N)r   ÚstopProtocolr   r   s    r   ÚstopListeningz%MemoryDatagramTransport.stopListeningH   s$   € ð 	Œ×#Ò#Ñ%Ô%Ð%Ý�t‰}Œ}Ðr   c                 ó   — dS ©zC
        Dummy implementation to satisfy L{IUDPTransport}.
        N© )r   Úenableds     r   ÚsetBroadcastAllowedz+MemoryDatagramTransport.setBroadcastAllowedO   ó	   € ð 	ˆr   c                 ó   — dS r-   r.   r   s    r   ÚgetBroadcastAllowedz+MemoryDatagramTransport.getBroadcastAllowedU   r1   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r"   r(   r+   r0   r3   r.   r   r   r   r      sŒ   € € € € € ðð ð ,ð ,ð ,ð/ð /ð /ð)ð )ð )ð
3ð 
3ð 
3ð 
3ðð ð ðð ð ðð ð ð ð r   r   c                   ó    — e Zd ZdZd„ Zdd„ZdS )ÚMemoryReactoraO  
    An L{IReactorTime} and L{IReactorUDP} provider.

    Time is controlled deterministically via the base class, L{Clock}.  UDP is
    handled in-memory by connecting protocols to instances of
    L{MemoryDatagramTransport}.

    @ivar udpPorts: A C{dict} mapping port numbers to instances of
        L{MemoryDatagramTransport}.
    c                 ó<   — t          j        | ¦  «         i | _        d S r   )r
   r   ÚudpPortsr   s    r   r   zMemoryReactor.__init__l   s   € ÝŒ�tÑÔÐØˆŒˆˆr   Ú é    c                 óÞ   — |dk    r	 t          dd¦  «        }|| j        vrnŒ|| j        v rt          d¦  «        ‚t          ||f||¦  «        }|| j        |<   |                     |¦  «         |S )zR
        Pretend to bind a UDP port and connect the given protocol to it.
        r   Té   i   zAddress in use)r   r;   r    r   ÚmakeConnection)r   r!   r   Ú	interfacer   Ú	transports         r   Ú	listenUDPzMemoryReactor.listenUDPp   s�   € ð �1Š9ˆ9ðÝ   EÑ*Ô*�Ø˜tœ}Ð,Ð,Øðð �4”=Ð Ð ÝÐ-Ñ.Ô.Ð.Ý+¨Y¸Ð,=¸xÈÑWÔWˆ	Ø'ˆŒ�dÑØ×Ò 	Ñ*Ô*Ð*ØÐr   N)r<   r=   )r4   r5   r6   r7   r   rC   r.   r   r   r9   r9   _   sA   € € € € € ð	ð 	ðð ð ðð ð ð ð ð r   r9   N)r7   Úrandomr   Úzope.interfacer   Úzope.interface.verifyr   Útwisted.internet.addressr   Útwisted.internet.deferr   Útwisted.internet.interfacesr   r	   Útwisted.internet.taskr
   r   r9   r.   r   r   ú<module>rK      sN  ððð ð
 Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &Ø -Ð -Ð -Ð -Ð -Ð -à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø *Ð *Ð *Ð *Ð *Ð *Ø BÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ 'Ð 'Ð 'Ð 'Ð 'Ð 'ð €ˆ]ÑÔðDð Dð Dð Dð Dñ Dô Dñ ÔðDðN €ˆMÐ2Ñ 3Ô 3Ð 3ð €ˆ[ÑÔðð ð ð ð �Eñ ô ñ ÔððB €ˆK˜Ñ 'Ô 'Ð 'Ð 'Ð 'r   