Ë
    tPêj 
  ã                   óÚ   — U d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	m
Z
 dZeed<   deeef   fd„Z	 dd
eeef   d	z  dee   fd„Zdeded	z  fd„Zd	edœded
eeef   d	z  dededd	f
d„Zy	)é    )ÚAnyÚFinal)ÚRequest)Úverbose_proxy_logger)Úip_in_networksÚnormalize_cidr_rangesÚparse_trusted_proxy_rangesÚtrusted_proxy_rangesÚTRUSTED_PROXY_RANGES_KEYÚreturnc                  ó>   — 	 ddl m}  | xs i S # t        $ r i cY S w xY w)Nr   ©Úgeneral_settings)Úlitellm.proxy.proxy_serverr   ÚImportErrorr   s    úk/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/proxy/auth/trusted_proxy_utils.pyÚ_get_proxy_general_settingsr      s)   € ðÝ?àÒ% 2Ð%øÜò ØŠ	ðús   ‚ Ž›Nr   c                 ób   — | €
t        «       } t        | j                  t        «      t        ¬«      S )zÒOperator-configured trusted reverse-proxy CIDRs, normalized to strings.

    Empty when none are configured, in which case X-Forwarded-For must not be
    trusted and only the direct peer is authoritative.
    ©Úsetting_name)r   r   Úgetr   r   s    r   Úget_trusted_proxy_cidrsr      s2   € ð ÐÜ6Ó8ÐÜ Ø×ÑÔ5Ó6Ü-ôð ó    Úrequestc                 ó\   — t        | dd «      }t        |dd «      }t        |t        «      r|S y )NÚclientÚhost)ÚgetattrÚ
isinstanceÚstr)r   r   Úclient_hosts      r   Ú_get_direct_client_ipr"   (   s1   € Ü˜G X¨tÓ4€FÜ  ¨°Ó6€KÜ�+œsÔ#ØÐØr   )r   r   Úfeature_namer   c                 óø   — |€
t        «       }t        |j                  |«      |¬«      }|st        |› d|› d�«      ‚t	        | «      }t        ||«      s(t        j                  d||«       t        |› d|›d�«      ‚y)a  
    Fail closed unless the direct TCP peer is one of the configured
    trusted reverse proxies.

    Header-based auth paths must validate the direct peer, not
    X-Forwarded-For, because the direct peer is the actor supplying the
    identity headers.
    Nr   z requires general_settings.z9 before trusting identity headers from an upstream proxy.z?%s rejected identity headers from untrusted direct client IP %rzV only accepts identity headers from configured trusted proxy ranges. Direct client IP z is not trusted.)r   r	   r   Ú
ValueErrorr"   r   r   Úwarning)r   r   r#   r   Útrusted_networksÚdirect_client_ips         r   Úrequire_trusted_proxy_requestr)   0   sµ   € ð ÐÜ6Ó8Ðä8Ð9I×9MÑ9MÈlÓ9[ÐjvÔwÐÙÜØˆnÐ7¸°~ð F@ð @ó
ð 	
ô
 4°GÓ<ÐÜÐ*Ð,<Ô=Ü×$Ñ$ØMØØô	
ô
 Øˆnð 6Ø6FÐ5Ið Jðó
ð 	
ð >r   )N)Útypingr   r   Úfastapir   Úlitellm._loggingr   Úlitellm.proxy.auth.networkr   r   r	   r   Ú__annotations__Údictr    r   Úlistr   r"   r)   © r   r   ú<module>r2      sÈ   ðß Ð å å 1÷ñ ð #9Ð ˜%Ó 8ð T¨#¨s¨(¡^ó ð /3ñØ˜3 ˜8‘n tÑ+ðà	ˆ#�Yóð  7ð ¨s°T©zó ð /3à0ò$
àð$
ð ˜3 ˜8‘n tÑ+ð$
ð ð	$
ð
 ð$
ð 
ô$
r   