403Webshell
Server IP : 15.235.198.142  /  Your IP : 216.73.216.149
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/twisted/words/protocols/jabber/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/twisted/words/protocols/jabber/__pycache__/component.cpython-312.pyc
�

Ϫ�fj;���dZddlmZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
ddlmZddlmZd	Zd
�ZGd�d�ZGd
�de
j,�ZGd�de
j0�Zeej4�Gd�dej6��ZGd�dej8�Zd�ZGd�d�ZGd�de
j@�Z!y)a�
External server-side components.

Most Jabber server implementations allow for add-on components that act as a
separate entity on the Jabber network, but use the server-to-server
functionality of a regular Jabber IM server. These so-called 'external
components' are connected to the Jabber server using the Jabber Component
Protocol as defined in U{JEP-0114<http://www.jabber.org/jeps/jep-0114.html>}.

This module allows for writing external server-side component by assigning one
or more services implementing L{ijabber.IService} up to L{ServiceManager}. The
ServiceManager connects to the Jabber server and is responsible for the
corresponding XML stream.
�)�implementer)�service)�defer)�log)�error�ijabber�	jstrports�	xmlstream)�	internJID)�domishzjabber:component:acceptc�D�t||�}tj|�S)z�
    XML stream factory for external server-side components.

    @param componentid: JID of the component.
    @type componentid: L{unicode}
    @param password: password used to authenticate to the server.
    @type password: C{str}
    )�ConnectComponentAuthenticatorr
�XmlStreamFactory)�componentid�password�as   �J/usr/lib/python3/dist-packages/twisted/words/protocols/jabber/component.py�componentFactoryr!s!��	&�k�8�<�A��%�%�a�(�(�c�"�eZdZdZd�Zd�Zd�Zy)�ComponentInitiatingInitializerz�
    External server-side component authentication initializer for the
    initiating entity.

    @ivar xmlstream: XML stream between server and component.
    @type xmlstream: L{xmlstream.XmlStream}
    c� �||_d|_y�N)r
�	_deferred��self�xss  r�__init__z'ComponentInitiatingInitializer.__init__7s�������rc��|j}tj|jjdf�}tj|j
|jj�}|jt|��|jd|j�|j|�tj�|_|jS)N�	handshakez
/handshake)r
r�Element�	namespace�hashPassword�sid�
authenticatorr�
addContent�str�addOnetimeObserver�_cbHandshake�sendr�Deferredr)rr�hs�digests    r�
initializez)ComponentInitiatingInitializer.initialize;s���
�^�^��
�^�^�T�^�^�5�5�{�C�
D���'�'�����0@�0@�0I�0I�J��
�
�
�c�&�k�"�	���l�D�,=�,=�>�
��������)����~�~�rc��|jj|j_|jj	d�yr)r
�otherEntity�
thisEntityr�callback)r�_s  rr)z+ComponentInitiatingInitializer._cbHandshakeGs,��%)�N�N�$>�$>����!�������%rN)�__name__�
__module__�__qualname__�__doc__rr.r)�rrrr.s����
�&rrc� �eZdZdZeZd�Zd�Zy)rz�
    Authenticator to permit an XmlStream to authenticate against a Jabber
    server as an external component (where the Authenticator is initiating the
    stream).
    c�R�tjj||�||_y)z�
        @type componentjid: C{str}
        @param componentjid: Jabber ID that this component wishes to bind to.

        @type password: C{str}
        @param password: Password/secret this component uses to authenticate.
        N)r
�ConnectAuthenticatorrr)r�componentjidrs   rrz&ConnectComponentAuthenticator.__init__Ws!��	�&�&�/�/��l�C� ��
rc�t�d|_tjj||�t	|�g|_y)N�rr)�versionr
r;�associateWithStreamr�initializersrs  rr@z1ConnectComponentAuthenticator.associateWithStreamcs.����
��&�&�:�:�4��D�9�"�=�>��rN)r4r5r6r7�NS_COMPONENT_ACCEPTr"rr@r8rrrrNs���$�I�
!�?rrc�2�eZdZdZeZd�Zd�Zd�Zd�Z	d�Z
y)�ListenComponentAuthenticatorz�
    Authenticator for accepting components.

    @since: 8.2
    @ivar secret: The shared secret used to authorized incoming component
                  connections.
    @type secret: C{unicode}.
    c�P�||_tjj|�yr)�secretr
�ListenAuthenticatorr)rrFs  rrz%ListenComponentAuthenticator.__init__vs������%�%�.�.�t�4rc�R�d|_tjj||�y)z�
        Associate the authenticator with a stream.

        This sets the stream's version to 0.0, because the XEP-0114 component
        protocol was not designed for XMPP 1.0.
        r>N)r?r
rGr@rs  rr@z0ListenComponentAuthenticator.associateWithStreamzs!����
��%�%�9�9�$��Crc���tjj||�|j|jk7r1tjd�}|jj|�y|jjs1tjd�}|jj|�y|jj�|jjd|j�y)aa
        Called by the stream when it has started.

        This examines the default namespace of the incoming stream and whether
        there is a requested hostname for the component. Then it generates a
        stream identifier, sends a response header and adds an observer for
        the first incoming element, triggering L{onElement}.
        zinvalid-namespaceNzimproper-addressing�/*)r
rG�
streamStarted�
defaultUrir"r�StreamError�sendStreamErrorr1�
sendHeaderr(�	onElement)r�rootElement�excs   rrKz*ListenComponentAuthenticator.streamStarted�s���	�%�%�3�3�D�+�F��!�!�T�^�^�3��#�#�$7�8�C��N�N�*�*�3�/���~�~�(�(��#�#�$9�:�C��N�N�*�*�3�/�����!�!�#����)�)�$����?rc���|j|jf|jdfk(r|jt	|��ytjd�}|jj|�y)a.
        Called on incoming XML Stanzas.

        The very first element received should be a request for handshake.
        Otherwise, the stream is dropped with a 'not-authorized' error. If a
        handshake request was received, the hash is extracted and passed to
        L{onHandshake}.
        r �not-authorizedN)	�uri�namer"�onHandshaker'rrMr
rN)r�elementrRs   rrPz&ListenComponentAuthenticator.onElement�sW��
�K�K����&�4�>�>�;�*G�G����S��\�*��#�#�$4�5�C��N�N�*�*�3�/rc��tj|jjt|j��}||k7r3tjdd��}|jj|�y|jjd�|jj|jtj�y)a9
        Called upon receiving the handshake request.

        This checks that the given hash in C{handshake} is equal to a
        calculated hash, responding with a handshake reply or a stream error.
        If the handshake was ok, the stream is authorized, and  XML Stanzas may
        be exchanged.
        rTzInvalid hash)�textz<handshake/>N)r
r#r$r'rFrrMrNr*�dispatch�STREAM_AUTHD_EVENT)rr �calculatedHashrRs    rrWz(ListenComponentAuthenticator.onHandshake�s���#�/�/����0B�0B�C����DT�U����&��#�#�$4�>�J�C��N�N�*�*�3�/��N�N����/��N�N�#�#�D�N�N�I�4P�4P�QrN)r4r5r6r7rBr"rr@rKrPrWr8rrrDrDjs*���$�I�5�D�@�6
0�RrrDc�(�eZdZdZd�Zd�Zd�Zd�Zy)�Servicez1
    External server-side component service.
    c��yrr8rs  r�componentConnectedzService.componentConnected����rc��yrr8�rs r�componentDisconnectedzService.componentDisconnected�rbrc��yrr8rs  r�transportConnectedzService.transportConnected�rbrc�:�|jj|�y)a�
        Send data over service parent's XML stream.

        @note: L{ServiceManager} maintains a queue for data sent using this
        method when there is no current established XML stream. This data is
        then sent as soon as a new stream has been established and initialized.
        Subsequently, L{componentConnected} will be called again. If this
        queueing is not desired, use C{send} on the XmlStream object (passed to
        L{componentConnected}) directly.

        @param obj: data to be sent over the XML stream. This is usually an
        object providing L{domish.IElement}, or serialized XML. See
        L{xmlstream.XmlStream} for details.
        N)�parentr*�r�objs  rr*zService.send�s�� 	
������rN)r4r5r6r7rarergr*r8rrr_r_�s���
�
�
�rr_c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�ServiceManagera[
    Business logic for a managed component connection to a Jabber router.

    This service maintains a single connection to a Jabber router and provides
    facilities for packet routing and transmission. Business logic modules are
    services implementing L{ijabber.IService} (like subclasses of L{Service}),
    and added as sub-service.
    c�F�tjj|�||_d|_g|_t
|j|�|_|jjtj|j�|jjtj|j�|jjtj|j�|jj|_|jj|_yr)r�MultiServicer�jabberIdr
�_packetQueuer�
_xsFactory�addBootstrap�STREAM_CONNECTED_EVENT�
_connectedr\�_authd�STREAM_END_EVENT�
_disconnected�removeBootstrap)r�jidrs   rrzServiceManager.__init__�s������%�%�d�+���
�������+�4�=�=�(�C���	
���$�$�Y�%E�%E�t���W����$�$�Y�%A�%A�4�;�;�O����$�$�Y�%?�%?��AS�AS�T�
!�O�O�8�8���#���>�>��rc��|jSr)rrrds r�
getFactoryzServiceManager.getFactorys�����rc��||_|D]3}tjj|�s�#|j	|��5yr)r
r�IService�
providedByrg)rr�cs   rruzServiceManager._connecteds:������	)�A����*�*�1�-��$�$�R�(�	)rc���|jD]}|jj|��g|_|D]3}tjj|�s�#|j
|��5yr)rqr
r*rr~rra)rr�pr�s    rrvzServiceManager._authdsd���"�"�	#�A��N�N����"�	#�����	)�A����*�*�1�-��$�$�R�(�	)rc��d|_|D]2}tjj|�s�#|j	��4yr)r
rr~rre)rr3r�s   rrxzServiceManager._disconnecteds:������	*�A����*�*�1�-��'�'�)�	*rc��|jdk7r|jj|�y|jj|�y)a�
        Send data over the XML stream.

        When there is no established XML stream, the data is queued and sent
        out when a new XML stream has been established and initialized.

        @param obj: data to be sent over the XML stream. This is usually an
        object providing L{domish.IElement}, or serialized XML. See
        L{xmlstream.XmlStream} for details.
        N)r
r*rq�appendrjs  rr*zServiceManager.send"s6���>�>�T�!��N�N����$����$�$�S�)rN)
r4r5r6r7rr|rurvrxr*r8rrrmrm�s%���?�2�)�	)�*�*rrmc��t||�}tj||j��}|j	|�|S)z[
    Constructs a pre-built L{ServiceManager}, using the specified strport
    string.
    )rmr	�clientr|�setServiceParent)rzr�strport�svc�
client_svcs     r�buildServiceManagerr�4s<����h�
'�C��!�!�'�3�>�>�+;�<�J�����$��Jrc�(�eZdZdZd�Zd�Zd�Zd�Zy)�Routera�
    XMPP Server's Router.

    A router connects the different components of the XMPP service and routes
    messages between them based on the given routing table.

    Connected components are trusted to have correct addressing in the
    stanzas they offer for routing.

    A route destination of L{None} adds a default route. Traffic for which no
    specific route exists, will be routed to this default route.

    @since: 8.2
    @ivar routes: Routes based on the host part of JIDs. Maps host names to the
                  L{EventDispatcher<utility.EventDispatcher>}s that should
                  receive the traffic. A key of L{None} means the default
                  route.
    @type routes: C{dict}
    c��i|_yr)�routesrds rrzRouter.__init__Us	����rc�Z�||j|<|jd|j�y)a
        Add a new route.

        The passed XML Stream C{xs} will have an observer for all stanzas
        added to route its outgoing traffic. In turn, traffic for
        C{destination} will be passed to this stream.

        @param destination: Destination of the route to be added as a host name
                            or L{None} for the default route.
        @type destination: C{str} or L{None}.
        @param xs: XML Stream to register the route for.
        @type xs: L{EventDispatcher<utility.EventDispatcher>}.
        rJN)r��addObserver�route�r�destinationrs   r�addRoutezRouter.addRouteXs$��$&����K� �
���t�T�Z�Z�(rc�|�|jd|j�||j|k(r|j|=yy)a
        Remove a route.

        @param destination: Destination of the route that should be removed.
        @type destination: C{str}.
        @param xs: XML Stream to remove the route for.
        @type xs: L{EventDispatcher<utility.EventDispatcher>}.
        rJN)�removeObserverr�r�r�s   r�removeRoutezRouter.removeRouteis:��	���$��
�
�+�
����[�)�)����K�(�*rc�L�t|d�}tjd|j��d|j	����|j
|jvr)|j|j
j|�y|jdj|�y)z{
        Route a stanza.

        @param stanza: The stanza to be routed.
        @type stanza: L{domish.Element}.
        �tozRouting to z: N)�JIDr�msg�full�toXml�hostr�r*)r�stanzar�s   rr�zRouter.routevs����&��,�'�����+�k�.�.�0�1��F�L�L�N�3E�F�G����t�{�{�*��K�K��(�(�)�.�.�v�6��K�K���"�"�6�*rN)r4r5r6r7rr�r�r�r8rrr�r�@s���(�)�")�+rr�c�4�eZdZdZdZd	d�Zd�Zd�Zd�Zd�Z	y)
�XMPPComponentServerFactoryz�
    XMPP Component Server factory.

    This factory accepts XMPP external component connections and makes
    the router service route traffic for a component's bound domain
    to that component.

    @since: 8.2
    Fc�"��|�_|�_�fd�}tjj	�|��jtj�j��jtj�j�d�_
y)Nc�.��t�j�Sr)rDrFrds�r�authenticatorFactoryzAXMPPComponentServerFactory.__init__.<locals>.authenticatorFactory�s���/����<�<rr)�routerrFr
�XmlStreamServerFactoryrrsrt�onConnectionMader\�onAuthenticated�serial)rr�rFr�s`   rrz#XMPPComponentServerFactory.__init__�sn���������	=�	�(�(�1�1�$�8L�M����)�:�:�D�<Q�<Q�R����)�6�6��8L�8L�M���rc����|j�_|xjdz
c_�fd�}�fd�}|jr|�_|�_�j	t
j|j�y)z{
        Called when a component connection was made.

        This enables traffic debugging on incoming streams.
        �c�N��tjd�j|fz�y)Nz
RECV (%d): %r�rr�r���bufrs �r�	logDataInz>XMPPComponentServerFactory.onConnectionMade.<locals>.logDataIn������G�G�O�r�y�y�#�&6�6�7rc�N��tjd�j|fz�y)Nz
SEND (%d): %rr�r�s �r�
logDataOutz?XMPPComponentServerFactory.onConnectionMade.<locals>.logDataOut�r�rN)r��
logTraffic�rawDataInFn�rawDataOutFnr�r
�STREAM_ERROR_EVENT�onError)rrr�r�s `  rr�z+XMPPComponentServerFactory.onConnectionMade�sW����K�K��	����q���	8�	8��?�?�&�B�N�(�B�O�
���y�3�3�T�\�\�Brc���|jj}|jj||�|j	t
j|jd||�y)z�
        Called when a component has successfully authenticated.

        Add the component to the routing table and establish a handler
        for a closed connection.
        rN)r1r�r�r�r�r
rw�onConnectionLost)rrr�s   rr�z*XMPPComponentServerFactory.onAuthenticated�sJ���m�m�(�(�������[�"�-�
����&�&��(=�(=�q�+�r�	
rc�0�tj|d�y)NzStream Error)r�err)r�reasons  rr�z"XMPPComponentServerFactory.onError�s�������'rc�<�|jj||�yr)r�r�)rr�rr�s    rr�z+XMPPComponentServerFactory.onConnectionLost�s��������R�0rN)rF)
r4r5r6r7r�rr�r�r�r�r8rrr�r��s(����J��C�*
�(�1rr�N)"r7�zope.interfacer�twisted.applicationr�twisted.internetr�twisted.pythonr�twisted.words.protocols.jabberrrr	r
�"twisted.words.protocols.jabber.jidrr��twisted.words.xishrrBrrr;rrGrDr~r_rormr�r�r�r�r8rr�<module>r�s���
�'�'�"��O�O�?�%�/��
)�&�&�@?�I�$B�$B�?�8SR�9�#@�#@�SR�l
�W�
�
���g�o�o����BO*�W�)�)�O*�d	�D+�D+�NA1��!A�!A�A1r

Youez - 2016 - github.com/yon3zu
LinuXploit