403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/websockets/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/websockets/__pycache__/connection.cpython-311.pyc
�

�=Xcq\���ddlmZddlZddlZddlZddlmZmZmZm	Z	m
Z
ddlmZm
Z
mZmZmZmZddlmZddlmZmZmZmZmZmZmZmZmZddlmZm Z dd	l!m"Z"dd
lm#Z#m$Z$m%Z%gd�Z&e
ee efZ'	Gd�d
ej(��Z)e)j*Z*e)j+Z+Gd�dej(��Z,e,j-Z-e,j.Z.e,j/Z/e,j0Z0dZ1	Gd�d��Z2dS)�)�annotationsN)�	Generator�List�Optional�Type�Union�)�ConnectionClosed�ConnectionClosedError�ConnectionClosedOK�InvalidState�
PayloadTooBig�
ProtocolError)�	Extension)	�OK_CLOSE_CODES�	OP_BINARY�OP_CLOSE�OP_CONT�OP_PING�OP_PONG�OP_TEXT�Close�Frame)�Request�Response)�StreamReader)�
LoggerLike�Origin�Subprotocol)�
Connection�Side�State�SEND_EOFc�.�eZdZdZed��\ZZdS)r!z6A WebSocket connection is either a server or a client.�N)�__name__�
__module__�__qualname__�__doc__�range�SERVER�CLIENT���7/usr/lib/python3/dist-packages/websockets/connection.pyr!r!,s%������@�@��U�1�X�X�N�F�F�F�Fr.r!c�2�eZdZdZed��\ZZZZdS)r"z6A WebSocket connection is in one of these four states.�N)	r&r'r(r)r*�
CONNECTING�OPEN�CLOSING�CLOSEDr-r.r/r"r"6s*������@�@�(-��a���%�J��g�v�v�vr.r"r.c�4�eZdZdZeddfd6d�Zed7d���Zejd8d���Zed9d���Z	ed:d���Z
ed;d���Zd<d�Zd=d�Z
d>d�Zd?d>d�Zd?d>d�Zd@dAd$�Zd<d%�Zd<d&�ZdBdCd(�ZdDd*�ZdEd,�ZdFd-�ZdGd/�ZdGd0�ZdHd3�ZdHd4�Zd=d5�ZdS)Ir a5
    Sans-I/O implementation of a WebSocket connection.

    Args:
        side: :attr:`~Side.CLIENT` or :attr:`~Side.SERVER`.
        state: initial state of the WebSocket connection.
        max_size: maximum size of incoming messages in bytes;
            :obj:`None` to disable the limit.
        logger: logger for this connection; depending on ``side``,
            defaults to ``logging.getLogger("websockets.client")``
            or ``logging.getLogger("websockets.server")``;
            see the :doc:`logging guide <../topics/logging>` for details.

    iN�sider!�stater"�max_size�
Optional[int]�logger�Optional[LoggerLike]�return�Nonec�R�tj��|_	|�.tjd|j�������}||_	|�tj	��|_
||_||_||_
d|_d|_d|_g|_d|_d|_d|_d|_d|_	d|_t1��|_g|_g|_|���|_t=|j��d|_dS)Nzwebsockets.F) �uuid�uuid4�id�logging�	getLogger�name�lowerr;�isEnabledFor�DEBUG�debugr7r8r9�cur_size�expect_continuation_frame�origin�
extensions�subprotocol�
close_rcvd�
close_sent�close_rcvd_then_sent�
handshake_exc�eof_sentr�reader�events�writes�parse�parser�next�
parser_exc)�selfr7r8r9r;s     r/�__init__zConnection.__init__Vs��"�Z�\�\���B��>��&�'H�T�Y�_�_�5F�5F�'H�'H�I�I�F�"(���)��(�(���7�7��
���	���
�!��
�(,��
�*/��&�)-���+-���26���,0���+/���48��!�37���	���
�#�n�n���#%���#%����j�j�l�l����T�[����/3����r.c��|jS)zm
        WebSocket connection state.

        Defined in 4.1, 4.2, 7.1.3, and 7.1.4 of :rfc:`6455`.

        )�_state�r[s r/r8zConnection.state�s���{�r.c�b�|jr |j�d|j��||_dS)Nz= connection is %s)rIr;rEr^)r[r8s  r/r8zConnection.state�s3���:�	@��K���2�E�J�?�?�?�����r.c�L�|jturdS|j�dS|jjS)z�
        `WebSocket close code`_.

        .. _WebSocket close code:
            https://www.rfc-editor.org/rfc/rfc6455.html#section-7.1.5

        :obj:`None` if the connection isn't closed yet.

        N��)r8r5rO�coder_s r/�
close_codezConnection.close_code�s.���:�V�#�#��4�
�_�
$��4��?�'�'r.�
Optional[str]c�L�|jturdS|j�dS|jjS)z�
        `WebSocket close reason`_.

        .. _WebSocket close reason:
            https://www.rfc-editor.org/rfc/rfc6455.html#section-7.1.6

        :obj:`None` if the connection isn't closed yet.

        N�)r8r5rO�reasonr_s r/�close_reasonzConnection.close_reason�s.���:�V�#�#��4�
�_�
$��2��?�)�)r.r
c��|jtus
Jd���|j�5|j�.|jjt
vr|jjt
vrt}nt}||j|j|j��}|j	|_
|S)a�
        Exception to raise when trying to interact with a closed connection.

        Don't raise this exception while the connection :attr:`state`
        is :attr:`~websockets.connection.State.CLOSING`; wait until
        it's :attr:`~websockets.connection.State.CLOSED`.

        Indeed, the exception includes the close code and reason, which are
        known only once the connection is closed.

        Raises:
            AssertionError: if the connection isn't closed yet.

        zconnection isn't closed yet)r8r5rOrPrcrrrrQrZ�	__cause__)r[�exc_type�excs   r/�	close_exczConnection.close_exc�s��� �z�V�#�#�#�%B�#�#�#�
�O�'���+���$��6�6���$��6�6�)�H�H�,�H� (���O��O��%�!
�!
�����
��
r.�data�bytesc�b�|j�|��t|j��dS)aH
        Receive data from the network.

        After calling this method:

        - You must call :meth:`data_to_send` and send this data to the network.
        - You should call :meth:`events_received` and process resulting events.

        Raises:
            EOFError: if :meth:`receive_eof` was called earlier.

        N)rT�	feed_datarYrX�r[ros  r/�receive_datazConnection.receive_data�s0��	
����d�#�#�#��T�[�����r.c�`�|j���t|j��dS)aw
        Receive the end of the data stream from the network.

        After calling this method:

        - You must call :meth:`data_to_send` and send this data to the network.
        - You aren't expected to call :meth:`events_received`; it won't return
          any new events.

        Raises:
            EOFError: if :meth:`receive_eof` was called earlier.

        N)rT�feed_eofrYrXr_s r/�receive_eofzConnection.receive_eofs.��	
��������T�[�����r.�fin�boolc��|jstd���||_|�tt||����dS)a�
        Send a `Continuation frame`_.

        .. _Continuation frame:
            https://datatracker.ietf.org/doc/html/rfc6455#section-5.6

        Parameters:
            data: payload containing the same kind of data
                as the initial frame.
            fin: FIN bit; set it to :obj:`True` if this is the last frame
                of a fragmented message and to :obj:`False` otherwise.

        Raises:
            ProtocolError: if a fragmented message isn't in progress.

        �unexpected continuation frameN)rKr�
send_framerr�r[rorxs   r/�send_continuationzConnection.send_continuationsM��"�-�	A�� ?�@�@�@�-0���&�����g�t�S�1�1�2�2�2�2�2r.Tc��|jrtd���||_|�tt||����dS)a�
        Send a `Text frame`_.

        .. _Text frame:
            https://datatracker.ietf.org/doc/html/rfc6455#section-5.6

        Parameters:
            data: payload containing text encoded with UTF-8.
            fin: FIN bit; set it to :obj:`False` if this is the first frame of
                a fragmented message.

        Raises:
            ProtocolError: if a fragmented message is in progress.

        �expected a continuation frameN)rKrr|rrr}s   r/�	send_textzConnection.send_text,sM�� �)�	A�� ?�@�@�@�-0���&�����g�t�S�1�1�2�2�2�2�2r.c��|jrtd���||_|�tt||����dS)a�
        Send a `Binary frame`_.

        .. _Binary frame:
            https://datatracker.ietf.org/doc/html/rfc6455#section-5.6

        Parameters:
            data: payload containing arbitrary binary data.
            fin: FIN bit; set it to :obj:`False` if this is the first frame of
                a fragmented message.

        Raises:
            ProtocolError: if a fragmented message is in progress.

        r�N)rKrr|rrr}s   r/�send_binaryzConnection.send_binaryAsM�� �)�	A�� ?�@�@�@�-0���&�����i��s�3�3�4�4�4�4�4r.rgrcrh�strc�D�|jrtd���|�(|dkrtd���tdd��}d}n$t||��}|���}|�tt|����||_t|_	dS)a�
        Send a `Close frame`_.

        .. _Close frame:
            https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.1

        Parameters:
            code: close code.
            reason: close reason.

        Raises:
            ProtocolError: if a fragmented message is being sent, if the code
                isn't valid, or if a reason is provided without a code

        r�Nrgz#cannot send a reason without a codei�r.)
rKrr�	serializer|rrrPr4r8�r[rcrh�closeros     r/�
send_closezConnection.send_closeVs��� �)�	A�� ?�@�@�@��<���|�|�#�$I�J�J�J��$��O�O�E��D�D��$��'�'�E��?�?�$�$�D�	
����h��-�-�.�.�.������
�
�
r.c�V�|�tt|����dS)z�
        Send a `Ping frame`_.

        .. _Ping frame:
            https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.2

        Parameters:
            data: payload containing arbitrary binary data.

        N)r|rrrss  r/�	send_pingzConnection.send_pingv�&��	
����g�t�,�,�-�-�-�-�-r.c�V�|�tt|����dS)z�
        Send a `Pong frame`_.

        .. _Pong frame:
            https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.3

        Parameters:
            data: payload containing arbitrary binary data.

        N)r|rrrss  r/�	send_pongzConnection.send_pong�r�r.�intc��|jture|dkr_t||��}|���}|�tt|����||_t|_|j	tur|js|���|�
��|_t|j��dS)a?
        `Fail the WebSocket connection`_.

        .. _Fail the WebSocket connection:
            https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.7

        Parameters:
            code: close code
            reason: close reason

        Raises:
            ProtocolError: if the code isn't valid.
        rbN)r8r3rr�r|rrrPr4r7r+rS�send_eof�discardrXrYr�s     r/�failzConnection.fail�s���&�:�����t�|�|��d�F�+�+�����(�(������h�� 5� 5�6�6�6�"'���$��
��9����t�}���M�M�O�O�O��l�l�n�n����T�[�����r.�List[Event]c�$�|jgc}|_|S)a7
        Fetch events generated from data received from the network.

        Call this method immediately after any of the ``receive_*()`` methods.

        Process resulting events, likely by passing them to the application.

        Returns:
            List[Event]: Events read from the connection.
        )rU)r[rUs  r/�events_receivedzConnection.events_received�s��#�k�2������
r.�List[bytes]c�$�|jgc}|_|S)a�
        Obtain data to send to the network.

        Call this method immediately after any of the ``receive_*()``,
        ``send_*()``, or :meth:`fail` methods.

        Write resulting data to the connection.

        The empty bytestring :data:`~websockets.connection.SEND_EOF` signals
        the end of the data stream. When you receive it, half-close the TCP
        connection.

        Returns:
            List[bytes]: Data to write to the connection.

        )rV)r[rVs  r/�data_to_sendzConnection.data_to_send�s��"#�k�2������
r.c�0�|jtup|jduS)a�
        Tell if the TCP connection is expected to close soon.

        Call this method immediately after any of the ``receive_*()`` or
        :meth:`fail` methods.

        If it returns :obj:`True`, schedule closing the TCP connection after a
        short timeout if the other side hasn't already closed it.

        Returns:
            bool: Whether the TCP connection is expected to close soon.

        N)r8r4rRr_s r/�close_expectedzConnection.close_expected�s��,�z�W�$�F��(:�$�(F�Fr.�Generator[None, None, None]c#�K�		|j���Ed{V��r0|jr|j�d��t	d���|j�d}n|j�|j}n|j|jz
}tj|jj	|j
tu||j���Ed{V��}|jr|j�d|��|�
|����#t$r5}|�dt!|����||_Yd}~�nd}~wt$r4}|�dt!|����||_Yd}~n�d}~wt$$r6}|�d	|j�d
|j����||_Yd}~n�d}~wt*$r4}|�dt!|����||_Yd}~nRd}~wt,$rB}|j�dd�
��|�d��||_Yd}~nd}~wwxYwdV�t1d���)z�
        Parse incoming data into frames.

        :meth:`receive_data` and :meth:`receive_eof` run this generator
        coroutine until it needs more data or reaches EOF.

        TN�< EOFzunexpected end of stream)�maskr9rMz< %si�rbi�z
 at position i�z
parser failed)�exc_infoi�z"parse() shouldn't step after error)rT�at_eofrIr;�EOFErrorr9rJrrW�
read_exactr7r+rM�
recv_framerr�r�rZ�UnicodeDecodeErrorrh�startr�	Exception�error�AssertionError)r[r9�framerms    r/rWzConnection.parse�s�����5	"�
'�#�{�1�1�3�3�3�3�3�3�3�3�?��z�3���)�)�'�2�2�2�
#�#=�>�>�>��=�(�#�H�H��]�*�#�}�H�H�#�}�t�}�<�H�
$)�;��K�*���f�,�%�#��	$�$�$���������:�5��K�%�%�f�e�4�4�4�����&�&�&�=
'��@�	"�	"�	"��I�I�d�C��H�H�%�%�%�!�D�O�O�O�O�O�O������	"�	"�	"��I�I�d�C��H�H�%�%�%�!�D�O�O�O�O�O�O�����!�	"�	"�	"��I�I�d�s�z�C�C��	�C�C�D�D�D�!�D�O�O�O�O�O�O������	"�	"�	"��I�I�d�C��H�H�%�%�%�!�D�O�O�O�O�O�O������	"�	"�	"��K���o���=�=�=��I�I�d�O�O�O�!�D�O�O�O�O�O�O�����		"����	�����A�B�B�BsH�C)C-�-
H,�7*D'�'
H,�4*E#�#
H,�0,F!�!
H,�.*G�
H,�*8H'�'H,c#�K�|jtu|jksJ�|j���Ed{V��s8|j���|j���Ed{V���8|jr|j�d��|jtur|�	��t|_dV�td���)z�
        Discard incoming data.

        This coroutine replaces :meth:`parse`:

        - after receiving a close frame, during a normal closure (1.4);
        - after sending a close frame, during an abnormal closure (7.1.7).

        Nr�z"discard() shouldn't step after EOF)
r7r+rSrTr�r�rIr;r,r�r5r8r�r_s r/r�zConnection.discard=s������	�V�#���7�7�7�7�"�k�0�0�2�2�2�2�2�2�2�2�	"��K���!�!�!�#�k�0�0�2�2�2�2�2�2�2�2�	"��:�	'��K���g�&�&�&��9�����M�M�O�O�O���
�
�����A�B�B�Br.r�rc��|jtus|jturA|j�t	d���|jr	d|_�n�t
|j��|_�n�|jturJ|j�t	d���|jr	d|_�n�|xjt
|j��z
c_�nq|jtur1tt|j��}|�|���n2|jtur�n"|jtur�tj|j��|_|jt$ur|j�J�d|_|j�t	d���|jt*urL|�tt|j����|j|_d|_t$|_|jt.ur|���|���|_t7|j��nt9d|jd�����|j�|��dS)	z-
        Process an incoming frame.

        Nr�r{Fzincomplete fragmented messageTzunexpected opcode: �02x)�opcoderrrJrrx�lenrorrrrr|rrrWrOr8r4rPrQr3r7r+r�r�rXrYr�rU�append)r[r��
pong_frames   r/r�zConnection.recv_frame[s
��
�<�7�"�"�e�l�i�&?�&?��}�(�#�$C�D�D�D��y�
0� $��
�
� #�E�J����
�
�
�\�W�
$�
$��}�$�#�$C�D�D�D��y�
1� $��
�
��
�
��U�Z���0�
�
�
�
�\�W�
$�
$��w��
�3�3�J��O�O�J�'�'�'�'�
�\�W�
$�
$�
�
�\�X�
%�
%�$�k�%�*�5�5�D�O��z�W�$�$���2�2�2�,1��)��}�(�#�$C�D�D�D��z�T�!�!�
����h��
� ;� ;�<�<�<�"&�/���,0��)�$��
��y�F�"�"��
�
����
�,�,�.�.�D�K��������!�!I�u�|�!I�!I�!I�J�J�J�����5�!�!�!�!�!r.c� �|jturtd|jj�d����|jr|j�d|��|j�|�|j	tu|j�����dS)Nz#cannot write to a WebSocket in the z statez> %s)r�rM)r8r3r
rErIr;rVr�r�r7r,rM)r[r�s  r/r|zConnection.send_frame�s����:�T�!�!��M�d�j�o�M�M�M���
��:�	-��K���f�e�,�,�,������O�O���f�!4���O�Q�Q�	
�	
�	
�	
�	
r.c��|jrJ�d|_|jr|j�d��|j�t
��dS)NTz> EOF)rSrIr;rVr�r#r_s r/r�zConnection.send_eof�sS���=� � � ���
��:�	'��K���g�&�&�&�����8�$�$�$�$�$r.)
r7r!r8r"r9r:r;r<r=r>)r=r")r8r"r=r>)r=r:)r=re)r=r
)rorpr=r>)r=r>)rorprxryr=r>)T)Nrg)rcr:rhr�r=r>)rg)rcr�rhr�r=r>)r=r�)r=r�)r=ry)r=r�)r�rr=r>)r&r'r(r)r3r\�propertyr8�setterrdrirnrtrwr~r�r�r�r�r�r�r�r�r�rWr�r�r|r�r-r.r/r r Fsk������
�
�$�"'�'+�A4�A4�A4�A4�A4�F�����X���\�����\��
�(�(�(��X�(�"�*�*�*��X�*�"�!�!�!��X�!�J���� ����&3�3�3�3�,3�3�3�3�3�*5�5�5�5�5�*�����@.�.�.�.�.�.�.�.�'�'�'�'�'�V���� ����(G�G�G�G�4BC�BC�BC�BC�HC�C�C�C�<N"�N"�N"�N"�d

�

�

�

�%�%�%�%�%�%r.r )3�
__future__r�enumrCr@�typingrrrrr�
exceptionsr
rrr
rrrMr�framesrrrrrrrrr�http11rr�streamsrrrr�__all__�Event�IntEnumr!r+r,r"r2r3r4r5r#r r-r.r/�<module>r�sl��"�"�"�"�"�"�������������9�9�9�9�9�9�9�9�9�9�9�9�9�9�����������������"�!�!�!�!�!�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�&�%�%�%�%�%�%�%�!�!�!�!�!�!�3�3�3�3�3�3�3�3�3�3�����	�g�x��&�'��A������4�<����
���	
���1�1�1�1�1�D�L�1�1�1��
�
��z��
�-��	�����E�x	%�x	%�x	%�x	%�x	%�x	%�x	%�x	%�x	%�x	%r.

Youez - 2016 - github.com/yon3zu
LinuXploit