+
    i                    f    ^ RI Ht ^ RIt^ RIHtHtHtHt  ! R R4      tR R lt	 ! R R	4      t
R# )
    )annotationsN)ASGI3ApplicationASGIReceiveCallableASGISendCallableScopec                  6    ] tR t^tRtRR R lltR R ltRtR# )	ProxyHeadersMiddlewarea  Middleware for handling known proxy headers

This middleware can be used when a known proxy is fronting the application,
and is trusted to be properly setting the `X-Forwarded-Proto` and
`X-Forwarded-For` headers with the connecting client information.

Modifies the `client` and `scheme` information so that they reference
the connecting client, rather that the connecting proxy.

References:
- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers#Proxies>
- <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For>
c               $    V ^8  d   QhRRRRRR/# )   appr   trusted_hostslist[str] | strreturnNone )formats   "ډC:\Users\petid\OneDrive\Desktop\Maestro\MAESTRO CLAUDE\MAESTRO\maestro-backend\venv\Lib\site-packages\uvicorn\middleware\proxy_headers.py__annotate__#ProxyHeadersMiddleware.__annotate__   s#     : :, :_ :_c :    c                	2    Wn         \        V4      V n        R # N)r   _TrustedHostsr   )selfr   r   s   &&&r   __init__ProxyHeadersMiddleware.__init__   s    *=9r   c               (    V ^8  d   QhRRRRRRRR/# )	r   scoper   receiver   sendr   r   r   r   )r   s   "r   r   r      s+     !4 !4E !44G !4O_ !4dh !4r   c                	p  "   VR ,          R8X  d   V P                  WV4      G Rj  xL
 # VP                  R4      pV'       d
   V^ ,          MRpWPP                  9   d   \        VR,          4      pRV9   dV   VR,          P	                  R4      P                  4       pVR9   d)   VR ,          R	8X  d   VP                  RR4      VR
&   MWqR
&   RV9   dD   VR,          P	                  R4      pV P                  P                  V4      p	V	'       d	   ^ p
W3VR&   V P                  WV4      G Rj  xL
 #  EL L5i)typelifespanNclientheaderss   x-forwarded-protolatin1httpws	websocketschemes   x-forwarded-for>   r(   wssr'   https)r   getr   dictdecodestripreplaceget_trusted_client_host)r   r   r   r    client_addrclient_hostr%   x_forwarded_protox_forwarded_forhostports   &&&&       r   __call__ProxyHeadersMiddleware.__call__   s    =J&%$777ii)(3k!n,,,5+,G#w.$+,@$A$H$H$R$X$X$Z!$(FFV}3*;*C*CFD*Qh*;h!W,")*<"="D"DX"N))AA/R D'+lE(OXXed333? 8> 4s.   $D6D1D6C
D6D6,D4-D64D6)r   r   N)z	127.0.0.1)__name__
__module____qualname____firstlineno____doc__r   r9   __static_attributes__r   r   r   r	   r	      s    :!4 !4r   r	   c                    V ^8  d   QhRRRR/# )r   valuestrr   z	list[str]r   )r   s   "r   r   r   ?   s     7 7C 7I 7r   c                h    V P                  R 4       Uu. uF  qP                  4       NK  	  up# u upi ),)splitr0   )rB   items   & r   _parse_raw_hostsrH   ?   s)    %*[[%56%5TJJL%5666s   /c                  >    ] tR t^CtRtR R ltR R ltR R ltRtR	# )
r   z(Container for trusted hosts and networksc                    V ^8  d   QhRRRR/# )r   r   r   r   r   r   )r   s   "r   r   _TrustedHosts.__annotate__F   s     %8 %8o %8$ %8r   c                	|   VR R .39   V n         \        4       V n        \        4       V n        \        4       V n        V P                   '       g   \        V\        4      '       d   \        V4      pV Fl  pRV9   d3    V P                  P                  \        P                  ! V4      4       K<   V P                  P                  \        P                  ! V4      4       Kn  	  R# R#   \         d     T P                  P                  T4        K  i ; i  \         d     T P                  P                  T4        K  i ; i)*/N)always_trustsettrusted_literalsr   trusted_networks
isinstancerC   rH   add	ipaddress
ip_network
ValueError
ip_address)r   r   r7   s   && r   r   _TrustedHosts.__init__F   s   "/C#<"?*-%QTQVTWTY    --- 0 ?%
 $;8--11)2F2Ft2LM
8**..y/C/CD/IJ &	 ! & 8--11$78 & 8--11$78s$   ;/C$-/D$&DD&D;:D;c                    V ^8  d   QhRRRR/# )r   r7   z
str | Noner   boolr   )r   s   "r   r   rK   m   s     1 1 1 1r   c                	n  a V P                   '       d   R # V'       g   R#  \        P                  ! V4      oSV P                  9   d   R # \        ;QJ d)    V3R lV P
                   4       F  '       g   K   R # 	  R# ! V3R lV P
                   4       4      #   \         d    YP                  9   u # i ; i)TFc              3  .   <"   T F
  pSV9   x  K  	  R # 5ir   r   ).0netips   & r   	<genexpr>-_TrustedHosts.__contains__.<locals>.<genexpr>x   s     B,ASrSy,As   )rO   rU   rX   r   anyrR   rW   rQ   )r   r7   r`   s   &&@r   __contains___TrustedHosts.__contains__m   s    	1%%d+BT'''3BD,A,AB33B3B3BD,A,ABBB 	10000	1s/   'B 

B B 6B 9B =B B43B4c                    V ^8  d   QhRRRR/# )r   r6   rC   r   r   )r   s   "r   r   rK   }   s     ( (s (s (r   c                    \        V4      pV P                  '       d
   V^ ,          # \        V4       F  pW09  g   K  Vu # 	  V^ ,          # )z~Extract the client host from x_forwarded_for header

In general this is the first "untrusted" host in the forwarded for list.
)rH   rO   reversed)r   r6   x_forwarded_for_hostsr7   s   &&  r   r2   %_TrustedHosts.get_trusted_client_host}   sP    
 !1 A(++ 23D 4 %Q''r   )rO   r   rQ   rR   N)	r;   r<   r=   r>   r?   r   rd   r2   r@   r   r   r   r   r   C   s    2%8N1 ( (r   r   )
__future__r   rU   uvicorn._typesr   r   r   r   r	   rH   r   r   r   r   <module>rm      s-    "  Y Y44 44n7K( K(r   