
    ,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y)    N)Optional)unquoteurlparse   )WebSocketProxyException	parse_urlget_proxy_infourlreturnc                    d| vrt        d      | j                  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/system.tvplus.app.br/jogos/scrap/venv/lib/python3.12/site-packages/websocket/_url.pyr   r      s     #~)**))C#KFCc&)F??.//D{{{{I~D	5	D/&899{{;;||a~&&T8Y..    addrc                     t        | t              st        d      	 t        j                  |        y# t
        $ r Y y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   sD    dC ABBT"   s   3 	??r   c                 N    	 t        j                  |        y# t        $ r Y yw xY w)NTF)r%   
ip_networkr   )r   s    r   _is_subnet_addressr*   V   s.    X&   s    	$$ipnetc                     	 t        j                  |       j                  t        j                  |            S # t        $ r Y yw xY w)NF)r%   r)   	subnet_ofr$   )r+   r,   s     r   _is_address_in_networkr/   _   s@    ##B'11)2F2Fs2KLL s   69 	AAno_proxyc           	         |sat         j                  j                  dt         j                  j                  dd            j                  dd      x}r|j	                  d      }|sg }d|v ry| |v ryt        |       r.t        |D cg c]  }t        |      rt        | |       c}      S |D cg c]  }|j                  d      s| c}D ]&  }|j                  d      }| j                  |      s& y y	c c}w c c}w )
Nr0   NO_PROXY  ,*T.F)osenvirongetreplacer   r'   anyr*   r/   
startswithlstripendswith)r   r0   vsubnetdomain	endDomains         r   _is_no_proxy_hostrD   f   s   

z2::>>*b+IJRR
 
1 
 wws|H
h8h '%f- 'x8
 	
 )1KfF4E4Ec4J6K MM#&	Y'  Ls   C7/C<C<r   
proxy_host
proxy_port
proxy_auth
proxy_typec                    t        | |      ry|r|st        d      |}|}|||fS |rdnd}	t        j                  j	                  |	t        j                  j	                  |	j                         d            j                  dd      }
|
rdt        |
      }|j                  r2t        |j                  xs d      t        |j                  xs d      fnd}|j                  |j                  |fS y)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)rD   r   r8   r9   r:   upperr;   r   usernamer   passwordr   r   )r   r   rE   rF   rG   r0   rH   r   authenv_keyvalueproxys               r   r	   r	      s    F 8,)*WXX4%%(mlGJJNN7BJJNN7==?B$GHPPRE  ~~ U^^)r*GENN4Hb,IJ 	
 ~~uzz4//r   )Nr   NNr   )r%   r8   typingr   urllib.parser   r   _exceptionsr   __all__r#   tupler   boolr'   r*   r/   listrD   intr	    r   r   <module>r\      s    	  * 0& (
)+/3 +/5 +/\    s    xS	/B t @ !%"&$(::: : 	:
 : tCy!: : :r   