§
    3xÅj¸$  ã                   ód   — 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dS )	z&
Implementation of an SSH2 "message".
é    N)ÚBytesIO)Úutil)Úmax_byteÚone_byteÚ	zero_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!dS )"Ú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                 ó\   — |�t          |¦  «        | _        dS t          ¦   «         | _        dS )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     úAC:\Projects\Historical\venv\Lib\site-packages\paramiko/message.pyÚ__init__zMessage.__init__,   s,   € ð ÐÝ! 'Ñ*Ô*ˆDŒKˆKˆKå!™)œ)ˆDŒKˆKˆKó    c                 ó*   — |                       ¦   «         S ©N)Úasbytes©r   s    r   Ú	__bytes__zMessage.__bytes__9   s   € Ø�|Š|‰~Œ~Ðr   c                 óZ   — dt          | 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ÑAÀCÑGÐGr   c                 ó4   — | 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                              d¦  «         dS )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                              |¦  «         |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   sF   € ð
 ”;×#Ò#Ñ%Ô%ˆØ”K×$Ò$Ñ&Ô&ˆ	ØŒ×Ò˜Ñ"Ô"Ð"ØÐr   c                 ó�   — | 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   s:   € ð ”;×#Ò#Ñ%Ô%ˆØ�Š‰ŒˆØŒ{×Ò Ñ)Ô)Ð)r   c                 ó²   — | j                              |¦  «        }d}t          |¦  «        |cxk     r|k     r n n|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   se   € ð ŒK×Ò˜QÑÔˆØˆÝˆq‰6Œ6�AÐ$Ð$Ò$Ð$˜Ò$Ð$Ð$Ð$Ð$Ø•y A­¨A©¬¡JÑ/Ñ/Ð/Øˆr   c                 ó,   — |                       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                 óB   — |                       d¦  «        }|t          k    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                 óô   — |                       d¦  «        }|t          k    r&t          j        |                      ¦   «         ¦  «        S ||                       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ƒ   sh   € ð �~Š~˜aÑ Ô ˆØ•8ÒÐÝÔ$ T§_¢_Ñ%6Ô%6Ñ7Ô7Ð7Ø�—’˜qÑ!Ô!Ñ!ˆÝŒ}˜T 4Ñ(Ô(¨Ô+Ð+r   c                 ó^   — t          j        d|                      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Ô#4Ñ5Ô5°aÔ8Ð8r   c                 ó^   — t          j        d|                      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Ô#4Ñ5Ô5°aÔ8Ð8r   c                 óN   — t          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Ô!2Ñ3Ô3Ð3r   c                 óP   — |                       |                      ¦   «         ¦  «        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œnÑ-Ô-Ð-r   c                 óD   — t          |                      ¦   «         ¦  «        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                 óP   — |                       |                      ¦   «         ¦  «        S )z@
        Alias for `get_string` (obtains a bytestring).
        rH   r   s    r   r8   zMessage.get_binaryº   s   € ð �~Š~˜dŸlšl™nœnÑ-Ô-Ð-r   c                 óP   — |                       ¦   «                              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                              |¦  «         | 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                              |¦  «         | 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                              t          ¦  «         n| 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Ú   s@   € ð ð 	)ØŒK×Ò�hÑ'Ô'Ð'Ð'àŒK×Ò�iÑ(Ô(Ð(Øˆr   c                 ó`   — | 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    rG| j                             t          ¦  «         |                      t          j        |¦  «        ¦  «         n-| 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ï   sn   € ð •”ÒÐØŒK×Ò�hÑ'Ô'Ð'Ø�OŠO�DÔ-¨aÑ0Ô0Ñ1Ô1Ð1Ð1àŒK×Ò�fœk¨$°Ñ2Ô2Ñ3Ô3Ð3Øˆr   c                 ó`   — | 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                 óT   — |                       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        |¦  «        }|                      t          |¦  «        ¦  «         | 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  sD   € õ ŒL˜‰OŒOˆØ�Š•S˜‘V”VÑÔÐØŒ×Ò˜!ÑÔÐØˆr   c                 óV   — |                       d                     |¦  «        ¦  «         | 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|                      |¦  «        S t          |t          ¦  «        r|                      |¦  «        S t          |¦  «        t          u r|                      |¦  «        S |                      |¦  «        S r   )	ÚtypeÚboolrY   Ú
isinstanceÚintre   Úlistrp   rc   )r   Úis     r   Ú_addzMessage._add'  s~   € Ý�‰7Œ7•dˆ?ˆ?Ø×#Ò# AÑ&Ô&Ð&Ý˜�3ÑÔð 	&Ø×(Ò(¨Ñ+Ô+Ð+Ý�!‰WŒW�ˆ_ˆ_Ø—=’= Ñ#Ô#Ð#à—?’? 1Ñ%Ô%Ð%r   c                 ó:   — |D ]}|                       |¦  «         ŒdS )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ŒOˆOˆ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ð Hð Hð&ð &ð &ðð ð ðð ð ð*ð *ð *ðð ð ð	!ð 	!ð 	!ðð ð ð
,ð 
,ð 
,ð9ð 9ð 9ð9ð 9ð 9ð4ð 4ð 4ð.ð .ð .ð$ð $ð $ð.ð .ð .ð*ð *ð *ðð ð ðð ð ð
ð 
ð 
ðð ð ðð ð ðð ð ðð ð ð	ð 	ð 	ð	ð 	ð 	ð&ð &ð &ðð ð ð ð r   r
   )r€   r9   Úior   Úparamikor   Úparamiko.commonr   r   r   Úparamiko.utilr   r
   r�   r   r   ú<module>r†      sª   ðð&ð ð €€€Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø Ð Ð Ð Ð Ð ð_ð _ð _ð _ð _ñ _ô _ð _ð _ð _r   