§
    ÌtºfD>  ã                   óÂ   — d dl Z d dlZd dlZd dlmZ d dl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	Zd
„ Zd„ Zd„ Z G d„ dej        ¦  «        Zdd„ZdS )é    N)Úwraps)ÚWampWebSocketClientFactory)ÚWampRawSocketClientFactory)Ú	component)ÚTransportLost)ÚSession)Úcreate_transport_serializersÚcreate_transport_serializer)Ú	ComponentÚrunc                 ó<   ‡— t          ¦   «         Šˆfd„| D ¦   «         S )zM
    Return a list with unique elements from sequence, preserving order.
    c                 óF   •— g | ]}|‰v¯‰                      |¦  «        °|‘ŒS © )Úadd)Ú.0ÚxÚseens     €úY/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/autobahn/asyncio/component.pyú
<listcomp>z _unique_list.<locals>.<listcomp>3   s,   ø€ Ð@Ð@Ð@�!˜a t˜m˜m°D·H²H¸Q±K´K˜mˆA˜m˜m˜mó    )Úset)Úseqr   s    @r   Ú_unique_listr   .   s(   ø€ õ ‰5Œ5€DØ@Ð@Ð@Ð@�sÐ@Ñ@Ô@Ð@r   c                 óŒ   — |                       d¦  «        }|d         d                     d„ |dd …         D ¦   «         ¦  «        z   S )NÚ_r   Ú c              3   ó>   K  — | ]}|                      ¦   «         V — Œd S ©N)Ú
capitalize)r   Úss     r   ú	<genexpr>z._camel_case_from_snake_case.<locals>.<genexpr>8   s*   è è € Ð@Ð@°˜aŸlšl™nœnÐ@Ð@Ð@Ð@Ð@Ð@r   é   )ÚsplitÚjoin)ÚsnakeÚpartss     r   Ú_camel_case_from_snake_caser'   6   sE   € Ø�KŠK˜ÑÔ€EØ�Œ8�b—g’gÐ@Ð@°e¸A¸B¸B´iÐ@Ñ@Ô@Ñ@Ô@Ñ@Ð@r   c           
      ó<  — |j         dk    r-t          |¦  «        }t          ||j        ||j        ¬¦  «        }nA|j         dk    r,t          |j        d         ¦  «        }t          ||¬¦  «        }n
J d¦   «         ‚|j         	                    ¦   «         D ]ˆ\  }}	  |j
        d	i ||i¤Ž Œ# t          t          f$ r_ 	  |j
        d	i t          |¦  «        |i¤Ž n># t          t          f$ r* t          d                     |j         ||¦  «        ¦  «        ‚w xY wY Œ…w xY w|S )
z3
    Create a WAMP-over-XXX transport factory.
    Ú	websocket)ÚurlÚserializersÚproxyÚ	rawsocketr   )Ú
serializerFúshould not arrive herez"Unknown {} transport option: {}={}r   )Útyper	   r   r*   r,   r
   r+   r   ÚoptionsÚitemsÚsetProtocolOptionsÚ	TypeErrorÚKeyErrorr'   Ú
ValueErrorÚformat)ÚloopÚ	transportÚsession_factoryr+   Úfactoryr.   ÚkÚvs           r   Ú_create_transport_factoryr>   ;   s�  € ð „~˜Ò$Ð$Ý2°9Ñ=Ô=ˆÝ,ØØ”Ø#Ø”/ð	
ñ 
ô 
ˆˆð 
Œ˜;Ò	&Ð	&Ý0°Ô1FÀqÔ1IÑJÔJˆ
Ý,¨_ÈÐTÑTÔTˆˆð 	0Ð/Ñ/Ô/Ð/ð Ô!×'Ò'Ñ)Ô)ð ð ‰ˆˆ1ð	Ø&ˆGÔ&Ð0Ð0¨!¨Q¨Ð0Ð0Ð0Ð0øÝ�8Ð$ð 	ð 	ð 	ðØ*�Ô*ð ð Ý2°1Ñ5Ô5°qÐ9ðð ð ð øõ �xÐ(ð ð ð Ý Ø8×?Ò?À	ÄÐPQÐSTÑUÔUñô ð ðøøøðð ð	øøøð €Ns*   ÂB)Â)DÂ;CÃDÃ;DÄDÄDc                   óV   — e Zd ZdZ ej        ¦   «         ZeZ	 d„ Z	d„ Z
d„ Zd„ Zdd„ZdS )	r   zæ
    A component establishes a transport and attached a session
    to a realm using the transport for communication.

    The transports a component tries to use can be configured,
    as well as the auto-reconnect strategy.
    c                 ó6   — t          |t          j        ¦  «        S )z"
        Internal helper.
        )Ú
isinstanceÚsslÚSSLError)ÚselfÚes     r   Ú_is_ssl_errorzComponent._is_ssl_errorr   s   € õ ˜!�Sœ\Ñ*Ô*Ð*r   c                 óø   — t          |t          ¦  «        rWd|v rQ|d         }t          |t          t          f¦  «        rd S t          |t          j        ¦  «        rd S t          d¦  «        ‚d S t          d¦  «        ‚)NÚtlsz?'tls' configuration must be a dict, bool or SSLContext instancezI'endpoint' configuration must be a dict or IStreamClientEndpoint provider)rA   ÚdictÚboolrB   Ú
SSLContextr6   )rD   ÚendpointrH   s      r   Ú_check_native_endpointz Component._check_native_endpointx   s”   € Ý�h¥Ñ%Ô%ð 	Ø˜Ð Ð Ø˜u”o�Ý˜c¥D­$ <Ñ0Ô0ð Ø�DÝ ¥S¤^Ñ4Ô4ð Ø�Då$ð.ñô ð ð !Ð õ ðñô ð r   c                 ó:	  — t          |||¦  «        }|j        rÏ|j                             dd¦  «        }t	          |¦  «        t
          k    r/t          d                     t	          |¦  «        ¦  «        ¦  «        ‚|                     ||j        d         |j        d         ¬¦  «        }t          j
        t          j        ||¬¦  «        ¦  «        }|                      |||¦  «        S |j        d         d	k    �rý|j                             d
d¦  «        }	|	dvr"t          d                     |	¦  «        ¦  «        ‚|j        d         }
t	          |
¦  «        t          k    r/t          d                     t	          |
¦  «        ¦  «        ¦  «        ‚|j        d         }t	          |¦  «        t
          k    r/t          d                     t	          |¦  «        ¦  «        ¦  «        ‚|j                             dd¦  «        }t	          |¦  «        t
          k    r/t          d                     t	          |¦  «        ¦  «        ¦  «        ‚|j                             dd¦  «        }d}|�r9t          |t          ¦  «        rÏ|                     ¦   «         D ](}|dvr"t          d                     |¦  «        ¦  «        ‚Œ)|                     d|
¦  «        }t	          |¦  «        t          k    r"t          d                     |¦  «        ¦  «        ‚|                     dd¦  «        }|}d}|�%t#          j        t"          j        j        |¬¦  «        }nUt          |t"          j        ¦  «        r|
}n8|dv r|r|
}n/t-          d                     t	          |¦  «        ¦  «        ¦  «        ‚|                     ||
|||¬¦  «        }t          j
        t          j        ||¬¦  «        ¦  «        }|                      |||¦  «        S |j        d         dk    r‹|j        d         }t          |j                             dd¦  «        ¦  «        }|                     ||¬¦  «        }t          j
        t          j        ||¬¦  «        ¦  «        }|                      |||¦  «        S J d ¦   «         ‚)!z?
        Create and connect a WAMP-over-XXX transport.
        Útimeouté
   z<invalid type {} for timeout in client endpoint configurationÚhostÚport)Úprotocol_factoryrQ   rR   )rO   r0   ÚtcpÚversioné   )rV   é   z6invalid IP version {} in client endpoint configurationz9invalid type {} for host in client endpoint configurationz9invalid type {} for port in client endpoint configurationrH   N)ÚhostnameÚ
trust_rootz Invalid key '{}' in 'tls' configrX   zAinvalid type {} for hostname in TLS client endpoint configurationrY   T)ÚpurposeÚcafile)FTz4unknown type {} for "tls" configuration in transport)rS   rQ   rR   rB   Úserver_hostnameÚunixÚpath)rS   r^   Fr/   )r>   r,   rL   Úgetr0   Úintr6   r7   Úcreate_connectionÚasyncioÚensure_futureÚwait_forÚ_wrap_connection_futureÚstrrA   rI   ÚkeysrB   Úcreate_default_contextÚPurposeÚSERVER_AUTHrK   ÚRuntimeErrorÚcreate_unix_connection)rD   r8   r9   r:   Údoner;   rO   ÚfÚtime_frU   rQ   rR   rH   Útls_hostnamer<   rX   Ú
cert_fnamer^   s                     r   Ú_connect_transportzComponent._connect_transportŒ   s†  € õ ,¨D°)¸_ÑMÔMˆð
 Œ?ð W	4ØÔ(×,Ò,¨Y¸Ñ;Ô;ˆGÝ�G‰}Œ}¥Ò#Ð#Ý Ð!_×!fÒ!fÕgkÐlsÑgtÔgtÑ!uÔ!uÑvÔvÐvð ×&Ò&Ø!(Ø”_ VÔ,Ø”_ VÔ,ð 'ñ ô ˆAõ
 Ô*­7Ô+;¸AÀwÐ+OÑ+OÔ+OÑPÔPˆFØ×/Ò/°	¸4ÀÑHÔHÐHàÔ Ô'¨5Ò0Ñ0àÔ(×,Ò,¨Y¸Ñ:Ô:ˆGØ˜fÐ$Ð$Ý Ð!Y×!`Ò!`ÐahÑ!iÔ!iÑjÔjÐjàÔ% fÔ-ˆDÝ�D‰zŒz�SÒ Ð Ý Ð!\×!cÒ!cÕdhÐimÑdnÔdnÑ!oÔ!oÑpÔpÐpàÔ% fÔ-ˆDÝ�D‰zŒz�SÒ Ð Ý Ð!\×!cÒ!cÕdhÐimÑdnÔdnÑ!oÔ!oÑpÔpÐpàÔ(×,Ò,¨Y¸Ñ;Ô;ˆGÝ�G‰}Œ}¥Ò#Ð#Ý Ð!_×!fÒ!fÕgkÐlsÑgtÔgtÑ!uÔ!uÑvÔvÐvàÔ$×(Ò(¨°Ñ5Ô5ˆCØˆLð ñ qÝ˜c¥4Ñ(Ô(ð qØ ŸXšX™ZœZð [ð [˜ØÐ$>Ð>Ð>Ý",Ð-O×-VÒ-VÐWXÑ-YÔ-YÑ"ZÔ"ZÐZð ?à"Ÿwšw z°4Ñ8Ô8�HÝ˜H‘~”~­Ò,Ð,Ý(Ð)l×)sÒ)sÐt|Ñ)}Ô)}Ñ~Ô~Ð~Ø!$§¢¨°tÑ!<Ô!<�Jà#+�LØ�CØ!Ð-Ý!Ô8Ý$'¤KÔ$;Ø#-ðñ ô ˜øõ
   ¥S¤^Ñ4Ô4ð 	qà#'�L�Là˜MÐ)Ð)Øð ,Ø'+˜øõ 'Ð']×'dÒ'dÕeiÐjmÑenÔenÑ'oÔ'oÑpÔpÐpà×&Ò&Ø!(ØØØØ ,ð 'ñ ô ˆAõ Ô*­7Ô+;¸AÀwÐ+OÑ+OÔ+OÑPÔPˆFØ×/Ò/°	¸4ÀÑHÔHÐHàÔ Ô'¨6Ò1Ð1ØÔ% fÔ-ˆDÝ˜)Ô,×0Ò0°¸BÑ?Ô?Ñ@Ô@ˆGà×+Ò+Ø!(Øð ,ñ ô ˆAõ Ô*­7Ô+;¸AÀwÐ+OÑ+OÔ+OÑPÔPˆFØ×/Ò/°	¸4ÀÑHÔHÐHð 4Ð3Ñ3Ô3Ð3r   c                 óx   ‡‡— ˆfd„}ˆˆfd„}t          j        ||d ¦  «         t          j        |d |¦  «         |S )Nc                 ó   •‡— | \  }}|                      ¦   «         rIt          j        ‰¦  «        s3t          |dd¦  «        }t          j        ‰t          |¦  «        ¦  «         d S |j        Št          ‰¦  «        ˆˆfd„¦   «         }||_        d S )NÚ_onclose_reasonzConnection already closedc                 ó’   •—  ‰| ¦  «        }t          j        ‰¦  «        s&| €t          d¦  «        } t          j        ‰| ¦  «         |S )Nzfailed to complete connection)ÚtxaioÚ	is_calledr   Úreject)ÚfailÚrtnrm   Úorigs     €€r   ÚlostzKComponent._wrap_connection_future.<locals>.on_connect_success.<locals>.lost  sN   ø€ à�d˜4‘j”j�Ý” tÑ,Ô,ð -ð �|Ý,Ð-LÑMÔM˜Ý”L  tÑ,Ô,Ð,Ø�
r   )Ú
is_closingrw   rx   Úgetattrry   r   Úconnection_lostr   )Úresultr9   ÚprotoÚreasonr}   r|   rm   s        @€r   Úon_connect_successz=Component._wrap_connection_future.<locals>.on_connect_successð   s°   øø€ à%ÑˆI�uð ×#Ò#Ñ%Ô%ð Ý” tÑ,Ô,ð >Ý$ UÐ,=Ð?ZÑ[Ô[�FÝ”L ¥}°VÑ'<Ô'<Ñ=Ô=Ð=Ø�ð Ô(ˆDå�4‰[Œ[ð	ð 	ð 	ð 	ð 	ñ Œ[ð	ð %)ˆEÔ!Ð!Ð!r   c                 óR   •— ‰xj         dz  c_         t          j        ‰| ¦  «         d S )Nr"   )Úconnect_failuresrw   ry   )Úerrrm   r9   s    €€r   Úon_connect_failurez=Component._wrap_connection_future.<locals>.on_connect_failure  s/   ø€ ØÐ&Ô&¨!Ñ+Ð&Ô&åŒL˜˜sÑ#Ô#Ð#Ð#Ð#r   )rw   Úadd_callbacks)rD   r9   rm   Úconn_fr„   rˆ   s    ``   r   re   z!Component._wrap_connection_futureî   sq   øø€ ð&	)ð &	)ð &	)ð &	)ð &	)ðP	$ð 	$ð 	$ð 	$ð 	$ð 	$õ
 	Ô˜FÐ$6¸Ñ=Ô=Ð=õ 	Ô˜F DÐ*<Ñ=Ô=Ð=Øˆr   Nc                 óŒ   — |€-| j                              d¦  «         t          j        ¦   «         }|                      |¬¦  «        S )a~  
        This starts the Component, which means it will start connecting
        (and re-connecting) to its configured transports. A Component
        runs until it is "done", which means one of:
        - There was a "main" function defined, and it completed successfully;
        - Something called ``.leave()`` on our session, and we left successfully;
        - ``.stop()`` was called, and completed successfully;
        - none of our transports were able to connect successfully (failure);

        :returns: a Future which will resolve (to ``None``) when we are
            "done" or with an error if something went wrong.
        NzUsing default loop)r8   )ÚlogÚwarnrb   Úget_event_loopÚ_start)rD   r8   s     r   ÚstartzComponent.start$  s@   € ð ˆ<ØŒH�MŠMÐ.Ñ/Ô/Ð/ÝÔ)Ñ+Ô+ˆDà�{Š{ ˆ{Ñ%Ô%Ð%r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rw   Úmake_loggerrŒ   r   r:   rF   rM   rr   re   r�   r   r   r   r   r   b   s�   € € € € € ðð ð ˆ%Ô
Ñ
Ô
€Cà€Oðð+ð +ð +ðð ð ð(`4ð `4ð `4ðD3ð 3ð 3ðl&ð &ð &ð &ð &ð &r   r   TÚinfoc                 ó´  ‡‡‡— |�t          j        |¬¦  «         t          j        ¦   «         Š‰                     ¦   «         rIt          j        t          j        ¦   «         ¦  «         t          j        ¦   «         Š‰t           j        _        t          j	        ¦   «         Šˆˆfd„Š	 ‰ 
                    t          j        ˆfd„¦  «         ‰ 
                    t          j        ˆfd„¦  «         n# t          $ r Y nw xY wd„ }t          j        ‰| |¦  «         |rA	 ‰                     ¦   «          n# t          j        $ r Y nw xY w‰                     ¦   «          dS dS )a.  
    High-level API to run a series of components.

    This will only return once all the components have stopped
    (including, possibly, after all re-connections have failed if you
    have re-connections enabled). Under the hood, this calls

    XXX fixme for asyncio

    -- if you wish to manage the loop yourself, use the
    :meth:`autobahn.asyncio.component.Component.start` method to start
    each component yourself.

    :param components: the Component(s) you wish to run
    :type components: instance or list of :class:`autobahn.asyncio.component.Component`

    :param start_loop: When ``True`` (the default) this method
        start a new asyncio loop.
    :type start_loop: bool

    :param log_level: a valid log-level (or None to avoid calling start_logging)
    :type log_level: string
    N)Úlevelc              “   óÒ  •K  — ‰                      d| ¬¦  «         	 t          j                             ¦   «         }n## t          $ r t          j        ¦   «         }Y nw xY w|D ]]}	 t          j                             ¦   «         }n## t          $ r t          j        ¦   «         }Y nw xY w||ur|                     ¦   «          Œ^ˆˆfd„}t          j        |Ž }|                     |¦  «         d S )NzShutting down due to {signal})Úsignalc                 ó4  •— 	 |                       ¦   «          nS# t          j        $ r ‰                     d¦  «         Y n-t          $ r!}‰                     d|¬¦  «         Y d }~nd }~ww xY w‰                     ¦   «          d S # ‰                     ¦   «          w xY w)NzAll task cancelledz&Error while shutting down: {exception})Ú	exception)r�   rb   ÚCancelledErrorÚdebugÚ	ExceptionÚerrorÚstop)ÚfutrE   rŒ   r8   s     €€r   Úcancel_all_callbackz5run.<locals>.nicely_exit.<locals>.cancel_all_callbacky  s³   ø€ ðØ—
’
‘”��øÝÔ)ð 0ð 0ð 0Ø—	’	Ð.Ñ/Ô/Ð/Ð/Ð/Ýð Qð Qð QØ—	’	ÐBÈa�	ÑPÔPÐPÐPÐPÐPÐPÐPøøøøðQøøøð —	’	‘”���ø�—	’	‘”��øøøs6   ƒ —B ˜$A(¼B ¾	A(ÁA#ÁB Á#A(Á(B ÂB)	r–   rb   ÚTaskÚ	all_tasksÚAttributeErrorÚcurrent_taskÚcancelÚgatherÚadd_done_callback)rš   ÚtasksÚtaskr§   r£   r¢   rŒ   r8   s         €€r   Únicely_exitzrun.<locals>.nicely_exite  s  øè è € Ø�ŠÐ0¸ˆÑ@Ô@Ð@ð	(Ý”L×*Ò*Ñ,Ô,ˆEˆEøÝð 	(ð 	(ð 	(åÔ%Ñ'Ô'ˆEˆEˆEð	(øøøð ð 		ð 		ˆDð6Ý&œ|×8Ò8Ñ:Ô:��øÝ!ð 6ð 6ð 6Ý&Ô3Ñ5Ô5���ð6øøøð ˜<Ð'Ð'Ø—’‘”�øð	ð 	ð 	ð 	ð 	ð 	õ Œn˜eÐ$ˆØ×ÒÐ1Ñ2Ô2Ð2Ð2Ð2s!   œ; »AÁAÁ#BÂB"Â!B"c                  ó>   •— t          j         ‰ d¦  «        ¦  «        S )NÚSIGINT©rb   rc   ©r­   s   €r   ú<lambda>zrun.<locals>.<lambda>‡  s   ø€ µwÔ7LÈ[È[ÐYaÑMbÔMbÑ7cÔ7c€ r   c                  ó>   •— t          j         ‰ d¦  «        ¦  «        S )NÚSIGTERMr°   r±   s   €r   r²   zrun.<locals>.<lambda>ˆ  s   ø€ ½Ô8MÈkÈkÐZcÑNdÔNdÑ8eÔ8e€ r   c                 ó.   — |                       ¦   «          d S r   )r¡   )r8   Úargs     r   Údone_callbackzrun.<locals>.done_callback�  s   € Ø�	Š	‰Œˆˆˆr   )rw   Ústart_loggingrb   rŽ   Ú	is_closedÚset_event_loopÚnew_event_loopÚconfigr8   r•   Úadd_signal_handlerrš   r¯   r´   ÚNotImplementedErrorr   Ú_runÚrun_foreverr�   Úclose)Ú
componentsÚ
start_loopÚ	log_levelr·   rŒ   r8   r­   s       @@@r   r   r   9  s•  øøø€ ð8 ÐÝÔ )Ð,Ñ,Ô,Ð,ÝÔ!Ñ#Ô#€DØ‡~‚~ÑÔð !ÝÔ�wÔ5Ñ7Ô7Ñ8Ô8Ð8ÝÔ%Ñ'Ô'ˆØ �ŒÔÝ
Ô
Ñ
Ô
€Cð3ð 3ð 3ð 3ð 3ð 3ðBØ×Ò¥¤Ð/cÐ/cÐ/cÐ/cÑdÔdÐdØ×Ò¥¤Ð0eÐ0eÐ0eÐ0eÑfÔfÐfÐføÝð ð ð àˆðøøøðð ð õ „N�4˜ ]Ñ3Ô3Ð3àð ð	Ø×ÒÑÔÐÐøõ Ô%ð 	ð 	ð 	ØˆDð	øøøð 	�
Š
‰Œˆˆˆðð s%   Â%AC, Ã,
C9Ã8C9ÄD- Ä-D?Ä>D?)Tr–   )rb   rB   rš   Ú	functoolsr   rw   Úautobahn.asyncio.websocketr   Úautobahn.asyncio.rawsocketr   Úautobahn.wampr   Úautobahn.wamp.exceptionr   Úautobahn.asyncio.wampr   Úautobahn.wamp.serializerr	   r
   Ú__all__r   r'   r>   r   r   r   r   r   ú<module>rÍ      sD  ðð6 €€€Ø 
€
€
€
Ø €€€Ø Ð Ð Ð Ð Ð à €€€Ø AÐ AÐ AÐ AÐ AÐ AØ AÐ AÐ AÐ AÐ AÐ Aà #Ð #Ð #Ð #Ð #Ð #Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1à )Ð )Ð )Ð )Ð )Ð )Ø ^Ð ^Ð ^Ð ^Ð ^Ð ^Ð ^Ð ^ð €ðAð Að AðAð Að Að
$ð $ð $ðNT&ð T&ð T&ð T&ð T&�	Ô#ñ T&ô T&ð T&ðnhð hð hð hð hð hr   