
    vKg                        S SK r S SKrS SKrS SKJr  S SKJrJr  SSKJ	r	   SS/r
S\S	\4S
 jrSS/rS\S	\4S jrS\S	\4S jrS\S\S	\4S jrS\S\\   S	\4S jr     SS\S\S\\   S\S\\   S\\   S\S	\4S jjrg)    N)Optional)unquoteurlparse   )WebSocketProxyException	parse_urlget_proxy_infourlreturnc                    SU ;  a  [        S5      eU R                  SS5      u  p[        U SS9nUR                  (       a  UR                  nO[        S5      eSnUR                  (       a  UR                  nSnUS	:X  a
  U(       d  S
nO US:X  a  SnU(       d  SnO[        SU-  5      eUR
                  (       a  UR
                  nOSnUR                  (       a  USUR                   3-  nX4Xe4$ )z
parse url and the result is tuple of
(hostname, port, resource path and the flag of secure mode)

Parameters
----------
url: str
    url string.
:zurl is invalidr   http)schemezhostname is invalidr   FwsP   wssTi  zscheme %s is invalid/?)
ValueErrorsplitr   hostnameportpathquery)r
   r   parsedr   r   	is_secureresources          N/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/websocket/_url.pyr   r      s     #~)**))C#KFc&)F??.//D{{{{I~D	5	D/&899{{;;||a~&&8..    	localhostz	127.0.0.1addrc                 f     [         R                  " U 5        g! [         R                   a     gf = f)NTF)socket	inet_atonerror)r!   s    r   _is_ip_addressr&   O   s2      << s    00r   c                      U R                  S5      u  p[        U5      =(       a    S[        U5      s=:*  =(       a    S:  $ s  $ ! [         a     gf = f)Nr   r       F)r   r&   intr   )r   r!   netmasks      r   _is_subnet_addressr+   X   sP     s+d#>S\(>(>B(>>(>> s   ?A A 
AAipnetc                    [         R                  " S[        R                  " U 5      5      S   nUR	                  S5      u  p4[         R                  " S[        R                  " U5      5      S   nSS[        U5      -
  -  S-  nX$-  U:H  $ )Nz!Ir   r   l    r(   )structunpackr#   r$   r   r)   )r,   r-   ipaddrnetaddrr*   s        r   _is_address_in_networkr3   `   sx    --f&6&6r&:;A>Fyy~G==v'7'7'@A!DGb3w</0J>Gw&&r   no_proxyc           	      B   U(       df  [         R                  R                  S[         R                  R                  SS5      5      R                  SS5      =n(       a  UR	                  S5      nU(       d  [
        nSU;   a  gX;   a  g[        U 5      (       a6  [        U Vs/ sH   n[        U5      (       d  M  [        X5      PM"     sn5      $ U Vs/ sH  oDR                  S5      (       d  M  UPM     sn H  nU R                  U5      (       d  M    g   g	s  snf s  snf )
Nr4   NO_PROXY  ,*T.F)osenvirongetreplacer   DEFAULT_NO_PROXY_HOSTr&   anyr+   r3   
startswithendswith)r   r4   vsubnetdomains        r   _is_no_proxy_hostrG   i   s    

z2::>>*b+IJRR
 
1 
 wws|H(
hh '&F%f- 9&x8&
 	
 )1Kf4E4Ec4J6KV$$ L  Ls   !D8DD.Dr   
proxy_host
proxy_port
proxy_auth
proxy_typec                    [        X5      (       a  gU(       a  U(       d  [        S5      eUnUnX'U4$ U(       a  SOSn	[        R                  R	                  U	[        R                  R	                  U	R                  5       S5      5      R                  SS5      n
U
(       aa  [        U
5      nUR                  (       a*  [        UR                  5      [        UR                  5      4OSnUR                  UR                  U4$ g)a<  
Try to retrieve proxy host and port from environment
if not provided in options.
Result is (proxy_host, proxy_port, proxy_auth).
proxy_auth is tuple of username and password
of proxy authentication information.

Parameters
----------
hostname: str
    Websocket server name.
is_secure: bool
    Is the connection secure? (wss) looks for "https_proxy" in env
    instead of "http_proxy"
proxy_host: str
    http proxy host name.
proxy_port: str or int
    http proxy port.
no_proxy: list
    Whitelisted host names that don't use the proxy.
proxy_auth: tuple
    HTTP proxy auth information. Tuple of username and password. Default is None.
proxy_type: str
    Specify the proxy protocol (http, socks4, socks4a, socks5, socks5h). Default is "http".
    Use socks4a or socks5h if you want to send DNS requests through the proxy.
)Nr   Nz+Cannot use port 0 when proxy_host specifiedhttps_proxy
http_proxyr7   r8   N)rG   r   r<   r=   r>   upperr?   r   usernamer   passwordr   r   )r   r   rH   rI   rJ   r4   rK   r   authenv_keyvalueproxys               r   r	   r	      s    F ,,)*WXX%%(mlGJJNN7BJJNN7==?B$GHPPRE  ~~ U^^$genn&=> 	
 ~~uzz4//r   )Nr   NNr   )r<   r#   r/   typingr   urllib.parser   r   _exceptionsr   __all__strtupler   r@   boolr&   r+   r3   listrG   r)   r	    r   r   <module>r_      s   	    * 0& (
)+/3 +/5 +/\ %k2     's ' ' ' x~ $ < !%"&#::: : 	:
 : tn: : :r   