403Webshell
Server IP : 74.208.236.52  /  Your IP : 216.73.217.98
Web Server : Apache
System : Linux infong527 4.4.400-icpu-115 #2 SMP Mon Jul 6 08:15:05 UTC 2026 x86_64
User : u44043973 ( 5404757)
PHP Version : 8.4.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/mercurial/__pycache__/wireprotoframing.cpython-313.pyc
�

6�h�����%SSKJr SSKrSSKrSSKrSSKrSSKJrJr SSKJ	r	 SSK
Jr \R(aSSKrSSK
JrJrJrJrJr SSKJrJr \R(aSS	KJr \\\\\\44rS
rSrSrSrS
r \\\ S.r!S\"S'Sr#Sr$Sr%Sr&Sr'Sr(S
r)Sr*\#\$\%\&\'\(\)\*S.r+S\"S'Sr,Sr-S
r.S
r/\,\-\.\/S.r0S\"S'Sr1Sr2\1\2S.r3S\"S'Sr4Sr5\4\5S.r6S\"S'Sr7Sr8\7\8S.r9S\"S'Sr:Sr;\:\;S.r<S\"S'\#\0\$\3\%\6\&0\'0\(0\)\9\*\<0r=S\"S '\R|"S!5r?SbS"jr@\R�"S#S$9"S%S&55rB\R�"S#S'S(9"S)S*55rCScS+jrDSdS,jrESeS-jrFSfS.jrGS\S4SgS0jjrHShS2jrI\4SiS3jjrJSjS4jrKSkSlS5jjrLSmS6jrM\4SgS7jjrN"S8S95rO"S:S;\5rP"S<S=\5rQ"S>S?\P5rR"S@SA\Q5rS"SBSC\P5rT"SDSE\Q5rU"SFSG\P5rV"SHSI\V5rW"SJSK\Q5rX"SLSM\X5rY\R(a\\R\T-\W-rZ\\S\U-\Y-r[0r\SN\"SO'/r]SP\"SQ'SnSRjr^"SSS/5r_"STSU\_5r`"SVS1\_5raSoSWjrbSXSY/0rcSZ\"S['"S\S]5rd"S^S_5re"S`Sa5rfg)p�)�annotationsN)�Protocol�Type�)�_)�attr)�encoding�error�pycompat�util�wireprototypes)�cborutil�
stringutil)�Iterator�i���)sstream-begins
stream-endsencoded�dict[bytes, int]�STREAM_FLAGS�����	)scommand-requestscommand-datascommand-responseserror-responsestext-outputsprogressssender-protocol-settingssstream-settings�FRAME_TYPES)snew�continuationsmores	have-data�FLAGS_COMMAND_REQUEST)r�eos�FLAGS_COMMAND_DATA�FLAGS_COMMAND_RESPONSE�FLAGS_SENDER_PROTOCOL_SETTINGS�FLAGS_STREAM_ENCODING_SETTINGSzdict[int, dict[bytes, int]]�FRAME_TYPE_FLAGSz<HHc��UR5VVs0sHup#X2_M	 nnn/nSnX:�a9X-(a$URURUSU-55 US-nX:�aM9SRU5$s snnf)zFConvert a numeric flags value to a human value, using a mapping table.r�<unknown 0x%02x>�|)�items�append�get�join)�mapping�value�k�v�namemap�flags�vals       �</usr/lib/python3/dist-packages/mercurial/wireprotoframing.py�
humanflagsr3�sw�� '�
�
��0����q�t��G�0��E�
�C�
�,��;��L�L����S�*=��*C�D�E���	���,�
�9�9�U����1s�A8T)�slotsc���\rSrSrSr\R"\S9r\R"\S9r	\R"\S9r
\R"\S9r\R"\S9r\R"\S9r
Srg)�frameheader�z&Represents the data in a frame header.��type�N)�__name__�
__module__�__qualname__�__firstlineno__�__doc__r�ib�int�length�	requestid�streamid�streamflags�typeidr0�__static_attributes__r:�r2r6r6�sY��0�
�W�W�#�
�F����S�!�I��w�w�C� �H��'�'�s�#�K�
�W�W�#�
�F��G�G���ErHr6F)r4�reprc��\rSrSrSr\R"\S9r\R"\S9r	\R"\S9r
\R"\S9r\R"\S9r\R"\
S9r\R S5rSrg)�frame�zRepresents a parsed frame.r8c�x�SUR-n[R5Hup#X0R:XdMUn O S[UR5UR
UR[[UR5U[[RUR05UR54-$)Nr%sHframe(size=%d; request=%d; stream=%d; streamflags=%s; type=%s; flags=%s))
rFrr'�len�payloadrCrDr3rrEr#r)r0)�self�typename�namer,s    r2�__repr__�frame.__repr__�s���&����4��&�,�,�.�K�D����#����/�
"��D�L�L�!�����
�
��<��)9�)9�:���+�/�/����R�@�$�*�*�M�
�	
�	
rHr:N)r;r<r=r>r?rr@rArCrDrErFr0�bytesrOr	�	strmethodrSrGr:rHr2rKrK�sq��$����S�!�I��w�w�C� �H��'�'�s�#�K�
�W�W�#�
�F��G�G���E��g�g�5�!�G�
���
��
rHrKc���[[[U5-5n[R"S[U55nUSSUSS&[R
"SUSXU5 US-U-US'XVSS&U$)	z#Assemble a frame into a byte array.z<Irr�<HBBrrrN)�	bytearray�FRAME_HEADER_SIZErN�struct�pack�	pack_into)rCrDrErFr0rOrK�ls        r2�	makeframer_�su��
�'�#�g�,�6�7�E�	���D�#�g�,�'�A��1�Q��E�!�A�J�
���V�U�A�y�K�H��!��u�$�E�!�H��!�"�I��LrHc	��URSS5nUup#pEpg[U5n[U5nSnURS5H)n	U	[;aU[U	-nMU[U	5-nM+ U[;a
[UnO[U5nSn
[UnURS5Hn	X�;a	X�U	-n
MU
[U	5-n
M! URS5(a=SR
[R"[R"USS555nO[R"U5n[UUUUU
US9$)	a�Create a frame from a human readable string

Strings have the form:

    <request-id> <stream-id> <stream-flags> <type> <flags> <payload>

This can be used by user-facing applications and tests for creating
frames easily without having to type out a bunch of constants.

Request ID and stream IDs are integers.

Stream flags, frame type, and flags can be specified by integer or
named constant.

Flags can be delimited by `|` to bitwise OR them together.

If the payload begins with ``cbor:``, the following string will be
evaluated as Python literal and the resulting object will be fed into
a CBOR encoder. Otherwise, the payload is interpreted as a Python
byte string literal.
� rrr&scbor:rHN)rCrDrErFr0rO)
�splitrArrr#�
startswithr*r�streamencoder�evalpythonliteral�unescapestrr_)�s�fieldsrCrDrE�	frametype�
frameflagsrO�finalstreamflags�flag�
finalflags�
validflagss            r2�makeframefromhumanstringro�sG��,�W�W�T�1�
�F�GM�D�I����I��I��8�}�H����!�!�$�'���<����T� 2�2����D�	�)��	(��K���	�*�	��	�N�	��J�!�)�,�J�� � ��&�����T�*�*�J��#�d�)�#�J�	'����(�#�#��(�(��!�!�*�">�">�w�q�r�{�"K�L�
��
�(�(��1�����$����
�rHc��USSUS--SUS--n[R"SUS5up#nUSnUS	-S
-	nUS-n[XX4Xg5$)z�Parse a unified framing protocol frame header from a buffer.

The header is expected to be in the buffer at offset 0 and the
buffer is expected to be large enough to hold a full header.
r�ri@rrXrr��r�)r[�unpack_fromr6)�data�framelengthrCrDrE�	typeflagsrirjs        r2�parseheaderrx'sv���q�'�C�$�q�'�M�)�E�D��G�O�;�K�'-�'9�'9�&�$��'J�$�I���Q��I��T�!�a�'�I��T�!�J����y��rHc��[[5nURU5nUS:XagU[:wa#[R"[S5X!4-5e[
U5nURUR5n[U5UR:wa7[R"[S5UR[U54-5e[URURURURURU5$)z�Read a unified framing protocol frame from a file object.

Returns a 3-tuple of (type, flags, payload) for the decoded frame or
None if no frame is available. May raise if a malformed frame is
seen.
rNs+received incomplete frame: got %d bytes: %ss'frame length error: expected %d; got %d)rYrZ�readintor
�Abortrrx�readrBrNrKrCrDrErFr0)�fh�header�	readcount�hrOs     r2�	readframer�@s����(�
)�F����F�#�I��A�~���%�%��k�k�
�<�=��!�
"�
�	
�
	�F��A��g�g�a�h�h��G�
�7�|�q�x�x���k�k�
�8�9��x�x��W��&�
'�
�	
�
�	���Q�Z�Z�������!�'�'�7��rH�streamc#�# �SU0nU(aX7S'U(aXgS'SR[R"U55nSnSn	U(d
U	[-n	O	U	[-n	U(a	U	[
-n	XxX�-n
U[
U
5-
n[
U
5U:XaU[
U5:a	U	[-n	URU[U	U
S9v� U	[-(dOM�U(asUR[5nSn[
U5[:Xa[n	O[n	URS	5S:XdeSnURU[U	US9v� U(ag
Mrg
7f)z�Create frames necessary to transmit a request to run a command.

This is a generator of bytearrays. Each item represents a frame
ready to be sent over the wire to a peer.
�name�args�redirectrHrT�rCrFr0rOFrN)r*rrd�FLAG_COMMAND_REQUEST_NEW�!FLAG_COMMAND_REQUEST_CONTINUATION� FLAG_COMMAND_REQUEST_EXPECT_DATArN� FLAG_COMMAND_REQUEST_MORE_FRAMESr_�FRAME_TYPE_COMMAND_REQUESTr|�DEFAULT_MAX_FRAME_SIZE�FLAG_COMMAND_DATA_CONTINUATION�FLAG_COMMAND_DATA_EOS�FRAME_TYPE_COMMAND_DATA)r�rC�cmd�args�datafh�maxframesize�redirectru�offsetr0rO�dones            r2�createcommandframesr�bsn���
�S�>�D���W�
��$�[���8�8�H�)�)�$�/�0�D�
�F�
�����-�-�E��6�6�E���5�5�E��� 5�6���#�g�,����w�<�<�'�F�S��Y�,>��5�5�E�����-���	�
�	
��8�8��7�:���;�;�5�6�D��D��4�y�2�2�6��-���{�{�1�~��,�,�,����"�"�#�.���	#��
���'��s�EE�outputstreamc���SR[R"SS055nUR(aUR	U5nSnU(dgOSnURU[[UUS9$)NrH�statussokTF�rCrFr0rO�encoded)r*rrd�streamsettingssent�encoder_�FRAME_TYPE_COMMAND_RESPONSE�"FLAG_COMMAND_RESPONSE_CONTINUATION)r�rC�overallr�s    r2�createcommandresponseokframer��sw���h�h�x�,�,�i��-?�@�A�G�
� � ��-�-��(�������������*�0�����rHc#��# �UR5nSnX4XB-nU[U5-
nU[U5:HnU(a[nO[nUR	U[
UUUS:gS9v� U(agM\7f)zACreate an empty payload frame representing command end-of-stream.rrHr�N)�flushrN�FLAG_COMMAND_RESPONSE_EOSr�r_r�)r�rCr�rOr��chunkr�r0s        r2�createcommandresponseeosframesr��s�����l�l�n�G�
�F�
���!6�7���#�e�*�����W��%���-�E�6�E�����.����s�N��
�	
���)�s�A0A2c�p�SURURS.S.nSH.n[X$5nUcMXSS[R"U5'M0 SR[R"U55nUR(aURU5nSnOSnURU[[UUS	9$)
Nr�)surls	mediatype)r��location)�size�
fullhashes�fullhashseed�serverdercerts�servercadercertsr�rHTFr�)
�url�	mediatype�getattrr�bytestrr*rrdr�r�r_r�r�)r�rC�locationru�ar,rOr�s        r2�$createalternatelocationresponseframer��s�����L�L�"�,�,�
��D�����$����5:���h�.�.�q�1�2���h�h�x�,�,�T�2�3�G�
� � ��-�-��(����������*�0�����rHc#�# �SSU0S.nU(aX4SS'SR[R"U55nURU[[
US9v� g7f)N�error�message)r�r�r�rHr�)r*rrdr_r�r�)r�rC�messager��mr�s      r2�createcommanderrorresponser�si������
�	�A��#�(��G���h�h�x�,�,�Q�/�0�G�
�
�
��*�'��	���s�AAc#�# �[U5[::deSR[R"USU0/S.55nURU[SUS9v� g7f)NrH�msg)�typer�rr�)rNr�r*rrdr_�FRAME_TYPE_ERROR_RESPONSE)r�rC�msg�errtyperOs     r2�createerrorframer�(sm����s�8�-�-�-�-��h�h���� �$�c�]�O�
�	
��G��
�
��(���	���s�AAc#�*# �/nUGH%upVn[U[5(d[S5eUH#n[U[5(aM[S5e UH#n	[U	[5(aM[S5e URSS5R	S5nUV
s/sH#o�RSS5R	S5PM% nn
UVs/sH#o�RSS5R	S5PM% nnSU0nU(aXlS	'U(aX|S
'URU5 GM( SR
[R"U55n
[U
5U:�a[S5eURU[S
U
S9v� gs sn
fs snf7f)arCreate a text output frame to render text to people.

``atoms`` is a 3-tuple of (formatting string, args, labels).

The formatting string contains ``%s`` tokens to be replaced by the
corresponding indexed entry in ``args``. ``labels`` is an iterable of
formatters to be applied at rendering time. In terms of the ``ui``
class, each atom corresponds to a ``ui.write()``.
s!must use bytes formatting stringssmust use bytes for argumentssmust use bytes for labels�ascii�replacezutf-8�strictr�r�slabelsrHs$cannot encode data in a single framerr�N)�
isinstancerU�
ValueError�decoder�r(r*rrdrNr_�FRAME_TYPE_TEXT_OUTPUT)r�rC�atomsr��	atomdicts�
formattingr��labels�arg�labelr�r^�atomrOs              r2�createtextoutputframer�?s�����I�$)� �
�&��*�e�,�,��A�B�B��C��c�5�)�)� �!@�A�A���E��e�U�+�+� �!=�>�>��
 �&�&�w�	�:�A�A�'�J�
�GK�K�d�����)�,�3�3�G�<�d��K�HN�N�v�!�(�(�7�H�-�4�4�W�=�v��N��
�#��� ��M��$��O������7%*�:�h�h�x�,�,�Y�7�8�G�
�7�|�l�"��@�A�A�
�
�
��%���	����%L��O�s+�AF�
%F�32F�%*F	�F�*F�?BFc�>�\rSrSrSr\4SSjjrSrSrSr	g)	�bufferingcommandresponseemitteriza�Helper object to emit command response frames intelligently.

Raw command response data is likely emitted in chunks much smaller
than what can fit in a single frame. This class exists to buffer
chunks until enough data is available to fit in a single frame.

TODO we'll need something like this when compression is supported.
So it might make sense to implement this functionality at the stream
level.
c�D�XlX lX0l/UlSUlg�Nr)�_stream�
_requestid�_maxsize�_chunks�_chunkssize)rPr�rCr�s    r2�__init__�(bufferingcommandresponseemitter.__init__�s"����#��$�
������rHc#�
# �UcUR5Shv�N gURRU5nU(dg[U5UR:�a|UR5Shv�N SnXX R-nU[U5-
nURRUR[[USS9v� U[U5:XagMa[U5UR-UR:a:URRU5 U=R[U5-
sl	gUR5Shv�N URRU5 [U5Ul	gGNbGNN67f)z�Send new data for emission.

Is a generator of new frames that were derived from the new input.

If the special input ``None`` is received, flushes all buffered
data to frames.
NrT�rFr0rOr�)�_flushr�r�rNr�r_r�r�r�r�r�r()rPrur�r�s    r2�send�$bufferingcommandresponseemitter.send�sM����<��{�{�}�$�$���|�|�"�"�4�(�����t�9�t�}�}�$��{�{�}�$�$��F���f�}�}�&<�=���#�e�*�$���l�l�,�,��O�O�6�<�!� �-����S��Y�&���"�t�9�t�'�'�'�$�-�-�7��L�L����%�����D�	�)���
�;�;�=� � ������D�!��t�9���k
%�*
%�:	!�s5�F�E;�AF�.E>�/CF�
F�1F�>F�Fc#�# �SRUR5n[U5UR::de/URSS&SUlU(dgUR
R
UR[[USS9v� g7f)NrHrTr�)
r*r�rNr�r�r�r_r�r�r�)rPrOs  r2r��&bufferingcommandresponseemitter._flush�sw����(�(�4�<�<�(���7�|�t�}�}�,�,�,�����Q��������l�l�$�$��O�O�.�4���%�
�	
�s�BB	)r�r�r�r�r�N)rCrAr�rA�return�None)
r;r<r=r>r?r�r�r�r�rGr:rHr2r�r�zs5��	�;Q��!$��47��	
��?%�B
rHr�c��\rSrSrSr\RSSj5r\RSSj5r\RSSj5r	Sr
g)	�Encoderi��9A protocol class for the various encoder implementations.c��[e�N��NotImplementedError�rPrus  r2r��Encoder.encode����!�!rHc��[er�r��rPs r2r��
Encoder.flush�r�rHc��[er�r�r�s r2�finish�Encoder.finish�r�rHr:N�r�rU)r;r<r=r>r?�abc�abstractmethodr�r�r�rGr:rHr2r�r��sQ��C����"��"�	���"��"�	���"��"rHr�c�@�\rSrSrSr\RSSj5rSrg)�Decoderi�r�c��[er�r�r�s  r2r��Decoder.decode�r�rHr:Nr�)	r;r<r=r>r?r�r�r�rGr:rHr2r�r��s��C����"��"rHr�c�@�\rSrSrSrS	SjrS
SjrS
SjrS
SjrSr	g)�identityencoderi�z3Encoder for the "identity" stream encoding profile.c��gr�r:)rP�uis  r2r��identityencoder.__init__s��rHc��U$r�r:r�s  r2r��identityencoder.encode����rHc��g�NrHr:r�s r2r��identityencoder.flush���rHc��grr:r�s r2r��identityencoder.finishr
rHr:N�r�r�r�)
r;r<r=r>r?r�r�r�r�rGr:rHr2rr�s��=�
���rHrc�,�\rSrSrSrSSjrSSjrSrg)	�identitydecoderiz3Decoder for the "identity" stream encoding profile.c�P�U(a[R"[S55eg)Ns6identity decoder received unexpected additional values)r
r{r)rPr�	extraobjss   r2r��identitydecoder.__init__s$����+�+��K�L��
�rHc��U$r�r:r�s  r2r��identitydecoder.decoderrHr:Nr
r�)r;r<r=r>r?r�r�rGr:rHr2rrs��=��rHrc�<�\rSrSrSSjrS	SjrS	SjrS	SjrSrg)
�zlibencoderic�B�SSKnX lUR5Ulgr�)�zlib�_zlib�compressobj�_compressor)rPrrs   r2r��zlibencoder.__init__s����
��+�+�-��rHc�8�URRU5$r��r�compressr�s  r2r��zlibencoder.encode#������(�(��.�.rHc�`�URRURR5$r�)rr�r�Z_SYNC_FLUSHr�s r2r��zlibencoder.flush&s%�����%�%�d�j�j�&=�&=�>�>rHc�r�URRURR5nSUlU$r�)rr�r�Z_FINISH�rP�ress  r2r��zlibencoder.finish+s/�����$�$�T�Z�Z�%8�%8�9������
rH)rrNr
r��	r;r<r=r>r�r�r�r�rGr:rHr2rrs��.�/�?�
rHrc�(�\rSrSrSSjrSSjrSrg)�zlibdecoderi1c��SSKnU(a[R"[S55eUR	5Ulg)Nrs2zlib decoder received unexpected additional values)rr
r{r�
decompressobj�
_decompressor)rPrrrs    r2r��zlibdecoder.__init__2s5�����+�+��G�H��
�"�/�/�1��rHc�8�URRU5$r��r/�
decompressr�s  r2r��zlibdecoder.decode<����!�!�,�,�T�2�2rH�r/Nr
r��r;r<r=r>r�r�rGr:rHr2r,r,1s��2�3rHr,c�<�\rSrSrSSjrS	SjrS	SjrS	SjrSrg)
�zstdbaseencoderi@c�d�SSKJn X lURUS9nUR	5Ulg)Nr��zstd)�level)�r<�_zstd�ZstdCompressorrr)rPr=r<�cctxs    r2r��zstdbaseencoder.__init__As.����
��"�"��"�/���+�+�-��rHc�8�URRU5$r�rr�s  r2r��zstdbaseencoder.encodeHr!rHc�`�URRURR5$r�)rr�r?�COMPRESSOBJ_FLUSH_BLOCKr�s r2r��zstdbaseencoder.flushKs%�����%�%�d�j�j�&H�&H�I�IrHc�r�URRURR5nSUlU$r�)rr�r?�COMPRESSOBJ_FLUSH_FINISHr's  r2r��zstdbaseencoder.finishQs/�����$�$�T�Z�Z�%H�%H�I������
rH)rr?N)r=rAr�r�r�r*r:rHr2r9r9@s��.�/�J�rHr9c�,^�\rSrSrSU4SjjrSrU=r$)�zstd8mbencoderiWc�$>�[TU]S5 g)Nr)�superr�)rPr�	__class__s  �r2r��zstd8mbencoder.__init__Xs���
����rHr:r
�r;r<r=r>r�rG�
__classcell__�rOs@r2rLrLWs
����rHrLc�(�\rSrSrSSjrSSjrSrg)�zstdbasedecoderi\c�X�SSKJn URUS9nUR5Ulg)Nrr;)�max_window_size)r>r<�ZstdDecompressorr.r/)rP�
maxwindowsizer<�dctxs    r2r��zstdbasedecoder.__init__]s)����$�$�]�$�C��!�/�/�1��rHc�8�URRU5$r�r2r�s  r2r��zstdbasedecoder.decodecr5rHr6N)rYrAr�r�r�r7r:rHr2rUrU\s��2�3rHrUc�,^�\rSrSrSU4SjjrSrU=r$)�zstd8mbdecoderigc�l>�U(a[R"[S55e[TU]SS9 g)Ns5zstd8mb decoder received unexpected additional valuesi�)rY)r
r{rrNr�)rPrrrOs   �r2r��zstd8mbdecoder.__init__hs2�����+�+��J�K��
�	���{��3rHr:r
rQrSs@r2r_r_gs
���4�4rHr_z&dict[bytes, tuple[EncoderT, DecoderT]]�STREAM_ENCODERSzlist[bytes]�STREAM_ENCODERS_ORDERc�d�[(agSSKJn UR U(a([
[4[S'[RS5 [[4[S'[RS5 [[4[S'[RS5 g![a SnN�f=f)Nrr;szstd-8mbszlib�identity)
rbr>r<�__version__�ImportErrorrLr_rcr(rr,rrr;s r2�populatestreamencodersrh}s�����������
�(6��'G���$��$�$�[�1� +�[�9�O�G��� � ��)�$3�_�#E�O�K� �� � ��-�������s�B � B/�.B/c�Z�\rSrSr%SrS\S'S\S'SSSjjrS
SjrS	rg
)r�i�z5Represents a logical unidirectional series of frames.rArD�bool�_activec��XlX lgr�)rDrk)rPrD�actives   r2r��stream.__init__�s�� �
��rHc�v�SnUR(dU[-nSUl[XRXRX45$)�mCreate a frame to be sent out over this stream.

Only returns the frame instance. Does not actually send it.
rT)rk�STREAM_FLAG_BEGIN_STREAMr_rD)rPrCrFr0rOrEs      r2r_�stream.makeframe�s:�����|�|��3�3�K��D�L���}�}�k�5�
�	
rH)rkrDN�F�rDrArmrjr�r�)
rCrArFrAr0rArOrUr�rY)	r;r<r=r>r?�__annotations__r�r_rGr:rHr2r�r��sA��?��M�
�M��
��
�&)�
�25�
�@E�
�	�
rHc�^^�\rSrSr%SrS\S'S
SU4SjjjrSSjrS
SjrS
Sjr	S	r
U=r$)�inputstreami�z,Represents a stream used for receiving data.zDecoder | None�_decoderc�.>�[TU]XS9 SUlg)N�rm)rNr�rx�rPrDrmrOs   �r2r��inputstream.__init__�s���
�����1���
rHc��U[;a"[R"[S5U-5e[US"X5Ulg)z�Set the decoder for this stream.

Receives the stream profile name and any additional CBOR objects
decoded from the stream encoding settings frame payloads.
sunknown stream decoder: %srN)rbr
r{rrx)rPrrRrs    r2�
setdecoder�inputstream.setdecoder�s<����&��+�+�a� =�>��E�F�F�'��-�a�0��?��
rHc�^�UR(dU$URRU5$r�)rxr�r�s  r2r��inputstream.decode�s%���}�}��K��}�}�#�#�D�)�)rHc�Z�UR(dgURR5$r)rxr�r�s r2r��inputstream.flush�s!���}�}���}�}�"�"�$�$rH)rxrsrt�rRrUr�r�r�)r;r<r=r>r?rur�r~r�r�rGrRrSs@r2rwrw�s+���6�����	@�*�%�%rHrwc�^�\rSrSr%SrS\S'S\S'S\S'SSU4S	jjjrSS
jrSSjrSSjr	S
r
SSSjjrSSjrSr
U=r$)r�i�z*Represents a stream used for sending data.rjr�zEncoder | None�_encoderzbytes | None�_encodernamec�J>�[TU]XS9 SUlSUlSUlg)NrzF)rNr�r�r�r�r{s   �r2r��outputstream.__init__�s*���
�����1�"'�����
� ��rHc��U[;a"[R"[S5U-5e[US"U5UlX lg)zDSet the encoder for this stream.

Receives the stream profile name.
sunknown stream encoder: %srN)rbr
r{rr�r�)rPrrRs   r2�
setencoder�outputstream.setencoder�sB��
��&��+�+�a� =�>��E�F�F�'��-�a�0��4��
� �rHc�^�UR(dU$URRU5$r�)r�r�r�s  r2r��outputstream.encode�s#���}�}��K��}�}�#�#�D�)�)rHc�Z�UR(dgURR5$r)r�r�r�s r2r��outputstream.flush�s���}�}���}�}�"�"�$�$rHc�\�UR(dgURR5 gr)r�r�r�s r2r��outputstream.finish�s���}�}���
�
���rHc�"�SnUR(dU[-nSUlU(a0UR(d[R"S5eU[
-nU[:XaU[-(aSUl[XRXbX45$)rprTs@attempting to send encoded frame without sending stream settings)
rkrqr�r
�ProgrammingError�STREAM_FLAG_ENCODING_APPLIED�FRAME_TYPE_STREAM_SETTINGS�!FLAG_STREAM_ENCODING_SETTINGS_EOSr_rD)rPrCrFr0rOr�rEs       r2r_�outputstream.makeframe�s������|�|��3�3�K��D�L���*�*��,�,� ���

�7�7�K�
�0�0��9�9�&*�D�#���}�}�k�5�
�	
rHc���UR(aUR(agSR[R"UR
55nUR
U[[U5$)z�Create a stream settings frame for this stream.

Returns frame data or None if no stream settings frame is needed or has
already been sent.
NrH)	r�r�r*rrdr�r_r�r�)rPrCrOs   r2�makestreamsettingsframe�$outputstream.makestreamsettingsframe#sR���}�}�� 7� 7���(�(�8�0�0��1B�1B�C�D���~�~��&�-��	
�	
rH)rkr�r�r�rsrtr�r�)rCrArFrAr0rArOrUr�rjr�rY)rCrAr��bytearray | None)r;r<r=r>r?rur�r�r�r�r�r_r�rGrRrSs@r2r�r��s����4�������!�!�	!�*�%���
"
��"
��"
��	"
�
�"
��
"
�
�"
�H
�
rHc�r�URS-(a#[R"SUR-5eg)NrsAserver should only write to even numbered streams; %d is not even)rDr
r�)r�s r2�ensureserverstreamr�5s8��
������$�$�
0�28�/�/�
B�
�	
�rH�contentencodingsrezdict[bytes, list[bytes]]�DEFAULT_PROTOCOL_SETTINGSc��\rSrSr%SrS\S'SSSjjrSSjrSSjrSSjr	SS	jr
SS
jrS S!SjjrS"S
jr
S#SjrS$SjrS%SjrSSjrSSjrSSjrSSjrSSjrSSjrSSjrSrg)&�
serverreactoriBa~
Holds state of a server handling frame-based protocol requests.

This class is the "brain" of the unified frame-based protocol server
component. While the protocol is stateless from the perspective of
requests/commands, something needs to track which frames have been
received, what frames to expect, etc. This class is that thing.

Instances are modeled as a state machine of sorts. Instances are also
reactionary to external events. The point of this class is to encapsulate
the state of the connection and the exchange of frames, not to perform
work. Instead, callers tell this class when something occurs, like a
frame arriving. If that activity is worthy of a follow-up action (say
*run a command*), the return value of that handler will say so.

I/O and CPU intensive operations are purposefully delegated outside of
this class.

Consumers are expected to tell instances when events occur. They do so by
calling the various ``on*`` methods. These methods return a 2-tuple
describing any follow-up action(s) to take. The first element is the
name of an action to perform. The second is a data structure (usually
a dict) specific to that action that contains more information. e.g.
if the server wants to send frames back to the client, the data structure
will contain a reference to those frames.

Valid actions that consumers can be instructed to take are:

sendframes
   Indicates that frames should be sent to the client. The ``framegen``
   key contains a generator of frames that should be sent. The server
   assumes that all frames are sent to the client.

error
   Indicates that an error occurred. Consumer should probably abort.

runcommand
   Indicates that the consumer should run a wire protocol command. Details
   of the command to run are given in the data structure.

wantframe
   Indicates that nothing of interest happened and the server is waiting on
   more frames from the client before anything interesting can be done.

noop
   Indicates no additional action is required.

Known Issues
------------

There are no limits to the number of partially received commands or their
size. A malicious client could stream command request data and exhaust the
server's memory.

Partially received commands are not acted upon when end of input is
reached. Should the server error if it receives a partial request?
Should the client send a message to abort a partially transmitted request
to facilitate graceful shutdown?

Active requests that haven't been responded to aren't tracked. This means
that if we receive a command and instruct its dispatch, another command
with its request ID can come in over the wire and there will be a race
between who responds to what.
zlist[Iterator[bytearray]]�_bufferedframegensc���XlX lSUlSUl/Ul0Ul0Ul0Ul[5Ul	SUl
[[5Ul
[5 g)a�Construct a new server reactor.

``deferoutput`` can be used to indicate that no output frames should be
instructed to be sent until input has been exhausted. In this mode,
events that would normally generate output frames (such as a command
response being ready) will instead defer instructing the consumer to
send those frames. This is useful for half-duplex transports where the
sender cannot receive until all data has been transmitted.
�initialrN)�_ui�_deferoutput�_state�_nextoutgoingstreamidr��_incomingstreams�_outgoingstreams�_receivingcommands�set�_activecommands�_protocolsettingsdecoder�dictr��_sendersettingsrh)rPr�deferoutputs   r2r��serverreactor.__init__�sh����'�� ���%&��"�"$��� "��� "���"$��� #�u���(,��%� $�$=�>���� rHc�Z�URS-(d.SUlUR[S5UR-5$URUR;aeUR
[-(d!SUlUR[S55$[UR5URUR'UR
[-(aSUl[R"S5eUR
[-(aURUR	URURURURUR S.nUR#UR5nU(d#[R"SUR-5eU"U5$)z�Process a frame that has been received off the wire.

Returns a dict with an ``action`` key that details what action,
if any, the consumer should take next.
r�erroreds/received frame with even numbered stream ID: %dsNreceived frame on unknown inactive stream without beginning of stream flag sets8support for decoding stream payloads not yet implemented)r��protocol-settings-receiving�idle�command-receivingr�sunhandled state: %s)rDr��_makeerrorresultrr�rErqrwr�r
r��STREAM_FLAG_END_STREAM�_onframeinitial�_onframeprotocolsettings�_onframeidle�_onframecommandreceiving�_onframeerroredr))rPrK�handlers�meths    r2�onframerecv�serverreactor.onframerecv�sj���~�~��!�$�D�K��(�(��D�E��.�.�!��
�
�>�>��!6�!6�6��$�$�'?�?�(����,�,��8����5@����4O�D�!�!�%�.�.�1����;�;�$�D�K��(�(�K��
����5�5��%�%�e�n�n�5��,�,�,0�,I�,I��&�&�"&�"?�"?��,�,�
���|�|�D�K�K�(����(�(�)?�$�+�+�)M�N�N��E�{�rHc�^^^^�[T5 [T[5(a[T5mUUUU4SjnTR	U"55$)z�Signal that objects are ready to be sent to the client.

``objs`` is an iterable of objects (typically a generator) that will
be encoded via CBOR and added to frames, which will be sent to the
client.
c	3��># �SnSn[T
T5n[T5n[U[R 5(aNU(a[
R""S5eT
R%T5nU(aUv� ['T
TU5v� SnSnM{U(a[
R""S5eU(d5T
R%T5nU(aUv� [)T
T5nU(aUv� Sn[U[R*5(a'URUR,5HnUv� M	 O�[U[R.5(aD[0R2"UR45HnURU5HnUv� M	 M! O:[0R6"U5HnURU5HnUv� M	 M! GM�![a= URS5HnUv� M	 U(a[	T
T5HnUv� M	 O�[
Ra7n[T
TURUR5HnUv� M	 SnAOySnAf[a8n[T
TS[R"U5-SS9HnUv� M	 SnAO9SnAff=f![a$n[T
TSU-SS9HnUv� M	 SnAOSnAff=fT	R8R;T5 g7f)NFTs%s�server�r�s:alternatelocationresponse seen after initial output objects(object follows alternatelocationresponse)r��next�
StopIterationr�r�r
�WireprotoCommandErrorr�r��messageargs�	Exceptionr�r�forcebytestrr�r
�alternatelocationresponser�r�r�r��encodedresponseru�indefinitebytestringresponser�streamencodebytestringfromiter�chunksrdr��remove)�emitted�alternatelocationsent�emitter�orK�er��objsrCrPr�s       ����r2�
sendframes�?serverreactor.oncommandresponsereadyobjects.<locals>.sendframes�s������G�$)�!�5�f�i�H�G����T�
�A�<G�"�!�^�%M�%M�N�N�"�"'�"8�"8�!1�#��
!'� >� >�y� I�� �"'�K�B�"�I�q���15�-�"&�� �,�#�4�4�G���#� &� >� >�y� I�� �"'�K�!=�V�Y� O�� �"'�K�"&��"�!�^�%C�%C�D�D�%,�\�\�!�&�&�%9�E�"'�K�&:�$��>�F�F���&.�%L�%L��H�H�&�E�*1���e�)<��&+��*=�&�&.�%:�%:�1�%=�E�)0���e�)<��&+��*=�&>�{��%�	�!(���d�!3��#��"4��%C�"�I�&�E�#(�K�&���2�2��!;��	�1�9�9�a�m�m�"��$��"��� �	�!1��!��
� 7� 7�� :�:� )�	"��$��
"���	��X!��!1��	�5�1�9�i�"��$��"�
��
��
� � �'�'�	�2�s��K.�G�A+J!�
K.�BJ!�-K.�.A"J!�K.�9J!�
K.�AJ�K.�J�'-I�K.�
J�&.J�K.�J�K.�!
K�+K
�K.�
K�K.)r�r��list�iter�_handlesendframes)rPr�rCr�r�s```` r2�oncommandresponsereadyobjects�+serverreactor.oncommandresponsereadyobjects�sG���	�6�"��d�D�!�!���:�D�m	3�m	3�^�%�%�j�l�3�3rHc�r^�TR(aTR(dS04$U4SjnSSU"504$)zySignals that end of input has been received.

No more frames will be received. All pending activity should be
completed.
�noopc3�L># �TRH
nUShv�N M gN	7fr�)r�)�genrPs �r2�makegen�)serverreactor.oninputeof.<locals>.makegenos �����.�.�����/��s�$�"�
$�
sendframes�framegen)r�r�)rPr�s` r2�
oninputeof�serverreactor.oninputeofcs@���� � ��(?�(?��B�;��	�����
�
�	
rHc�n�UR(aURRU5 S04$SSU04$)Nr�r�r�)r�r�r()rP�framegens  r2r��serverreactor._handlesendframeswsB������#�#�*�*�8�4��B�;�� ��X�#��
rHc�^^^^^�[T5 UUUU4SjnTRU"55$)Nc3�p># �[TTTSS9Shv�N TRRT5 gN 7f)Nr�r�)r�r�r�)r�rCrPr�s����r2r��/serverreactor.onservererror.<locals>.sendframes�s<����'��	�3�	��
�
�
� � �'�'�	�2�	
�s�6�4�!6�r�r�)rPr�rCr�r�s```` r2�
onservererror�serverreactor.onservererror�s,���	�6�"�	3�	3��%�%�j�l�3�3rHNc�b^^^^^�[T5 UUUUU4SjnTRU"55$)zACalled when a command encountered an error before sending output.c3�t># �[TTTT5Shv�N TRRT5 gN 7fr�)r�r�r�)r�r�rCrPr�s�����r2r��0serverreactor.oncommanderror.<locals>.sendframes�s<����1��	�7�D��
�
�
� � �'�'�	�2�	
�s�8�6�!8r�)rPr�rCr�r�r�s````` r2�oncommanderror�serverreactor.oncommanderror�s,���	�6�"�	3�	3��%�%�j�l�3�3rHc��URnU=RS-
sl[U5nX RU'[H4nX0RS;dMURURU5  U$ U$)z�Create a stream to be used for sending data to the client.

If this is called before protocol settings frames are received, we
don't know what stream encodings are supported by the client and
we will default to identity.
rr�)r�r�r�rcr�r�r�)rPrDrgrRs    r2�makeoutputstream�serverreactor.makeoutputstream�sw���-�-���"�"�a�'�"���"��*+���h�'�*�D��+�+�,?�@�@����T�X�X�t�,����*�
�rHc��SSU04$)Nr�r�r:)rPr�s  r2r��serverreactor._makeerrorresult�s�����
�
�	
rHc�~�URUnUS(dSUl[R"S5eURU	UR(aSUlOSUlUSR	S5 [
R"USR55SnSU;a!SUlUR[S	55$S
U;a0US
'XR;deURRU5 SUUSUS
URS5US
(aUS
R5S.4$SS.4$)N�requestdoner�s,should not be called without requestdone setr�r��payloadrr�s$command request missing "name" fieldr�s
runcommandr��data)s	requestidscommandr�r�r)
r�r�r
r��seekr�	decodeall�getvaluer�rr��addr))rPrC�entry�requests    r2�_makeruncommandresult�#serverreactor._makeruncommandresult�sZ���'�'�	�2���^�$�$�D�K��(�(�?��
�
�#�#�I�.��"�"�.�D�K�!�D�K�	�j����q�!��$�$�U�:�%6�%?�%?�%A�B�1�E���'�!�$�D�K��(�(��9�:��
��'�!�!�G�G��� 4� 4�4�4�4���� � ��+�
�'�#�G�,� ��)�$�[�[��5�6;�G�n��w��0�0�2�
�	
�		
�KO�
�	
�		
rHc�"�SSUR04$)Ns	wantframesstate)r�r�s r2�_makewantframeresult�"serverreactor._makewantframeresult�s����d�k�k�
�
�	
rHc��UR[-nUR[-nU(a(U(a!SUlUR	[S55$U(d)U(d!SUlUR	[S55$gg)Nr�sGreceived command request frame with both new and continuation flags setsJreceived command request frame with neither new nor continuation flags set)r0r�r�r�r�r)rPrK�new�continuations    r2�_validatecommandrequestframe�*serverreactor._validatecommandrequestframe�s����k�k�4�4���{�{�%F�F���<�$�D�K��(�(��.���
��<�$�D�K��(�(��.���
�(�srHc�B�UR[:Xa2SUl[R"5UlUR
U5$UR[:XaSUlURU5$SUlUR[S5UR-5$)Nr�r�r�sBexpected sender protocol settings or command request frame; got %d)rF�#FRAME_TYPE_SENDER_PROTOCOL_SETTINGSr�r�bufferingdecoderr�r�r�r�r�r�rPrKs  r2r��serverreactor._onframeinitials����<�<�>�>�8�D�K�,4�,E�,E�,G�D�)��0�0��7�7�
�\�\�7�
7�!�D�K��$�$�U�+�+�%�D�K��(�(��%���,�,�	��
rHc�T�URS:XdeURceUR[:wa.SUlUR	[S5UR-5$UR[-nUR[-nU(a(U(a!SUlUR	[S55$U(d(U(d!SUlUR	[S55$URRUR5 U(aUR5$U(deURR5nSUlU(d!SUlUR	[S55$[!U5S:�a!SUlUR	[S	55$US
nSU;aUSUR"S'SUlUR5$![aBnSUlUR	[S5[R"U5-5sSnA$SnAff=f)
Nr�r�s/expected sender protocol settings frame; got %dsXsender protocol settings frame cannot have both continuation and end of stream flags setsOsender protocol settings frame must have continuation or end of stream flag sets;error decoding CBOR from sender protocol settings frame: %ss8sender protocol settings frame did not contain CBOR datars=sender protocol settings frame contained multiple CBOR valuesrr�r�)r�r�rFrr�rr0�*FLAG_SENDER_PROTOCOL_SETTINGS_CONTINUATION�!FLAG_SENDER_PROTOCOL_SETTINGS_EOSr�rOr�rr�r�getavailablerNr�)rPrK�more�eosr��decoded�ds       r2r��&serverreactor._onframeprotocolsettingss���{�{�<�<�<�<��,�,�8�8�8��<�<�>�>�$�D�K��(�(��D�E��,�,���
�
�{�{�G�G���k�k�=�=���C�$�D�K��(�(��@���
��C�$�D�K��(�(��.���
�		��)�)�0�0����?���,�,�.�.��
�s��/�/�<�<�>��(,��%��$�D�K��(�(��M�N��
���\�A�
�$�D�K��(�(�����
�
�A�J���!�#�89�:M�8N�D� � �!4�5�����(�(�*�*��M�	�$�D�K��(�(��R���)�)�!�,�-��
��	�s�)%G�
H'�%7H"�H'�"H'c���UR[:wa.SUlUR[	S5UR-5$URU5nU(aU$URUR;a.SUlUR[	S5UR-5$URUR;a.SUlUR[	S5UR-5$UR[-nUR[-nUR[-nU(d!SUlUR[	S55$[R"5nURUR 5 USU(+[#U5S.URUR'U(d"U(dUR%UR5$U(d	U(deSUlUR'5$)Nr�s&expected command request frame; got %ds#request with ID %d already receiveds$request with ID %d is already actives3received command request frame without new flag set)rrr��
expectingdatar�)rFr�r�r�rrrCr�r�r0r�r�r�r�bytesio�writerOrjrr)rPrKr(r�
moreframes�
expectingdatarOs       r2r��serverreactor._onframeidleas����<�<�5�5�$�D�K��(�(��;�<�u�|�|�K��
��/�/��6����J��?�?�d�5�5�5�$�D�K��(�(��8�9�E�O�O�K��
��?�?�d�2�2�2�$�D�K��(�(��9�:�U�_�_�L��
��k�k�4�4���[�[�#C�C�
����&F�F�
��$�D�K��(�(��H�I��
��,�,�.���
�
�e�m�m�$� �� *�N�"�=�1�	4
�������0��-��-�-�e�o�o�>�>��]�*�*�*����(�(�*�*rHc�H�UR[:XaCUR[-(aUR	U5$URU5nU(aU$URUR;a.SUlUR[S5UR-5$URUR;a.SUlUR[S5UR-5$URURnUR[:Xa�UR[-n[UR[-5nUS(a!SUlUR[S55$XSS:wa!SUlUR[S55$USRUR 5 U(dS	US'U(d"U(dUR#UR5$UR%5$UR[&:XagUS(d.SUlUR[S
5UR-5$USc[(R*"5US'UR-X5$SUlUR[S5UR-5$)
Nr�s3received frame for request that is still active: %ds4received frame for request that is not receiving: %dr�sGreceived command request frame when request frames were supposedly doner!s4mismatch between expect data flag and previous framerTsFreceived command data frame for request that is not expecting data: %drs"received unexpected frame type: %d)rFr�r0r�r�rrCr�r�r�rr�r�rjr�r#rOrrr�rr"�_handlecommanddataframe)rPrKr(rr$r%s      r2r��&serverreactor._onframecommandreceiving�sc���<�<�5�5��{�{�5�5��(�(��/�/��3�3�E�:�C���
��?�?�d�2�2�2�$�D�K��(�(��H�I��/�/�"��
�
�?�?�$�"9�"9�9�$�D�K��(�(��I�J��/�/�"��
�
�'�'����8���<�<�5�5����'G�G�J� ����/O�!O�P�M��^�$�(����,�,��0�����&6� 7�7�(����,�,��M�N���
�*��#�#�E�M�M�2��(,��n�%��m��1�1�%�/�/�B�B��,�,�.�.�
�\�\�4�
4��)�*�(����,�,��.���o�o�	&����W�~�%�!%�����g���/�/��=�=�$�D�K��(�(��7�8�5�<�<�G��
rHc��UR[:XdeUSRUR5 UR[
-(aUR
5$UR[-(a/USRS5 URUR5$SUlUR[S55$)Nrrr�s command data frame without flags)rFr�r#rOr0r�rr�rrrCr�r�r)rPrKrs   r2r(�%serverreactor._handlecommanddataframe�s����|�|�6�6�6�6�	�g����U�]�]�+��;�;�7�7��,�,�.�.�
�[�[�0�
0��'�N����"��-�-�e�o�o�>�>�$�D�K��(�(��+N�)O�P�PrHc�6�UR[S55$)Nsserver already errored)r�rrs  r2r��serverreactor._onframeerrored�s���$�$�Q�'@�%A�B�BrH)r�r�r�r�r�r�r�r�r�r�r�rs)r�rjr�r��rKrK)rCrAr��HandleSendFramesReturnT�r�z.tuple[bytes, dict[bytes, Iterator[bytearray]]])r��Iterator[bytearray]r�r/)r�r�rCrAr�rUr�r/r�)r�r�rCrAr�rUr�r/)r�r�)r�rUr�� tuple[bytes, dict[bytes, bytes]])rCrA)r�r2)r;r<r=r>r?rur�r�r�r�r�r�r�r�r�rrrr�r�r�r�r(r�rGr:rHr2r�r�Bs���>�@2�1�!�@/�bK4�!$�K4�	 �K4�Z
�(	�+�	�	 �	�4��4�),�4�38�4�	 �4�DH�
4��
4�),�
4�7<�
4�	 �
4��,
�
)
�V
�
�,�*J+�X3+�jL�\
Q�CrHr�c�:�\rSrSr%SrS\S'SS	SjjrSrg)
�commandrequesti�z&Represents a request to run a command.rU�stateNc�N�XlX lX0lX@lXPlSUlg)Nspending)rCrRr�r�r�r5)rPrCrRr�r�r�s      r2r��commandrequest.__init__�s$��#���	��	��� �
���
rH)r�r�rRr�rCr5�NN)rCrAr�r�)r;r<r=r>r?rur�rGr:rHr2r4r4�s+��0��L�AE� �� �	
� � rHr4c��\rSrSr%SrS\S'S\S'SSSjjrSSjrSS	jrSS
jr	SSjr
SSjrSS
jrSSjr
Srg)�
clientreactoria!Holds state of a client issuing frame-based protocol requests.

This is like ``serverreactor`` but for client-side state.

Each instance is bound to the lifetime of a connection. For persistent
connection transports using e.g. TCP sockets and speaking the raw
framing protocol, there will be a single instance for the lifetime of
the TCP socket. For transports where there are multiple discrete
interactions (say tunneled within in HTTP request), there will be a
separate instance for each distinct interaction.

Consumers are expected to tell instances when events occur by calling
various methods. These methods return a 2-tuple describing any follow-up
action(s) to take. The first element is the name of an action to
perform. The second is a data structure (usually a dict) specific to
that action that contains more information. e.g. if the reactor wants
to send frames to the server, the data structure will contain a reference
to those frames.

Valid actions that consumers can be instructed to take are:

noop
   Indicates no additional action is required.

sendframes
   Indicates that frames should be sent to the server. The ``framegen``
   key contains a generator of frames that should be sent. The reactor
   assumes that all frames in this generator are sent to the server.

error
   Indicates that an error occurred. The ``message`` key contains an
   error message describing the failure.

responsedata
   Indicates a response to a previously-issued command was received.

   The ``request`` key contains the ``commandrequest`` instance that
   represents the request this data is for.

   The ``data`` key contains the decoded data from the server.

   ``expectmore`` and ``eos`` evaluate to True when more response data
   is expected to follow or we're at the end of the response stream,
   respectively.
rj�_hasmultiplesend�_buffersendsNc��XlX lX0lX@lSUlSUlSUlSUl[S5Ul	[R"5Ul0Ul
0Ul0Ul[!5 g)aBCreate a new instance.

``hasmultiplesend`` indicates whether multiple sends are supported
by the transport. When True, it is possible to send commands immediately
instead of buffering until the caller signals an intent to finish a
send operation.

``buffercommands`` indicates whether sends should be buffered until the
last request has been issued.

``clientcontentencoders`` is an iterable of content encoders the client
will advertise to the server and that the server can use for encoding
data. If not defined, the client will not advertise content encoders
to the server.
TFrN)r�r;r<�_clientcontentencoders�_canissuecommands�_cansend�_protocolsettingssent�_nextrequestidr��_outgoingstream�collections�deque�_pendingrequests�_activerequestsr��_streamsettingsdecodersrh)rPr�hasmultiplesend�buffersends�clientcontentencoderss     r2r��clientreactor.__init__9su��,�� /��'��&;�#�!%�����
�%*��"����+�A���� +� 1� 1� 3���!��� "���')��$�� rHc���UR(d[R"S5eURnU=RS-
sl[	XQX#US9nUR
(a URRU5 US04$UR(d[R"S5eUR(dSUlSUlUSSURU504$)	z�Request that a command be executed.

Receives the command name, a dict of arguments to pass to the command,
and an optional file object containing the raw data for the command.

Returns a 3-tuple of (request, action, action data).
scannot issue new commandsr�r�r�r��*sends cannot be performed on this instanceFr�r�)r?r
r�rBr4r<rFr(r@r;�_makecommandframes)rPrRr�r�r�rCrs       r2�callcommand�clientreactor.callcommandbs����%�%��(�(�)E�F�F��'�'�	����q� �� ��T�8�
������!�!�(�(��1��G�R�'�'��=�=��,�,�A����(�(� %��
�).��&�����!8�!8��!A���
rHc��^�TR(dS04$TR(d[R"S5eTR(dSTlSTlU4SjnSSU"504$)a/Request that all queued commands be sent.

If any commands are buffered, this will instruct the caller to send
them over the wire. If no commands are buffered it instructs the client
to no-op.

If instances aren't configured for multiple sends, no new command
requests are allowed after this is called.
r�rOFc3��># �TR(aGTRR5nTRU5Shv�N TR(aMFggN7fr�)rF�popleftrP)rrPs �r2�
makeframes�/clientreactor.flushcommands.<locals>.makeframes�sH�����'�'��/�/�7�7�9���2�2�7�;�;�;��'�'�'�;�s�AA�A�A�Ar�r�)rFr@r
r�r;r?)rPrVs` r2�
flushcommands�clientreactor.flushcommands�so����$�$��B�;���}�}��(�(�=��
��$�$�%*�D�"�!�D�M�	<�
����
�
�	
rHc	#�# �XRUR'SUlUR(dyUR(ahSUlSR[R"SUR055nURRUR[[US9v� [URURURURURUR S9nUShv�N SUlgN7f)	zsEmit frames to issue a command request.

As a side-effect, update request accounting to reflect its changed
state.
ssendingTrHr�r�rNNssent)rGrCr5rAr>r*rrdrCr_rrr�rRr�r�r�)rPrrOr(s    r2rP� clientreactor._makecommandframes�s����3:���W�.�.�/�"��
��)�)�d�.I�.I�)-�D�&��h�h��%�%�+�T�-H�-H����G��&�&�0�0�!�+�+�:�7��	1��
�"�� � �����L�L��L�L��>�>��%�%�

�������
�	�s�C9D
�;D�<
D
c��URS-(aSS[S5UR-04$URUR;aSUR[-(dSS[S504$[UR5URUR'URURnUR[-(a URUR5UlUR[-(aURUR	UR[:XaURU5$URUR;aSS[S5UR-04$URURnSUl[ UR"[$UR&0nUR)UR5nU(d#[*R,"SUR-5eU"X15$)	z�Process a frame that has been received off the wire.

Returns a 2-tuple of (action, meta) describing further action the
caller needs to take as a result of receiving this frame.
rr�r�s.received frame with odd numbered stream ID: %dsEreceived frame on unknown stream without beginning of stream flag sets*received frame for inactive request ID: %ds	receivingsunhandled frame type: %d)rDrr�rErqrwr�r�rOr�rFr��_onstreamsettingsframerCrGr5r��_oncommandresponseframer��_onerrorresponseframer)r
r�)rPrKr�rr�r�s      r2r��clientreactor.onframerecv�s����>�>�A�����K�L��.�.�)���
��>�>��!6�!6�6��$�$�'?�?��"�A�D�%����5@����4O�D�!�!�%�.�.�1��&�&�u�~�~�6��
���;�;�"�M�M�%�-�-�8�E�M����5�5��%�%�e�n�n�5��<�<�5�5��.�.�u�5�5��?�?�$�"6�"6�6����G�H��/�/�*���
��&�&�u���7��$��
�
(��)E�)E�%�t�'A�'A�
��
�|�|�E�L�L�)����(�(�+�e�l�l�:��
��G�#�#rHc��UR[:XdeUR[-nUR[-nU(aU(aSS[S504$U(dU(dSS[S504$URUR;a-[R"5nX@RUR'URURnURUR5 U(aS04$U(deUR5nURUR	U(dSS[S504$UR URR#UR$USUS	S5 S04$![a0nSS[S5[R"U5-04sSnA$SnAff=f![a0nSS[S
5[R"U5-04sSnA$SnAff=f)Nr�r�sXstream encoding settings frame cannot have both continuation and end of stream flags setsOstream encoding settings frame must have continuation or end of stream flag sets;error decoding CBOR from stream encoding settings frame: %sr�s8stream encoding settings frame did not contain CBOR datarrs error setting stream decoder: %s)rFr�r0�*FLAG_STREAM_ENCODING_SETTINGS_CONTINUATIONr�rrDrHrrr�rOr�rr�rr�r~r�)rPrKrr�decoderr�rs       r2r]�$clientreactor._onstreamsettingsframes���|�|�9�9�9�9��{�{�G�G���k�k�=�=���C����H���
�

��C����B�!���
��>�>��!=�!=�=��/�/�1�G�;B�(�(����8��.�.�u�~�~�>��	��N�N�5�=�=�)���B�;���
�s��&�&�(���(�(����8�����%�!���
�
	��!�!�%�.�.�1�<�<����'�!�*�g�a�b�k�
���{���a�	����2��%�1�1�!�4�	5���
��	��J�		����=�>�$�1�1�!�4�5���
��		�s<�F�:G�
F=�
%F8�2F=�8F=�
G:�
%G5�/G:�5G:c���UR[-(aSUlURUR	SUUR[
-UR[-URS.4$)Nsreceivedsresponsedata)�requests
expectmorerr)r0r�r5rGrCr�rO)rPrrKs   r2r^�%clientreactor._oncommandresponseframetsb���;�;�2�2�'�G�M��$�$�W�%6�%6�7�
�#�$�{�{�-O�O����&?�?����	
�
�	
rHc��SUlURUR	[R"UR
5SnSUUSUSS.4$)Nr�rr�r�r�)rfr�r�)r5rGrCrrrO)rPrrKr�s    r2r_�#clientreactor._onerrorresponseframe�s]��"��
�� � ��!2�!2�3�
���u�}�}�-�a�0��
�#��7���j�M�
�
�	
rH)
rGr<r?r@r>r;r�rBrCrFrArHr�)FTN)rIrjrJrjr�r�r8r0)rr4r�r1r.)rr4rKrK)r;r<r=r>r?rur�rQrXrPr�r]r^r_rGr:rHr2r:r:s��,�\����
!&� �"�'!��'!��	'!�
�
'!�R%�N
�B( �%�( �	�( �TF$�PV�p

�
rHr:)r+rr,rAr�rU)rCrArDrArErArFrAr0rArOrUr�rY)rgrUr�rY)rurUr�r6)r�zframe | None)r�r�rCrAr�rAr�r1)r�r�rCrAr�r�)r�r�rCrAr�rAr�r1)r�r�rCrAr�rYr�)r�r�rCrAr�rUr�r1)
r�r�rCrAr�rUr�rUr�r1r
)r�r�r�r�)g�
__future__rr�rDr[�typingrr�i18nr�
thirdpartyr�
TYPE_CHECKINGr>r	r
rrr
�utilsrrr�tuplerUr�rYr/rZr�rqr�r�rrur�r�r�r�r��FRAME_TYPE_PROGRESSrr�rr�r�r�r�rr�r�rr�r�r rrr!rbr�r"r#�Struct�ARGUMENT_RECORD_HEADERr3rgr6rKr_rorxr�r�r�r�r�r�r�r�r�r�r�rrrr,r9rLrUr_�EncoderT�DecoderTrbrcrhr�rwr�r�r�r�r4r:r:rHr2�<module>rvs2��#�
��
�
��
��
�������

����$�E�4��x�	�7J�0J�+K�$K�L����������#��.�)�,�"����"����"�� ������&*�#�!��3�,�4�0�*�$�!D�2�	!��
�	� ��$(�!�#'� �#'� �
%�6�
-�2�	+��'��"&����4�!�(��$��
&*�"� ��8�%�,��(��
.2�*�$(�!�@�-�4�� 0��
.2�*�$(�!�@�-�4�� 0��� 5��/��!7��r��B���'�)G�� >�	1��-�	� ���u�-��
����d���������d���
�
� �
�@�������
�	�
���
���8?�D�2�N�.�
�J��J��J��
J��J�Z���%(����4/���������	�@&��&�%(�&��&�T:>����"��-2����2���"��).��9>����6/�	8��8��8��	8�
�8�vf
�f
�Z
"�h�
"� "�h�"�
�g�
� 
�g�
��'��*3�'�3��g��.�_��
3�g�3�4�_�4�
����O�k�1�N�B�C�H��O�k�1�N�B�C�H�;=��7�<�%'��{�'�.�.
�
�6"%�&�"%�J^
�6�^
�B
��+��7��3��
r
C�r
C�j
 �
 � J
�J
rH

Youez - 2016 - github.com/yon3zu
LinuXploit