
    ai"                        d dl Z d dlZd dlmZ d dlmZmZ ddlmZ 	 ddgZ	de
d	efd
Zde
d	efdZde
d	efdZde
de
d	efdZde
deee
                  d	efdZ	 	 	 	 	 dde
dedee
         dedee         deee
                  de
d	efdZdS )    N)Optional)unquoteurlparse   )WebSocketProxyException	parse_urlget_proxy_infourlreturnc                    d| vrt          d          |                     dd          \  }} t          | d          }|j        r|j        }nt          d          d}|j        r|j        }d}|d	k    r|sd
}n|dk    rd}|sd}nt          d|z            |j        r|j        }nd}|j        r|d|j         z  }||||fS )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          ^/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/websocket/_url.pyr   r      s    #~~)***))C##KFCc&)))F 0?.///D{ {I~~ 	D	5	 	D/&8999{ ;| '&&&&T8Y..    addrc                     t          | t                    st          d          	 t          j        |            dS # t
          $ r Y dS w xY w)Nz'_is_ip_address() argument 1 must be strTF)
isinstancestr	TypeError	ipaddress
ip_addressr   )r    s    r   _is_ip_addressr'   K   se    dC   CABBBT""" t    uus   < 
A
	A
r   c                 R    	 t          j        |            dS # t          $ r Y dS w xY w)NTF)r%   
ip_networkr   )r   s    r   _is_subnet_addressr*   V   sC    X&&& t    uus    
&&ipnetc                     	 t          j        |                               t          j        |                    S # t          $ r Y dS w xY w)NF)r%   r)   	subnet_ofr$   )r+   r,   s     r   _is_address_in_networkr/   _   sS    #B''11)2Fs2K2KLLL   uus   8; 
A	A	no_proxyc                     |sit           j                            dt           j                            dd                                        dd          x}r|                    d          }|sg }d|v rdS  |v rdS t                     rt           fd|D                       S d	 |D             D ]/}|                    d
          }                     |          r dS 0dS )Nr0   NO_PROXY  ,*Tc                 N    g | ]!}t          |          t          |          "S  )r*   r/   ).0subnetr   s     r   
<listcomp>z%_is_no_proxy_host.<locals>.<listcomp>v   sA       %f--&x88  r   c                 <    g | ]}|                     d           |S ).)
startswith)r9   domains     r   r;   z%_is_no_proxy_host.<locals>.<listcomp>|   s+    KKKfF4E4Ec4J4JK6KKKr   r=   F)	osenvirongetreplacer   r'   anylstripendswith)r   r0   vr?   	endDomains   `    r   _is_no_proxy_hostrI   f   s+    $
z2:>>*b+I+IJJRR
 
 
1 	$ wws||H 
ht8th 
   &  
 
 	
 LKKKK  MM#&&	Y'' 	44	5r   r   r   
proxy_host
proxy_port
proxy_auth
proxy_typec                    t          | |          rdS |r|st          d          |}|}|||fS |rdnd}	t          j                            |	t          j                            |	                                d                                        dd          }
|
rSt          |
          }|j        r,t          |j        pd          t          |j
        pd          fnd}|j        |j        |fS dS )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_proxyr3   r4   N)rI   r   r@   rA   rB   upperrC   r   usernamer   passwordr   r   )r   r   rJ   rK   rL   r0   rM   r   authenv_keyvalueproxys               r   r	   r	      s   F 8,, } & 	Y)*WXXX4%%(:mmlGJNN7BJNN7==??B$G$GHHPPR E  0 ~WU^)r**GEN4Hb,I,IJJ 	
 ~uz4//=r   )Nr   NNr   )r%   r@   typingr   urllib.parser   r   _exceptionsr   __all__r#   tupler   boolr'   r*   r/   listrI   intr	   r8   r   r   <module>r`      s       				       * * * * * * * * 0 0 0 0 0 0& (
)+/3 +/5 +/ +/ +/ +/\          s       xS	/B t    @ !%"&$(: ::: : 	:
 : tCy!: : : : : : : :r   