+
    jI                     p    R t ^ RIt^ RIt ! R R]4      t ! R R4      tRR R lltRR R	 lltR
 R ltR# )a  
Control Socket Protocol

JSON-based protocol with length-prefixed framing for the control interface.

Message Format:
    +----------------+------------------+
    | Length (4B BE) |  JSON Payload    |
    +----------------+------------------+

Request Format:
    {"id": 1, "command": "show", "args": ["workers"]}

Response Format:
    {"id": 1, "status": "ok", "data": {...}}
    {"id": 1, "status": "error", "error": "message"}
Nc                       ] tR t^tRtRtR# )ProtocolErrorzProtocol-level error. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       J/var/www/idalgo/venv/lib/python3.14/site-packages/gunicorn/ctl/protocol.pyr   r      s    r   r   c                      a  ] tR t^t o RtRt]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t	]V 3R lR	 l4       t
]V 3R
 lR l4       t]V 3R lR l4       tRtV tR# )ControlProtocolz{
Protocol implementation for control socket communication.

Uses 4-byte big-endian length prefix followed by JSON payload.
c                &   < V ^8  d   QhRS[ RS[/#    datareturn)dictbytes)format__classdict__s   "r   __annotate__ControlProtocol.__annotate__*   s        T  e  r   c                    \         P                  ! V 4      P                  R4      p\        P                  ! R\        V4      4      pW!,           # )zs
Encode a message for transmission.

Args:
    data: Dictionary to encode

Returns:
    Length-prefixed JSON bytes
utf-8>I)jsondumpsencodestructpacklen)r   payloadlengths   &  r   encode_messageControlProtocol.encode_message)   s:     **T"))'2T3w<0r   c                &   < V ^8  d   QhRS[ RS[/# r   )r   r   )r   r   s   "r   r   r   9   s     3 3U 3t 3r   c                (   \        V 4      ^8  d   \        R4      h\        P                  ! RV R,          4      ^ ,          p\        V 4      ^V,           8  d   \        R4      hV ^^V,            p\        P
                  ! VP                  R4      4      # )zy
Decode a message from bytes.

Args:
    data: Raw bytes (length prefix + JSON payload)

Returns:
    Decoded dictionary
zMessage too shortr   :N   NzIncomplete messager   )r"   r   r    unpackr   loadsdecode)r   r$   r#   s   &  r   decode_messageControlProtocol.decode_message8   sx     t9q= 344tT"X.q1t9q6z! 455qV$zz'..122r   c                    < V ^8  d   QhRS[ /# r   r   r   )r   r   s   "r   r   r   N   s     (6 (6d (6r   c                   Rp\        V4      ^8  dR   V P                  ^\        V4      ,
          4      pV'       g   V'       g   \        R4      h\        R4      hW,          pKa  \        P
                  ! RV4      ^ ,          pV\        P                  8  d   \        RV 24      hRp\        V4      V8  dI   V P                  \        V\        V4      ,
          R4      4      pV'       g   \        R4      hWB,          pKX   \        P                  ! VP                  R4      4      #   \        P                   d   p\        R	T 24      hR
p?ii ; i)z
Read one message from a socket.

Args:
    sock: Socket to read from

Returns:
    Decoded message dictionary

Raises:
    ProtocolError: If message is malformed
    ConnectionError: If connection is closed
r   zConnection closedzIncomplete length prefixr   Message too large: i   zIncomplete payloadr   Invalid JSON: N)r"   recvConnectionErrorr   r    r*   r   MAX_MESSAGE_SIZEminr   r+   r,   JSONDecodeError)socklength_datachunkr$   payload_dataes   &     r   read_messageControlProtocol.read_messageM   s     +"IIa#k"223E")*=>>#$>?? Kt[1!4O444"5fX >?? ,&(IIc&3|+<"<eDEE#$899!L	6::l11':;;## 	6. 455	6s    $D% %E:EEc                    < V ^8  d   QhRS[ /# r   r   r1   )r   r   s   "r   r   r   y   s     	 	$ 	r   c                R    \         P                  V4      pV P                  V4       R# )zi
Write one message to a socket.

Args:
    sock: Socket to write to
    data: Message dictionary to send
N)r   r%   sendall)r:   r   messages   && r   write_messageControlProtocol.write_messagex   s      "006Wr   c                    < V ^8  d   QhRS[ /# r0   r1   )r   r   s   "r   r   r      s     6 6D 6r   c                  "   V P                  ^4      G Rj  xL
 p\        P                  ! RV4      ^ ,          pV\        P                  8  d   \        RV 24      hV P                  V4      G Rj  xL
 p \        P                  ! VP                  R4      4      #  L L,  \        P                   d   p\        RT 24      hRp?ii ; i5i)zy
Read one message from an async reader.

Args:
    reader: asyncio StreamReader

Returns:
    Decoded message dictionary
Nr   r3   r   r4   )
readexactlyr    r*   r   r7   r   r   r+   r,   r9   )readerr;   r$   r=   r>   s   &    r   read_message_async"ControlProtocol.read_message_async   s      #..q11t[1!4O444"5fX >?? $//77	6::l11':;; 2 8 ## 	6. 455	6sF   CBAC1B2C7$B  CC C5CCCc                    < V ^8  d   QhRS[ /# rB   r1   )r   r   s   "r   r   r      s     
 
 
r   c                   "   \         P                  V4      pV P                  V4       V P                  4       G Rj  xL
  R#  L5i)zt
Write one message to an async writer.

Args:
    writer: asyncio StreamWriter
    data: Message dictionary to send
N)r   r%   writedrain)writerr   rE   s   && r   write_message_async#ControlProtocol.write_message_async   s2      "006Wllns   :AAAr   Ni   )r   r   r   r   r	   r7   staticmethodr%   r-   r?   rF   rL   rS   r
   __classdictcell__)r   s   @r   r   r      s      (    3 3( (6 (6T 	 	 6 62 
 
r   r   c                H    V ^8  d   QhR\         R\        R\        R\        /# )r   
request_idcommandargsr   )intstrlistr   )r   s   "r   r   r      s(      S 3 d d r   c                &    RT RTRT;'       g    . /# )z
Create a request message.

Args:
    request_id: Unique request identifier
    command: Command name (e.g., "show workers")
    args: Optional list of arguments

Returns:
    Request dictionary
idrY   rZ   r   )rX   rY   rZ   s   &&&r   make_requestr`      s#     	j7

 r   c                <    V ^8  d   QhR\         R\        R\        /# )r   rX   r   r   )r[   r   )r   s   "r   r   r      s!      c   r   c                &    RT RRRT;'       g    / /# )z
Create a success response message.

Args:
    request_id: Request identifier being responded to
    data: Response data

Returns:
    Response dictionary
r_   statusokr   r   )rX   r   s   &&r   make_responsere      s#     	j$

 r   c                <    V ^8  d   QhR\         R\        R\        /# )r   rX   errorr   )r[   r\   r   )r   s   "r   r   r      s!      C   r   c                    RV RRRV/# )z
Create an error response message.

Args:
    request_id: Request identifier being responded to
    error: Error message

Returns:
    Error response dictionary
r_   rc   rg   r   )rX   rg   s   &&r   make_error_responseri      s     	j' r   )N)	r	   r   r    	Exceptionr   r   r`   re   ri   r   r   r   <module>rk      s:   
$   I  J JZ&$r   