§
    ÌtºfQ'  ã                   óÒ  — 	 d dl mZ n# e$ r  ed¦  «        ‚w xY w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 n# e$ r	 d dlmZ Y nw xY wd dlmZ d d	lmZmZ d d
lmZ d dlmZ d dlmZ d dlmZ dZ ee¦  «         G d„ de¦  «        ¦   «         Z ee
¦  «         G d„ de¦  «        ¦   «         Z G d„ dee¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Zd„ Z d„ Z!dS )é    )ÚIHostnameResolverz=Twisted 17.1.0 or later required for autobahn.twisted.testing)ÚDeferred)ÚIPv4Address)ÚHostResolution)ÚISSLTransportÚIReactorPluggableNameResolver)ÚMemoryReactorClock)Úiosim)ÚdirectlyProvidesÚimplementer)ÚIWebSocketClientAgent)Ú_TwistedWebSocketClientAgent)ÚWebSocketServerProtocol)ÚWebSocketServerFactory)Úcreate_pumperÚcreate_memory_agentÚMemoryReactorClockResolverc                   ó   — e Zd Zdd„ZdS )Ú_StaticTestResolverr   c                 óÎ   — t          |¦  «        }|                     |¦  «         |                     t          dd|dk    rdn|¦  «        ¦  «         |                     ¦   «          dS )zR
        Implement IHostnameResolver which always returns 127.0.0.1:31337
        ÚTCPú	127.0.0.1r   éiz  N)r   ÚresolutionBeganÚaddressResolvedr   ÚresolutionComplete)ÚselfÚreceiverÚhostNameÚ
portNumberÚ
resolutions        ú`/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/autobahn/twisted/testing/__init__.pyÚresolveHostNamez#_StaticTestResolver.resolveHostName@   sr   € õ $ HÑ-Ô-ˆ
Ø× Ò  Ñ,Ô,Ð,Ø× Ò Ý˜˜{°ZÀ1²_°_¨E¨EÈ*ÑUÔUñ	
ô 	
ð 	
ð 	×#Ò#Ñ%Ô%Ð%Ð%Ð%ó    N)r   )Ú__name__Ú
__module__Ú__qualname__r#   © r$   r"   r   r   >   s(   € € € € € ð	&ð 	&ð 	&ð 	&ð 	&ð 	&r$   r   c                   ó2   — e Zd ZdZdZed„ ¦   «         Zd„ ZdS )Ú_TestNameResolverz9
    A test version of IReactorPluggableNameResolver
    Nc                 óD   — | j         €t          ¦   «         | _         | j         S ©N)Ú	_resolverr   ©r   s    r"   ÚnameResolverz_TestNameResolver.nameResolverT   s   € àŒ>Ð!Ý0Ñ2Ô2ˆDŒNØŒ~Ðr$   c                 ó"   — | j         }|| _         |S r,   )r-   )r   ÚresolverÚolds      r"   ÚinstallNameResolverz%_TestNameResolver.installNameResolverZ   s   € ØŒnˆØ!ˆŒØˆ
r$   )r%   r&   r'   Ú__doc__r-   Úpropertyr/   r3   r(   r$   r"   r*   r*   L   sM   € € € € € ðð ð €Iàðð ñ „Xðð
ð ð ð ð r$   r*   c                   ó   — e Zd ZdZdS )r   zY
    Combine MemoryReactor, Clock and an IReactorPluggableNameResolver
    together.
    N)r%   r&   r'   r4   r(   r$   r"   r   r   `   s   € € € € € ðð ð 	€Dr$   r   c                   ó    — e Zd ZdZd„ Zdd„ZdS )Ú_TwistedWebMemoryAgentaä  
    A testing agent which will hook up an instance of
    `server_protocol` for every client that is created via the `open`
    API call.

    :param reactor: the reactor to use for tests (usually an instance
        of MemoryReactorClockResolver)

    :param pumper: an implementation IPumper (e.g. as returned by
        `create_pumper`)

    :param server_protocol: the server-side WebSocket protocol class
        to instantiate (e.g. a subclass of `WebSocketServerProtocol`
    c                 ó®   — || _         || _        || _        t          | j         ¦  «        | _        t          ¦   «         | _        t          ¦   «         | _        d S r,   )	Ú_reactorÚ_server_protocolÚ_pumperr   Ú_agentÚsetÚ_pumpsÚdictÚ_servers)r   ÚreactorÚpumperÚserver_protocols       r"   Ú__init__z_TwistedWebMemoryAgent.__init__x   sE   € ØˆŒØ /ˆÔØˆŒõ 3°4´=ÑAÔAˆŒÝ‘e”eˆŒÝ™œˆŒˆˆr$   Nc                 ó  ‡ ‡— |                      d¦  «        }‰ j                             |||¬¦  «        }|r‰ j        j        d         \  }}}}	}
}n‰ j        j        d         \  }}}}
}t          dd|¦  «        }t          ddd¦  «        }‰                      ¦   «         Št          ‰dd¦  «        €t          ¦   «         ‰_
        t          j        ‰d	||¬
¦  «        }|                     d¦  «        }t          j        |d||¬
¦  «        }|r*t          |t          ¦  «         t          |t          ¦  «         t          j        ‰|||¦  «        }‰ j                             |¦  «         ˆ ˆfd„}|                     |¦  «         |S )a}  
        Implement IWebSocketClientAgent with in-memory transports.

        :param transport_config: a string starting with 'wss://' or
            'ws://'

        :param options: a dict containing options

        :param protocol_class: the client protocol class to
            instantiate (or `None` for defaults, which is to use
            `WebSocketClientProtocol`)
        zwss://)Úprotocol_classéÿÿÿÿr   r   r   ÚfactoryNT)ÚisServerÚhostAddressÚpeerAddressFc                 ó   •— ‰‰j         | <   | S r,   )rA   )Úprotor   rD   s    €€r"   Úadd_mappingz0_TwistedWebMemoryAgent.open.<locals>.add_mapping´   s   ø€ Ø#2ˆDŒM˜%Ñ ØˆLr$   )Ú
startswithr=   Úopenr:   Ú
sslClientsÚ
tcpClientsr   r;   Úgetattrr   rI   r
   ÚFakeTransportÚbuildProtocolr   r   Úconnectr<   ÚaddÚaddCallback)r   Útransport_configÚoptionsrG   Ú	is_secureÚreal_client_protocolÚhostÚportrI   Úcontext_factoryÚtimeoutÚbindAddressÚserver_addressÚclient_addressÚserver_transportÚclientProtocolÚclient_transportÚpumprO   rD   s   `                  @r"   rQ   z_TwistedWebMemoryAgent.open‚   sÑ  øø€ ð %×/Ò/°Ñ9Ô9ˆ	ð  $œ{×/Ò/Ø˜gØ)ð  0ñ  
ô  
Ðð
 ð 	UØIMÌÔIaÐbdÔIeÑFˆD�$˜ °'¸;¸;à8<¼Ô8PÐQSÔ8TÑ5ˆD�$˜ ¨+å$ U¨K¸Ñ>Ô>ˆÝ$ U¨K¸Ñ?Ô?ˆà×/Ò/Ñ1Ô1ˆå�? I¨tÑ4Ô4Ð<Ý&<Ñ&>Ô&>ˆOÔ#å Ô.Ø dØ&°NðDñ Dô DÐð !×.Ò.¨tÑ4Ô4ˆÝ Ô.Ø UØ&°NðDñ Dô DÐð ð 	>ÝÐ-­}Ñ=Ô=Ð=ÝÐ-­}Ñ=Ô=Ð=åŒ}ØÐ-¨~Ð?OñQô QˆàŒ×Ò˜ÑÔÐð	ð 	ð 	ð 	ð 	ð 	ð 	×(Ò(¨Ñ5Ô5Ð5Ø#Ð#r$   r,   )r%   r&   r'   r4   rE   rQ   r(   r$   r"   r8   r8   h   sA   € € € € € ðð ðð ð ð6$ð 6$ð 6$ð 6$ð 6$ð 6$r$   r8   c                   ó6   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )	Ú
_Kalamazooaµ  
    Feeling whimsical about class names, see https://en.wikipedia.org/wiki/Handcar

    This is 'an IOPump pumper', an object which causes a series of
    IOPumps it is monitoring to do their I/O operations
    periodically. This needs the 'real' reactor which trial drives,
    because reasons:

     - so @inlineCallbacks / async-def functions work
       (if I could explain exactly why here, I would)

     - we need to 'break the loop' of synchronous calls somewhere and
       polluting the tests themselves with that is bad

     - get rid of e.g. .flush() calls in tests themselves (thus
      'teaching' the tests about details of I/O scheduling that they
      shouldn't know).
    c                 ób   — t          ¦   «         | _        d| _        g | _        ddlm} || _        d S )NFr   )rB   )r>   r?   Ú_pumpingÚ_waiting_for_stopÚtwisted.internetrB   Ú_global_reactor)r   Úglobal_reactors     r"   rE   z_Kalamazoo.__init__Ï   s<   € Ý‘e”eˆŒØˆŒØ!#ˆÔØ>Ð>Ð>Ð>Ð>Ð>Ø-ˆÔÐÐr$   c                 ó:   — | j                              |¦  «         dS )zp
        Add a new IOPump. It will be removed when both its client and
        server are disconnected.
        N)r?   rX   )r   Úps     r"   rX   z_Kalamazoo.addÖ   s   € ð
 	Œ�Š˜ÑÔÐÐÐr$   c                 óf   — | j         rdS d| _         | j                             d| j        ¦  «         dS )zÃ
        Begin triggering I/O in all IOPump instances we have. We will keep
        periodically 'pumping' our IOPumps until `.stop()` is
        called. Call from `setUp()` for example.
        NTr   )rl   ro   Ú	callLaterÚ
_pump_oncer.   s    r"   Ústartz_Kalamazoo.startÝ   s;   € ð Œ=ð 	ØˆFØˆŒØÔ×&Ò& q¨$¬/Ñ:Ô:Ð:Ð:Ð:r$   c                 óä   — | j         st          | j        ¦  «        r1t          ¦   «         }| j                             |¦  «         d| _         |S t          ¦   «         }|                     d¦  «         |S )z
        :returns: a Deferred that fires when we have stopped pump()-ing

        Call from `tearDown()`, for example.
        FN)rl   Úlenrm   r   ÚappendÚcallback©r   Úds     r"   Ústopz_Kalamazoo.stopè   sl   € ð Œ=ð 	�C Ô 6Ñ7Ô7ð 	Ý‘
”
ˆAØÔ"×)Ò)¨!Ñ,Ô,Ð,Ø!ˆDŒMØˆHÝ‰JŒJˆØ	�
Š
�4ÑÔÐØˆr$   c                 óÌ   — | j         r6|                      ¦   «          | j                             d| j        ¦  «         dS | j        D ]}|                     d¦  «         Œg | _        dS )z{
        flush all data from all our IOPump instances and schedule another
        iteration on the global reactor
        gš™™™™™¹?N)rl   Ú_flushro   rt   ru   rm   rz   r{   s     r"   ru   z_Kalamazoo._pump_once÷   sq   € ð
 Œ=ð 	(Ø�KŠK‰MŒMˆMØÔ ×*Ò*¨3°´Ñ@Ô@Ð@Ð@Ð@àÔ+ð !ð !�Ø—
’
˜4Ñ Ô Ð Ð Ø%'ˆDÔ"Ð"Ð"r$   c                 óÌ   — | j         }t          ¦   «         x}| _         |D ]D}|                     ¦   «          |j        j        r|j        j        rŒ/|                     |¦  «         ŒEdS )zE
        Flush all data between pending client/server pairs.
        N)r?   r>   ÚflushÚclientIOÚdisconnectedÚserverIOrX   )r   Ú	old_pumpsÚ	new_pumpsrr   s       r"   r   z_Kalamazoo._flush  sr   € ð ”Kˆ	Ý"%¡%¤%Ð'ˆ	�D”KØð 	ð 	ˆAØ�GŠG‰IŒIˆIØŒzÔ&ð ¨1¬:Ô+Bð ØØ�MŠM˜!ÑÔÐÐð		ð 	r$   N)
r%   r&   r'   r4   rE   rX   rv   r}   ru   r   r(   r$   r"   rj   rj   »   sx   € € € € € ðð ð&.ð .ð .ðð ð ð	;ð 	;ð 	;ðð ð ð(ð (ð (ð
ð 
ð 
ð 
ð 
r$   rj   c                  ó   — t          ¦   «         S )z4
    return a new instance implementing IPumper
    )rj   r(   r$   r"   r   r     s   € õ ‰<Œ<Ðr$   c                 ó6   — |€t           }t          | ||¦  «        S )a)  
    return a new instance implementing `IWebSocketClientAgent`.

    connection attempts will be satisfied by traversing the Upgrade
    request path starting at `resource` to find a `WebSocketResource`
    and then exchange data between client and server using purely
    in-memory buffers.
    )r   r8   )rB   rC   rD   s      r"   r   r     s!   € ð ÐÝ1ˆÝ! '¨6°?ÑCÔCÐCr$   N)"Útwisted.internet.interfacesr   ÚImportErrorÚtwisted.internet.deferr   Útwisted.internet.addressr   Útwisted.internet._resolverr   r   r   Útwisted.internet.testingr	   Útwisted.test.proto_helpersÚtwisted.testr
   Úzope.interfacer   r   Úautobahn.websocket.interfacesr   Úautobahn.twisted.websocketr   r   r   Ú__all__Úobjectr   r*   r   r8   rj   r   r   r(   r$   r"   ú<module>r–      s­  ðð<Ø=Ð=Ð=Ð=Ð=Ð=Ð=øØð ð ð Ø
ˆ+ØGñô ð ðøøøð
 ,Ð +Ð +Ð +Ð +Ð +Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø TÐ TÐ TÐ TÐ TÐ TÐ TÐ Tð>Ø;Ð;Ð;Ð;Ð;Ð;Ð;øØð >ð >ð >Ø=Ð=Ð=Ð=Ð=Ð=Ð=Ð=ð>øøøà Ð Ð Ð Ð Ð à 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8à ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø CÐ CÐ CÐ CÐ CÐ CØ >Ð >Ð >Ð >Ð >Ð >Ø =Ð =Ð =Ð =Ð =Ð =ð€ð €ÐÑÔð
&ð 
&ð 
&ð 
&ð 
&˜&ñ 
&ô 
&ñ  Ôð
&ð €Ð*Ñ+Ô+ðð ð ð ð ˜ñ ô ñ ,Ô+ðð&	ð 	ð 	ð 	ð 	Ð!3Ð5Fñ 	ô 	ð 	ðP$ð P$ð P$ð P$ð P$Ð2ñ P$ô P$ð P$ðfSð Sð Sð Sð S�ñ Sô Sð Sðlð ð ðDð Dð Dð Dð Ds   ‚	 ‰¸? ¿AÁA