
    @OOf                        U d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd	lmZ dd
lmZ  G d d      Z G d de      Ze G d de             Ze G d de             Z G d de      Z G d de      Zi Zeej.                  ee   f   ed<    ed       G d de             Z ed       G d de             Z ed      Ze G d d eee                Ze G d! d"e             Zy)#z
When IO actions occur at the proxy server, they are passed down to layers as events.
Events represent the only way for layers to receive new data from sockets.
The counterpart to events are commands.
    N)	dataclass)is_dataclass)Any)Generic)TypeVar)flow)
Connection)commandsc                       e Zd ZdZd Zy)Eventz$
    Base class for all events.
    c                 ^    t        |       j                   dt        | j                         dS )N())type__name__repr__dict__selfs    W/var/www/premiumrankchecker/venv/lib/python3.12/site-packages/mitmproxy/proxy/events.py__repr__zEvent.__repr__   s*    t*%%&aT]](;'<A>>    N)r   
__module____qualname____doc__r    r   r   r   r      s    ?r   r   c                       e Zd ZdZy)Startze
    Every layer initially receives a start event.
    This is useful to emit events on startup.
    Nr   r   r   r   r   r   r   r   r      s    r   r   c                       e Zd ZU dZeed<   y)ConnectionEventz-
    All events involving connection IO.
    
connectionN)r   r   r   r   r	   __annotations__r   r   r   r!   r!   $   s     r   r!   c                   "    e Zd ZU dZeed<   d Zy)DataReceivedz$
    Remote has sent some data.
    datac                     t        | j                        j                  j                         }d| d| j                  dS )NzDataReceived(, r   )r   r"   r   lowerr&   )r   targets     r   r   zDataReceived.__repr__5   s8    doo&//557vhbQ77r   N)r   r   r   r   bytesr#   r   r   r   r   r%   r%   -   s     K8r   r%   c                       e Zd ZdZy)ConnectionClosedz)
    Remote has closed a connection.
    Nr   r   r   r   r-   r-   :   s    r   r-   c                   X     e Zd ZU dZej
                  ed<   eed<    fdZd Z	d Z
 xZS )CommandCompletedz
    Emitted when a command has been finished, e.g.
    when the master has replied or when we have established a server connection.
    commandreplyc                 b    | t         u rt        d      t        |       sJ t        |   |       S )Nz2CommandCompleted may not be instantiated directly.)r/   	TypeErrorr   super__new__)clsargskwargs	__class__s      r   r5   zCommandCompleted.__new__I   s5    ""PQQC   ws##r   c                    t        j                  |       j                  dd       }t        |t              xr. t        |t        j                        xr |t        j                  u}|st        j                  |  dt               |t        v r,t        |   }t        j                  d| d|  d| t               | t        |<   y )Nr0   z. needs a properly annotated command attribute.zTwo conflicting subclasses for z: z and )typingget_type_hintsget
isinstancer   
issubclassr
   CommandwarningswarnRuntimeWarningcommand_reply_subclasses)r6   r8   command_clsvalid_command_subclassothers        r   __init_subclass__z"CommandCompleted.__init_subclass__O   s    ++C044YE{D) 4;(8(8948#3#33 	
 &MM%EF 22,[9EMM1+bU5'R 14 -r   c                 `    dt        | j                         dt        | j                         dS )NzReply(r(   r   )r   r0   r1   r   s    r   r   zCommandCompleted.__repr__c   s+    T\\*+2d4::.>-?qAAr   )r   r   r   r   r
   r@   r#   r   r5   rH   r   __classcell__)r9   s   @r   r/   r/   @   s+    
 J$4(Br   r/   rD   F)r   c                   <    e Zd ZU ej                  ed<   edz  ed<   y)OpenConnectionCompletedr0   Nr1   )r   r   r   r
   OpenConnectionr#   strr   r   r   rL   rL   j   s    $$$:r   rL   c                   :    e Zd ZU ej                  ed<   dZded<   y)HookCompletedr0   Nr1   )r   r   r   r
   	StartHookr#   r1   r   r   r   rP   rP   q   s    E4r   rP   Tc                   :    e Zd ZU dZej
                  ed<   eed<   y)MessageInjectedzC
    The user has injected a custom WebSocket/TCP/... message.
    r   messageN)r   r   r   r   r   Flowr#   rR   r   r   r   rT   rT   z   s     ))OJr   rT   c                   0    e Zd ZU dZej
                  ed<   y)WakeupzK
    Event sent to layers that requested a wakeup using RequestWakeup.
    r0   N)r   r   r   r   r
   RequestWakeupr#   r   r   r   rX   rX      s     ###r   rX   )r   r;   rA   dataclassesr   r   r   r   r   	mitmproxyr   mitmproxy.connectionr	   mitmproxy.proxyr
   r   r   r!   r%   r-   r/   rD   dictr@   r   r#   rL   rP   rR   rT   rX   r   r   r   <module>r_      s@     ! $     + $? ?E  e   	8? 	8 	8 $Bu $BN LN $x//6F1GGH M .   $  
 CL eWQZ   $ $ $r   