ó
    Ö›‘hý  ã                   óÚ   • S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJrJr  SSKJr  \" \5       " S	 S
5      5       r\" \\5        \" \5       " S S\5      5       r\" \\5        g)z$
Utilities for Twisted.names tests.
é    )Ú	randrange)Úimplementer)ÚverifyClass)ÚIPv4Address)Úsucceed)ÚIReactorUDPÚIUDPTransport)ÚClockc                   óF   • \ rS rSrSrS rS rS rSS jrS r	S	 r
S
 rSrg)ÚMemoryDatagramTransporté   a€  
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                 óD   • Xl         X l        / U l        S U l        X0l        g ©N)Ú_hostÚ	_protocolÚ_sentPacketsÚ_connectedToÚ_maxPacketSize)ÚselfÚhostÚprotocolÚmaxPacketSizes       Ú`C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/names/test/test_util.pyÚ__init__Ú MemoryDatagramTransport.__init__&   s"   € ØŒ
Ø!ŒØˆÔØ ˆÔØ+Õó    c                 ó.   • [        S/U R                  Q76 $ )zG
Return the address which this transport is pretending to be bound
to.
ÚUDP)r   r   ©r   s    r   ÚgetHostÚMemoryDatagramTransport.getHost-   s   € ô
 ˜5Ð. 4§:¡:Ò.Ð.r   c                 óD   • U R                   b  [        S5      eX4U l         g)z.
Connect this transport to the given address.
NzAlready connected)r   Ú
ValueError)r   r   Úports      r   ÚconnectÚMemoryDatagramTransport.connect4   s&   € ð ×ÑÑ(ÜÐ0Ó1Ð1Ø!˜LˆÕr   Nc                 ó¾   • Uc  U R                   nUc  [        S5      e[        U5      U R                  :”  a  [        S5      eU R                  R                  X45        g)z
Send the given datagram.
NzNeed an addresszPacket too big)r   r#   Úlenr   r   Úappend)r   ÚdatagramÚaddrs      r   ÚwriteÚMemoryDatagramTransport.write<   sZ   € ð ‰<Ø×$Ñ$ˆDØ‰<ÜÐ.Ó/Ð/Üˆx‹=˜4×.Ñ.Ó.ÜÐ-Ó.Ð.Ø×Ñ× Ñ  (Ð!1Õ2r   c                 óL   • U R                   R                  5         [        S5      $ )z
Shut down this transport.
N)r   ÚstopProtocolr   r   s    r   ÚstopListeningÚ%MemoryDatagramTransport.stopListeningH   s   € ð 	�‰×#Ñ#Ô%Ü�t‹}Ðr   c                 ó   • g©z3
Dummy implementation to satisfy L{IUDPTransport}.
N© )r   Úenableds     r   ÚsetBroadcastAllowedÚ+MemoryDatagramTransport.setBroadcastAllowedO   ó   € ð 	r   c                 ó   • gr3   r4   r   s    r   ÚgetBroadcastAllowedÚ+MemoryDatagramTransport.getBroadcastAllowedU   r8   r   )r   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r    r%   r,   r0   r6   r:   Ú__static_attributes__r4   r   r   r   r      s*   † ñò ,ò/ò)ô
3òòõr   r   c                   ó(   • \ rS rSrSrS rSS jrSrg)ÚMemoryReactoré_   a3  
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                 ó>   • [         R                  " U 5        0 U l        g r   )r
   r   ÚudpPortsr   s    r   r   ÚMemoryReactor.__init__l   s   € Ü�Š�tÔØˆ�r   c                 óÜ   • US:X  a   [        SS5      nXR                  ;  a  OM  XR                  ;   a  [        S5      e[        X14X$5      nXPR                  U'   UR	                  U5        U$ )zB
Pretend to bind a UDP port and connect the given protocol to it.
r   é   i   zAddress in use)r   rF   r#   r   ÚmakeConnection)r   r$   r   Ú	interfacer   Ú	transports         r   Ú	listenUDPÚMemoryReactor.listenUDPp   ss   € ð �1‹9ØÜ   EÓ*�ØŸ}™}Ó,Øñ ð —=‘=Ó ÜÐ-Ó.Ð.Ü+¨YÐ,=¸xÓWˆ	Ø'�‰�dÑØ×Ñ 	Ô*ØÐr   )rF   N)Ú i    )r<   r=   r>   r?   r@   r   rM   rA   r4   r   r   rC   rC   _   s   † ñ	ò÷r   rC   N)r@   Úrandomr   Úzope.interfacer   Úzope.interface.verifyr   Útwisted.internet.addressr   Útwisted.internet.deferr   Útwisted.internet.interfacesr   r	   Útwisted.internet.taskr
   r   rC   r4   r   r   Ú<module>rW      s}   ðñõ
 å &Ý -å 0Ý *ß BÝ 'ñ ˆ]Ó÷Dð Dó ðDñN ˆMÐ2Ô 3ñ ˆ[Óô�Eó ó ðñB ˆK˜Õ 'r   