
    kjG_                        d Z ddlZddlZddl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 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  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+ ddl*m,Z, ddl-m.Z.  ej^                  e0      Z1dZ2 G d d      Z3e G d  d!             Z4 G d" d#ejj                  $      Z6 G d% d&e6ejj                  $      Z7 G d' d(e7      Z8e0d)k(  r ejr                         Z: ejv                         Z<e<j{                  d*e>d+d,       e<j{                  d-e?d.d/d01       e<j{                  d2e>d+d3       d4 Z@ ej                  e@d5d6e:7      ZBe:j                  eB      ZDeDj                  sJ  eFd8 e,j                  eDj                  d   j                                       	 e:j                          eDj                          e:j                  eDj                                e:j                          yy# eJ$ r Y Hw xY w)9a?  
Proxy Server Implementation using asyncio.
The very high level overview is as follows:

    - Spawn one coroutine per client connection and create a reverse proxy layer to example.com
    - Process any commands from layer (such as opening a server connection)
    - Wait for any IO and send it as events to top layer.
    N)	Awaitable)Callable)MutableMapping)contextmanager)	dataclass)TracebackType)Literal)SSL)http)options)tls)Address)Client)
Connection)ConnectionState)commands)events)layer)layers)
mode_specs)server_hooks)Context)HTTPMode)asyncio_utils)human)pkg_data   c                       e Zd ZU eed<   eed<   ej                  ed<   eed<   dedeg e	f   fdZ
d Zd Zed	        Zy
)TimeoutWatchdoglast_activitytimeoutcan_timeoutblockercallbackc                     || _         || _        t        j                         | _        t	        j
                         | _        | j                  j                          d| _        y )Nr   )	r!   r$   timer    asyncioEventr"   setr#   )selfr!   r$   s      _/home/ubuntu/.cache/pipx/cdb5059130eadca/lib/python3.12/site-packages/mitmproxy/proxy/server.py__init__zTimeoutWatchdog.__init__8   sE     !YY["==?    c                 6    t        j                          | _        y N)r&   r    r*   s    r+   register_activityz!TimeoutWatchdog.register_activity@   s    !YY[r-   c                   K   	 	 | j                   j                          d {    t        j                  | j                  t        j
                         | j                  z
  z
         d {    | j                  | j                  z   t        j
                         k  r| j                          d {    y 7 7 N7 
# t        j                  $ r Y y w xY wwr/   )	r"   waitr'   sleepr!   r&   r    r$   CancelledErrorr0   s    r+   watchzTimeoutWatchdog.watchC   s     	&&++---mmDLLDIIK$BTBT4T$UVVV%%4tyy{B--/)) -V)%% 		s^   CB> B8AB> +B:,AB> 1B<2B> 6C7B> :B> <B> >CCCCc              #     K   | j                   j                          | xj                  dz  c_        	 d  | xj                  dz  c_        | j                  dk(  r+| j                          | j                   j	                          y y # | xj                  dz  c_        | j                  dk(  r+| j                          | j                   j	                          w w xY ww)N   r   )r"   clearr#   r1   r)   r0   s    r+   disarmzTimeoutWatchdog.disarmN   s      	'LLAL||q &&(  $$& ! LLAL||q &&(  $$& !s   0CB ACACCN)__name__
__module____qualname__float__annotations__intr'   r(   r   r   r,   r1   r6   r   r:    r-   r+   r   r   2   sV    LL xI/F )	 	' 	'r-   r   c                       e Zd ZU dZej
                  dz  ed<   dZej                  e	j                  z  dz  ed<   dZej                  e	j                  z  dz  ed<   y)ConnectionIONhandlerreaderwriter)r;   r<   r=   rD   r'   Taskr?   rE   StreamReadermitmproxy_rsStreamrF   StreamWriterrA   r-   r+   rC   rC   [   sU    #'GW\\D '@DFG  <#6#66=D@DFG  <#6#66=Dr-   rC   c                      e Zd ZU eeef   ed<   eed<   eed<   e	j                  eej                  f   ed<   ded<   eej                     ed<   ded	d
fdZd!dZdej(                  d	d
fdZdej,                  d	d
fdZded	d
fdZd Zd!dZdej6                  d	d
fdZej<                  dej6                  d	d
fd       Ze jB                  d
fde"de#de$d   e%e&e'   e'e(d
z  f   z  d
z  d	d
fdZ)de*jV                  d	d
fdZ,	 d"dede-d	d
fd Z.y
)#ConnectionHandler
transportstimeout_watchdogclient	max_connszlayer.Layerr   wakeup_timercontextreturnNc                    |j                   | _         i | _        t        j                  d       | _        t               | _        t        j                  |d      | _        | j                   j                  dk(  r|j                  j                  }nt        }t        || j                        | _        t!        j"                         | _        t!        j"                         | _        y )Nc                  ,    t        j                  d      S )N   )r'   	SemaphorerA   r-   r+   <lambda>z,ConnectionHandler.__init__.<locals>.<lambda>m   s    9J9J19M r-   T)ask_on_starttcp)rP   rN   collectionsdefaultdictrQ   r)   rR   r   	NextLayertransport_protocolr   tcp_timeoutUDP_TIMEOUTr   
on_timeoutrO   r'   Lock_server_event_lock_drain_lock)r*   rS   r!   s      r+   r,   zConnectionHandler.__init__j   s    nn$001MNE
 __W4@
;;))U2oo11G!G / I"),,. #<<>r-   c                   K   t        j                  d| j                  j                         t        j                  | j
                  j                         dd| j                  j                        }| j                  d       | j                  t        j                  | j                               d {    | j                  j                  rV| j                  d       | j                  j                  | j                        j                  }|sJ |j                          n
| j!                  t#        j$                                d {    t        j                  | j'                  | j                        dd| j                  j                        }|| j                  | j                     _        t+        j,                  |g       d {    |j/                         sM|j1                         x}r;| j                  d	| t2        j4                  t7        |      ||j8                  f
       |j;                          | j<                  r7| j<                  j                         }|j;                          | j<                  r7| j                  d       t?        j>                         | j                  _         | j                  t        jB                  | j                               d {    | j                  r| j                  dt2        jD                         | j                  jG                         D ]*  }|j(                  s|j(                  j;                  d       , t+        j,                  | j                  jG                         D cg c]  }|j(                  s|j(                   c}       d {    | j                  dt2        jD                         y y 7 '7 7 7 c c}w 7 6w)Nzclient handler)namerP   ztimeout watchdogFrg   keep_refrP   zclient connectzclient kill connectionzclient connection handlerz connection handler has crashed: exc_infozclient disconnectzclosing transports...zclient disconnectedztransports closed!)$r   set_current_task_debug_inforP   peernamecreate_taskrO   r6   loghandle_hookr   ClientConnectedHookerrorrN   poprF   closeserver_eventr   Starthandle_connectionrD   r'   r3   	cancelled	exceptionloggingERRORtype__traceback__cancelrR   r&   timestamp_endClientDisconnectedHookDEBUGvalues)r*   r6   rF   rD   etimerioxs           r+   handle_clientzConnectionHandler.handle_client   s    11!;;''	
 ))!!'')#;;''	
 	!"|??LMMM;;HH-.__((5<<FM6LLN##FLLN333#//&&t{{30{{++	G 4;DOODKK(0,,y)))$$&1B1B1D,DA,D6qc:MM"1gq!//:   	%%))+ELLN  	$%$(IIK!|BB4;;OPPP??HH,gmm<oo,,. =::JJ%%&;<= ,,$(OO$:$:$<Jq		J   HH)7==9 A 	N 4 * 	Q Ks~   B3O.5O6BO.OBO.O"B3O.A%O.(O%)AO.AO.O'O'+
O.5O,6'O.O."O.%O.'O.commandc                 b  K   |j                   j                  s?| j                  d       | j                  t	        j
                  |d             d {    y t        j                  | j                  |j                         }| j                  t        j                  |             d {    |j                   j                  x}r| j                  dt        j                  |j                   j                         d|        | j                  t        j                  |             d {    | j                  t	        j
                  |d|              d {    y | j                  |j                   j                     4 d {    	 t!        j                          |j                   _        |j                   j$                  dk(  rIt'        j(                  |j                   j                  d|j                   j*                  i d {   \  }}n|j                   j$                  dk(  rRt-        j.                  j0                  |j                   j                  d|j                   j*                  i d {   x}}nt3        |j                   j$                        |j                   j$                  dk(  r#t!        j                          |j                   _        t6        j8                  |j                   _        |j=                  d	      |j                   _        |j=                  d
      |j                   _        tA        t'        jB                         ||      | jD                  |j                   <   |j                   j>                  sJ |j                   j                  d   |j                   j>                  d   k7  rWt        j                  |j                   j                         dt        j                  |j                   j>                         d}n)t        j                  |j                   j                        }| j                  d|        | j                  t        jF                  |             d {    | j                  t	        j
                  |d              d {    	 | jI                  |j                          d {    | j                  d|        t!        j                          |j                   _%        | j                  t        jL                  |             d {    d d d       d {    y 7 7 7 7 7 7 D7 7 7 7 7 0# | j                  d|        t!        j                          |j                   _%        | j                  t        jL                  |             d {  7   w xY w# tN        t&        jP                  f$ r}tS        |      }|sd}| j                  d|        ||j                   _        | j                  t        j                  |             d {  7   | j                  t	        j
                  ||             d {  7   tU        |t&        jP                        r Y d }~`d }~ww xY w7 ]# 1 d {  7  sw Y   y xY ww)Nz*Cannot open connection, no hostname given.)rP   serverzserver connection to z killed before connect: zConnection killed: r[   
local_addrudprm   socknamerD   rE   rF   r   z ()zserver connect zserver disconnect zconnection cancelledz&error establishing server connection: )+
connectionaddressro   ru   r   OpenConnectionCompletedr   ServerConnectionHookDatarP   rp   ServerConnectHookrr   r   format_addressServerConnectErrorHookrQ   r&   timestamp_startr_   r'   open_connectionr   rI   r   open_udp_connectionAssertionErrortimestamp_tcp_setupr   OPENstateget_extra_inform   rC   current_taskrN   ServerConnectedHookrw   r   ServerDisconnectedHookOSErrorr5   str
isinstance)r*   r   	hook_dataerrrE   rF   addrr   s           r+   r   z!ConnectionHandler.open_connection   s    !!))HHAC##..I  
  99;;w'9'9
	 |==iHIII$$***3*HH'(<(<W=O=O=W=W(X'YYqruqvw ""<#F#Fy#QRRR##..w:McU8ST   >>'"4"4"<"<= ;	 ;	859YY[""2%%88EA+2+B+B ++33,#*#5#5#>#>, &NFF ''::eC,8,<,<,P,P ++33-#*#5#5#>#>- ' FV
 )););)N)NOO %%88EA=AYY[G&&:+:+?+?""(.4.C.CJ.O""+.4.C.CJ.O""+6B#002!!7 2 23 ))2222%%--a0G4F4F4O4OPQ4RR#2273E3E3M3MNOrRWRfRfgngygy  hC  hC  SD  RE  EF  GD //0B0B0J0JKD?4&12&&|'G'G	'RSSS''(F(FwPT(UVVV001C1CDDDHH1$897;yy{G&&4**$;;IF  s;	 ;	 ;	+ 	J
 S
;	&
'L TV E HH1$897;yy{G&&4**$;;IF  Q W334 !f0CA#GH+.""(&&|'J'J9'UVVV''(F(FwPS(TUUUa!7!78 	 9#;	 ;	 ;	 ;	sj  AZ/U AZ/*U+BZ/,U-/Z/U	,Z/	U
Z/ZA<WUA+W7U8&WGZ6U7,Z#U$Z)UUUAZ*U+Z/Z/:Z;Z/Z/Z/	Z/Z/WWZZUZAW<V?
=WZZAZ:X=;-Z(Y+) Z	ZZZZ/Z, Z#!Z,(Z/requestc                    K   t        j                  |j                         d {    t        j                         }|J | j                  j                  |       | j                  t        j                  |             d {    y 7 d7 wr/   )	r'   r4   delayr   rR   discardru   r   Wakeup)r*   r   tasks      r+   wakeupzConnectionHandler.wakeup  sr     mmGMM***##%!!$'g 6777	 	+ 	8s"   #BB
ABBBBr   c                 R  K   d}| j                   |   j                  }|sJ 	 	 |j                  d       d{   }|st        d      	 | j                  t        j                  ||             d{    	 | j                          d{    o7 Y# t        $ r Y nGt        j
                  $ r}|}Y d}~n.d}~ww xY w7 L7 5# t        j
                  $ r}|}Y d}~nd}~ww xY w|4|j                  dk(  r%|xj                  t        j                   z  c_        nt        j                  |_        | j                  t        j                  |             d{  7   |j                  t        j                   u rO	 t	        j"                         j%                          d{  7   n"# t        j
                  $ r}|}Y d}~nd}~ww xY w	 | j                   |   j&                  }|sJ |j)                          n# t        $ r Y nw xY w| j                   j+                  |       |r|yw)z
        Handle a connection for its entire lifetime.
        This means we read until EOF,
        but then possibly also keep on waiting for our side of the connection to be closed.
        Ni  zConnection closed by peer.r[   )rN   rE   readr   r'   r5   ru   r   DataReceiveddrain_writersr_   r   r   CAN_READCLOSEDConnectionClosed	CAN_WRITEr(   r3   rF   rt   rs   )r*   r   rx   rE   datar   rF   s          r+   rw   z#ConnectionHandler.handle_connection  s     	,33v#[[//!">??  ##F$7$7
D$IJJJ((*** /  )) 	 K +)) 	 !>!>%!G!9!9 99.55J 7 7
 CDDD888mmo**,,,)) 		__Z077FM6LLN 		J'O s   !H'B BB 
)H'3C 4H'9C CC H'B 	B=H'B=1B83H'8B==H'C C#CH'C##A5H'E!H';%F'  F#!F' &H''G:G<H'GH'
-G8 7H'8	HH'H#H'c                   K   | j                   4 d{    t        | j                  j                               D ]2  }|j                  	 |j                  j                          d{    4 ddd      d{    y7 m7 # t        $ r4}|j                  |j                  j                  d|        Y d}~d}~ww xY w7 I# 1 d{  7  sw Y   yxY ww)z
        Drain all writers to create some backpressure. We won't continue reading until there's space available in our
        write buffers, so if we cannot write fast enough our own read buffers run full and the TCP recv stream is throttled.
        NzError sending data: )	re   listrN   r   rF   drainr   rD   r~   )r*   	transportr   s      r+   r   zConnectionHandler.drain_writersJ  s     
 ## 	Q 	Q!$//"8"8":; Q	##/Q'..44666Q	Q 	Q 	Q 7" Q$,,8%--447KA35OPQ	Q 	Q 	Q 	Qs   CBC3CB)B*B.C0C;C<CB	C*B=8C=CCCCCCCc                 
  K   	 | j                   | j                     j                  }| j                  j                  dk(  r| j	                  d| j                          |sJ |j                  d       y # t        $ r Y y w xY ww)Nr[   z&Closing connection due to inactivity: r!   )rN   rP   rD   r_   ro   r~   KeyError)r*   rD   s     r+   rb   zConnectionHandler.on_timeoutX  su     		&oodkk2::G
 {{--6A$++OPN7NN9%  		s(   B#A4 AB4	B =B?B  Bhookc                    K   | j                  |       d {    |j                  r-| j                  t        j                  |             d {    y y 7 >7 wr/   )rp   blockingru   r   HookCompletedr*   r   s     r+   	hook_taskzConnectionHandler.hook_taskd  sN     t$$$==##F$8$8$>???  	%?s!   AA7AAAAc                    K   y wr/   rA   r   s     r+   rp   zConnectionHandler.handle_hooki  s	     s   messagelevelrk   Tc                 b    t         j                  ||d| j                  j                  i|       y )NrP   )extrark   )loggerro   rP   rm   )r*   r   r   rk   s       r+   ro   zConnectionHandler.logm  s-     	

78T[[-A-A"BX 	 	
r-   eventc                 r  K   | j                   4 d {    | j                  j                          	 | j                  j	                  |      }|D ]  }t        |t        j                        r|j                  | j                  vsJ t        j                  | j                  |      d|j                  j                   d| j                  j                        }t!        |      | j                  |j                  <   t        |t        j"                        rlt        j                  | j%                  |      d|j&                  ddd| j                  j                        }|J | j(                  j+                  |       5t        |t        j,                        r|j                  | j                  vrit        |t        j.                        rV| j                  |j                     j0                  }|sJ |j3                         r|j5                  |j6                         t        |t        j8                        r(| j;                  |j                  |j<                         t        |t        j>                        r| j;                  |j                  d       St        |t        j@                        rLt        j                  | jC                  |      d|jD                   d	d
| j                  j                         t        |t        jF                        r(| jI                  |jJ                  |jL                         tO        d|        	 d d d       d {    y 7 Y# tP        $ r% | jI                  dtR        jT                  d
       Y Aw xY w7 9# 1 d {  7  sw Y   y xY ww)Nzserver connection handler Frh   )rD   zwakeup timer (z.1fzs)zhandle_hook(r   TzUnexpected command: zmitmproxy has crashed!rj   )+rd   rO   r1   r   handle_eventr   r   OpenConnectionr   rN   r   rn   r   r   rP   rm   rC   RequestWakeupr   r   rR   addConnectionCommandSendDatarF   
is_closingwriter   CloseTcpConnectionclose_connection
half_closeCloseConnection	StartHookr   rg   Logro   r   r   RuntimeError	Exceptionrz   r{   )r*   r   layer_commandsr   rD   r   rF   s          r+   ru   zConnectionHandler.server_eventy  s     ** 5	R 5	R !!3351R!%!8!8!?- -MG!'8+B+BC&11HHH"/";"; 009#=g>P>P>X>X=Y!Z%*#';;#7#7	# ?K$+?(:(:; $GX-C-CD,88 KK0#1'--1DB!G%*#';;#7#7	   $///))--d3"7H,F,FG#..dooE#GX->->?!%1C1C!D!K!K%v%002"LL6#GX-H-HI--g.@.@'BTBTU#GX-E-EF--g.@.@%H#GX-?-?@%11 NN73#/~Q!?%)#';;#7#7	 $GX\\:'--@*-A'+KLL[-M5	R 5	R 5	Rh  R1GMMDQRi5	R 5	R 5	R 5	Rso   N7M,N7N"GM/EM/N"N7&N 'N7/+NN"NN" N7"N4(N+)N40N7r   c                 X   |r|j                   t        j                  z  sy | j                  d| t        j
                         	 | j                  |   j                  }|sJ |j                         s|j                          |xj                   t        j                   z  c_         nt        j                  |_         |j                   t        j                  u r/| j                  |   j                  }|sJ |j                  d       y y # t        $ r t        j                  |_         Y lw xY w)Nzhalf-closing zclosed by command)r   r   r   ro   rz   r   rN   rF   r   	write_eofr   r   rD   r~   )r*   r   r   rF   rD   s        r+   r   z"ConnectionHandler.close_connection  s     ##o&?&??HH}ZL17==A	?4;;v((*$$&
   _%>%>$>> .55J555ooj199GN7NN./ 6  :#2#9#9
 :s   =D D)(D))rT   N)F)/r;   r<   r=   r   r   rC   r?   r   r   r\   r]   r   r'   rX   r)   rG   r   r,   r   r   r   r   r   r   rw   r   rb   r   r   abcabstractmethodrp   rz   INFOr   r@   r	   tupler|   BaseExceptionr   ro   r   r(   ru   boolr   rA   r-   r+   rM   rM   b   s   z<788%%N&&w0A0A'ABBgll##* *D **5:nSX-D-D S Sj8H$:$: 8t 86* 6 6pQ
&@H$6$6 @4 @
 	h&8&8 T   \\ 



 

 $-
]#]MD4HH
IJ
	

 


<R <R <R~ :?0$0260	0r-   rM   )	metaclassc            
            e Zd Zdej                  ej                  z  dej                  ej                  z  dej                  de
j                  ddf
 fdZ xZS )LiveConnectionHandlerrE   rF   r   moderT   Nc                 0   t        |j                  dd      |j                  d      |j                  d      t        j                         |t        j                        }t        ||      }t        |   |       t        d ||      | j                  |<   y )Nr_   r[   rm   r   )r_   rm   r   r   
proxy_moder   r   )
r   r   r&   r   r   r   superr,   rC   rN   )r*   rE   rF   r   r   rP   rS   	__class__s          r+   r,   zLiveConnectionHandler.__init__  s     %445I5Q**:6**:6 IIK!&&
 &'*!".#
r-   )r;   r<   r=   r'   rH   rI   rJ   rK   moptionsOptionsr   	ProxyModer,   __classcell__r   s   @r+   r   r     sk    
$$|':'::
 $$|':'::
 !!	

 ""
 

 
r-   r   c                   \     e Zd ZU dZeeef   ed<    fdZde	j                  ddfdZ xZS )SimpleConnectionHandlerz6Simple handler that does not really process any hooks.hook_handlersc                 8    t         |   ||||       || _        y r/   )r   r,   r   )r*   rE   rF   r   r   r   r   s         r+   r,   z SimpleConnectionHandler.__init__  s    $7*r-   r   rT   Nc                    K   |j                   | j                  v r+ | j                  |j                      |j                           y y wr/   )rg   r   argsr   s     r+   rp   z#SimpleConnectionHandler.handle_hook  s<     99***)Dtyy)499;7 +s   AA)r;   r<   r=   __doc__dictr   r   r?   r,   r   r   rp   r   r   s   @r+   r   r     s3    @X&&+8h&8&8 8T 8r-   r   __main__store_streamed_bodiesF connection_strategylazyz8Determine when server connections should be established.)eagerr   )choiceskeep_host_headerz{
        Reverse Proxy: Keep the original host header instead of rewriting it
        to the reverse proxy target.
        c                 X  K   d d gdt         j                  ffd}dt        j                  fd}dt        j
                  fd}dt        j
                  fd	}t        | |t        t        j                  j                  d
      ||||d      j                          d {    y 7 w)Nc                 @    t         j                  j                  |       S r/   )r   modesReverseProxyctxs    r+   rY   zhandle.<locals>.<lambda>  s    11#6 r-   c                 J    t        j                  | t        j                        S r/   )r   	HttpLayerr   transparentr  s    r+   rY   zhandle.<locals>.<lambda>  s    ((h.B.BC r-   nlc                      j                  d      | j                        }dt        | j                  j                        z  |_        || _        y )Nr   z  )rs   rS   lenr   debugr   )r  layrlayer_stacks     r+   
next_layerzhandle.<locals>.next_layer  s>    %;??1%bjj1DBJJ$5$5 66DJBHr-   flowc                 P   d| j                   j                  v r<t        j                  j	                  dd| j                   j
                         | _        d| j                   j                  v r| j                   j                  j                  d      r6| j                   j                  j                  dd      | j                   _        n5| j                   j                  j                  dd      | j                   _        d| j                   j                  v rd| j                   _
        y y )	Ncachedi  z	(cached) z
toggle-tlszhttps://zhttp://redirectzhttpbin.org)r   pathr   Responsemaketextresponseurl
startswithreplacehost)r  s    r+   r   zhandle.<locals>.request"  s    4<<,,, $ 2 23)DLLDUDUCV8W Xt||000<<##..z:'+||'7'7'?'?
I'VDLL$'+||'7'7'?'?	:'VDLL$T\\...$1! /r-   	tls_startc                 B   t        j                  t         j                        }|j                  t	        j
                  d             |j                  t	        j
                  d             t        j                  |      | _        | j                  j                          y )Nz9../test/mitmproxy/data/verificationcerts/trusted-leaf.keyz9../test/mitmproxy/data/verificationcerts/trusted-leaf.crt)
r
   r   SSLv23_METHODuse_privatekey_filer   r  use_certificate_chain_filer   ssl_connset_accept_stater  ssl_contexts     r+   tls_start_clientz handle.<locals>.tls_start_client-  sw    ++c&7&78K++O
 22O
 "%!<I//1r-   c                    t        j                  t         j                        }t        j                  |      | _        | j                  j                          | j                  j                  j                  H| j                  j                  | j                  j                  j                  j                                y y r/   )r
   r   r!  r   r$  set_connect_staterS   rP   sniset_tlsext_host_nameencoder&  s     r+   tls_start_serverz handle.<locals>.tls_start_server=  s    ++c&7&78K!$!<I002  ''++7""77%%,,00779 8r-   zreverse:http://127.0.0.1:3000/)r  r   r(  r.  )r   r^   r   HTTPFlowr   TlsDatar   optsr   r   parser   )rE   rF   r  r   r(  r.  r  s         @r+   handler3    s      7C
	5?? 	
		2$-- 		2	2 	2 	 	 &  &&'GH("$4$4	
 -/	 	s   BB*"B(#B*z	127.0.0.1i  )loopzServing on )Mr   r   r'   r\   rz   r&   collections.abcr   r   r   
contextlibr   dataclassesr   typesr   typingr	   OpenSSLr
   rI   	mitmproxyr   r   r   r   mitmproxy.connectionr   r   r   r   mitmproxy.proxyr   r   r   r   r   r   mitmproxy.proxy.contextr   mitmproxy.proxy.layers.httpr   mitmproxy.utilsr   r   mitmproxy.utils.datar   	getLoggerr;   r   ra   r   rC   ABCMetarM   r   r   get_event_loopr4  r   r1  
add_optionr   r   r3  start_servercororun_until_completer   socketsprintr   getsocknamerun_foreverKeyboardInterruptrt   wait_closedrA   r-   r+   <module>rO     s"        % $ * % !      )  ( ' + 0 $ " ! " & ( + 0 ) ! )			8	$&' &'R E E El0#++ l0^
- 
.83 8 z!7!!#D8DOO
	 	OOB!   	OO		?B  7TED$$T*F >>>	K,,,V^^A->-J-J-LMN
OP
 LLNF..01JJLY L  s   1I I
	I
