Ë
    zñ�j…$  ã                   ó\   — d Z ddlZddlmZ ddlmZ ddlmZmZm	Z	 ddl
mZ  G d„ d«      Zy)	z&
Implementation of an SSH2 "message".
é    N)ÚBytesIO)Úutil)Ú	zero_byteÚmax_byteÚone_byte)Úuc                   óÄ   — e Zd ZdZdZd!d„Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d „ Z!y)"ÚMessagea~  
    An SSH2 message is a stream of bytes that encodes some combination of
    strings, integers, bools, and infinite-precision integers.  This class
    builds or breaks down such a byte stream.

    Normally you don't need to deal with anything this low-level, but it's
    exposed for people implementing custom extensions, or features that
    paramiko doesn't support yet.
    l      ~ Nc                 óH   — |�t        |«      | _        yt        «       | _        y)z¾
        Create a new SSH2 message.

        :param bytes content:
            the byte stream to use as the message content (passed in only when
            decomposing a message).
        N)r   Úpacket)ÚselfÚcontents     úQ/var/www/api.ozpay.ru/ozpay/venv/lib/python3.12/site-packages/paramiko/message.pyÚ__init__zMessage.__init__,   s   € ð ÐÜ! 'Ó*ˆD�Kä!›)ˆD�Kó    c                 ó"   — | j                  «       S ©N)Úasbytes©r   s    r   Ú	__bytes__zMessage.__bytes__9   s   € Ø�|‰|‹~Ðr   c                 óT   — dt        | j                  j                  «       «      z   dz   S )zP
        Returns a string representation of this object, for debugging.
        zparamiko.Message(ú))Úreprr   Úgetvaluer   s    r   Ú__repr__zMessage.__repr__<   s&   € ð #¤T¨$¯+©+×*>Ñ*>Ó*@Ó%AÑAÀCÑGÐGr   c                 ó6   — | j                   j                  «       S )zO
        Return the byte stream content of this Message, as a `bytes`.
        )r   r   r   s    r   r   zMessage.asbytesC   s   € ð �{‰{×#Ñ#Ó%Ð%r   c                 ó:   — | j                   j                  d«       y)zk
        Rewind the message to the beginning as if no items had been parsed
        out of it yet.
        r   N)r   Úseekr   s    r   ÚrewindzMessage.rewindI   s   € ð
 	�‰×Ñ˜Õr   c                 ó¤   — | j                   j                  «       }| j                   j                  «       }| j                   j                  |«       |S )zk
        Return the `bytes` of this message that haven't already been parsed and
        returned.
        )r   ÚtellÚreadr   )r   ÚpositionÚ	remainders      r   Úget_remainderzMessage.get_remainderP   s@   € ð
 —;‘;×#Ñ#Ó%ˆØ—K‘K×$Ñ$Ó&ˆ	Ø�‰×Ñ˜Ô"ØÐr   c                 óŒ   — | j                   j                  «       }| j                  «        | j                   j                  |«      S )zà
        Returns the `bytes` of this message that have been parsed and
        returned. The string passed into a message's constructor can be
        regenerated by concatenating ``get_so_far`` and `get_remainder`.
        )r   r!   r   r"   )r   r#   s     r   Ú
get_so_farzMessage.get_so_farZ   s4   € ð —;‘;×#Ñ#Ó%ˆØ�‰ŒØ�{‰{×Ñ Ó)Ð)r   c                 ó    — | j                   j                  |«      }d}t        |«      |cxk  r|k  rn |S |t        |t        |«      z
  z  z   S |S )a	  
        Return the next ``n`` bytes of the message, without decomposing into an
        int, decoded string, etc.  Just the raw bytes are returned. Returns a
        string of ``n`` zero bytes if there weren't ``n`` bytes remaining in
        the message.
        i   )r   r"   Úlenr   )r   ÚnÚbÚmax_pad_sizes       r   Ú	get_byteszMessage.get_bytesd   sR   € ð �K‰K×Ñ˜QÓˆØˆÜˆq‹6�AÔ$˜Ô$àˆð ”y A¬¨A«¡JÑ/Ñ/Ð/Øˆr   c                 ó$   — | j                  d«      S )a  
        Return the next byte of the message, without decomposing it.  This
        is equivalent to `get_bytes(1) <get_bytes>`.

        :return:
            the next (`bytes`) byte of the message, or ``b' '`` if there
            aren't any bytes remaining.
        é   )r-   r   s    r   Úget_bytezMessage.get_byteq   s   € ð �~‰~˜aÓ Ð r   c                 ó6   — | j                  d«      }|t        k7  S )z2
        Fetch a boolean from the stream.
        r/   )r-   r   ©r   r+   s     r   Úget_booleanzMessage.get_boolean|   s   € ð �N‰N˜1ÓˆØ”I‰~Ðr   c                 óÖ   — | j                  d«      }|t        k(  r#t        j                  | j	                  «       «      S || j                  d«      z  }t        j                  d|«      d   S )zZ
        Fetch an int from the stream.

        :return: a 32-bit unsigned `int`.
        r/   é   ú>Ir   )r-   r   r   Úinflate_longÚ
get_binaryÚstructÚunpack)r   Úbytes     r   Úget_adaptive_intzMessage.get_adaptive_intƒ   s[   € ð �~‰~˜aÓ ˆØ”8ÒÜ×$Ñ$ T§_¡_Ó%6Ó7Ð7Ø�—‘˜qÓ!Ñ!ˆÜ�}‰}˜T 4Ó(¨Ñ+Ð+r   c                 óR   — t        j                  d| j                  d«      «      d   S )z/
        Fetch an int from the stream.
        r6   é   r   ©r9   r:   r-   r   s    r   Úget_intzMessage.get_int�   s#   € ô �}‰}˜T 4§>¡>°!Ó#4Ó5°aÑ8Ð8r   c                 óR   — t        j                  d| j                  d«      «      d   S )zj
        Fetch a 64-bit int from the stream.

        :return: a 64-bit unsigned integer (`int`).
        ú>Qé   r   r?   r   s    r   Ú	get_int64zMessage.get_int64•   s#   € ô �}‰}˜T 4§>¡>°!Ó#4Ó5°aÑ8Ð8r   c                 óH   — t        j                  | j                  «       «      S )zr
        Fetch a long int (mpint) from the stream.

        :return: an arbitrary-length integer (`int`).
        )r   r7   r8   r   s    r   Ú	get_mpintzMessage.get_mpint�   s   € ô × Ñ  §¡Ó!2Ó3Ð3r   c                 ó@   — | j                  | j                  «       «      S )zà
        Fetch a "string" from the stream.  This will actually be a `bytes`
        object, and may contain unprintable characters.  (It's not unheard of
        for a string to contain another byte-stream message.)
        ©r-   r@   r   s    r   Ú
get_stringzMessage.get_string§   s   € ð �~‰~˜dŸl™l›nÓ-Ð-r   c                 ó4   — t        | j                  «       «      S )zš
        Fetch a Unicode string from the stream.

        This currently operates by attempting to encode the next "string" as
        ``utf-8``.
        )r   rI   r   s    r   Úget_textzMessage.get_text±   s   € ô �—‘Ó"Ó#Ð#r   c                 ó@   — | j                  | j                  «       «      S )z@
        Alias for `get_string` (obtains a bytestring).
        rH   r   s    r   r8   zMessage.get_binaryº   s   € ð �~‰~˜dŸl™l›nÓ-Ð-r   c                 ó@   — | j                  «       j                  d«      S )zŽ
        Fetch a list of `strings <str>` from the stream.

        These are trivially encoded as comma-separated values in a string.
        ú,)rK   Úsplitr   s    r   Úget_listzMessage.get_listÀ   s   € ð �}‰}‹×$Ñ$ SÓ)Ð)r   c                 ó<   — | j                   j                  |«       | S )zj
        Write bytes to the stream, without any formatting.

        :param bytes b: bytes to add
        ©r   Úwriter2   s     r   Ú	add_byteszMessage.add_bytesÈ   ó   € ð 	�‰×Ñ˜!ÔØˆr   c                 ó<   — | j                   j                  |«       | S )zq
        Write a single byte to the stream, without any formatting.

        :param bytes b: byte to add
        rR   r2   s     r   Úadd_bytezMessage.add_byteÑ   rU   r   c                 óŠ   — |r!| j                   j                  t        «       | S | j                   j                  t        «       | S )za
        Add a boolean value to the stream.

        :param bool b: boolean value to add
        )r   rS   r   r   r2   s     r   Úadd_booleanzMessage.add_booleanÚ   s9   € ñ Ø�K‰K×ÑœhÔ'ð ˆð �K‰K×ÑœiÔ(Øˆr   c                 ód   — | j                   j                  t        j                  d|«      «       | S ©zU
        Add an integer to the stream.

        :param int n: integer to add
        r6   ©r   rS   r9   Úpack©r   r*   s     r   Úadd_intzMessage.add_intæ   ó&   € ð 	�‰×Ñœ&Ÿ+™+ d¨AÓ.Ô/Øˆr   c                 ó  — |t         j                  k\  rE| j                  j                  t        «       | j                  t        j                  |«      «       | S | j                  j                  t        j                  d|«      «       | S r[   )
r
   Úbig_intr   rS   r   Ú
add_stringr   Údeflate_longr9   r]   r^   s     r   Úadd_adaptive_intzMessage.add_adaptive_intï   sd   € ð ”—‘ÒØ�K‰K×ÑœhÔ'Ø�O‰OœD×-Ñ-¨aÓ0Ô1ð ˆð �K‰K×ÑœfŸk™k¨$°Ó2Ô3Øˆr   c                 ód   — | j                   j                  t        j                  d|«      «       | S )zX
        Add a 64-bit int to the stream.

        :param int n: long int to add
        rB   r\   r^   s     r   Ú	add_int64zMessage.add_int64ü   r`   r   c                 óN   — | j                  t        j                  |«      «       | S )zµ
        Add a long int to the stream, encoded as an infinite-precision
        integer.  This method only works on positive numbers.

        :param int z: long int to add
        )rc   r   rd   )r   Úzs     r   Ú	add_mpintzMessage.add_mpint  s    € ð 	�‰œ×)Ñ)¨!Ó,Ô-Øˆr   c                 óš   — t        j                  |«      }| j                  t        |«      «       | j                  j                  |«       | S )z[
        Add a bytestring to the stream.

        :param byte s: bytestring to add
        )r   r   r_   r)   r   rS   )r   Úss     r   rc   zMessage.add_string  s8   € ô �L‰L˜‹OˆØ�‰”S˜“VÔØ�‰×Ñ˜!ÔØˆr   c                 óF   — | j                  dj                  |«      «       | S )zé
        Add a list of strings to the stream.  They are encoded identically to
        a single string of values separated by commas.  (Yes, really, that's
        how SSH2 does it.)

        :param l: list of strings to add
        rN   )rc   Újoin)r   Úls     r   Úadd_listzMessage.add_list  s   € ð 	�‰˜Ÿ™ ›Ô$Øˆr   c                 óî   — t        |«      t        u r| j                  |«      S t        |t        «      r| j                  |«      S t        |«      t        u r| j                  |«      S | j                  |«      S r   )	ÚtypeÚboolrY   Ú
isinstanceÚintre   Úlistrp   rc   )r   Úis     r   Ú_addzMessage._add'  sb   € Ü�‹7”d‰?Ø×#Ñ# AÓ&Ð&Ü˜œ3ÔØ×(Ñ(¨Ó+Ð+Ü�!‹Wœ‰_Ø—=‘= Ó#Ð#à—?‘? 1Ó%Ð%r   c                 ó4   — |D ]  }| j                  |«       Œ y)a  
        Add a sequence of items to the stream.  The values are encoded based
        on their type: bytes, str, int, bool, or list.

        .. warning::
            Longs are encoded non-deterministically.  Don't use this method.

        :param seq: the sequence of items
        N)rx   )r   ÚseqÚitems      r   ÚaddzMessage.add3  s   € ð ò 	ˆDØ�I‰I�d�Oñ	r   r   )"Ú__name__Ú
__module__Ú__qualname__Ú__doc__rb   r   r   r   r   r   r%   r'   r-   r0   r3   r<   r@   rD   rF   rI   rK   r8   rP   rT   rW   rY   r_   re   rg   rj   rc   rp   rx   r|   © r   r   r
   r
      s    „ ñð €Gó$òòHò&òòò*òò	!òò
,ò9ò9ò4ò.ò$ò.ò*òòò
òòòòò	ò	ò&ór   r
   )r€   r9   Úior   Úparamikor   Úparamiko.commonr   r   r   Úparamiko.utilr   r
   r�   r   r   ú<module>r†      s*   ðñ&ó Ý å ß 9Ñ 9Ý ÷_ò _r   