
    i"                        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	\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          ;C:\des-py\RoboSAPF\venv\Lib\site-packages\websocket\_url.pyr   r      s     #~)**))C#KFc&)F??.//D{{{{I~D	5	D/&899{{;;||a~&&8..    addrc                     [        U [        5      (       d  [        S5      e [        R                  " U 5        g! [
         a     gf = f)Nz'_is_ip_address() argument 1 must be strTF)
isinstancestr	TypeError	ipaddress
ip_addressr   )r    s    r   _is_ip_addressr'   K   sG    dC  ABBT"   s   9 
AAr   c                 R     [         R                  " U 5        g! [         a     gf = f)NTF)r%   
ip_networkr   )r   s    r   _is_subnet_addressr*   V   s.    X&   s    
&&ipnetc                      [         R                  " U 5      R                  [         R                  " U5      5      $ ! [         a     gf = f)NF)r%   r)   	subnet_ofr$   )r+   r,   s     r   _is_address_in_networkr/   _   s@    ##B'11)2F2Fs2KLL s   8; 
AAno_proxyc           	      `   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      (       a7  [        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                  S5      nU R                  U5      (       d  M,    g   g	s  snf s  snf )
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h '&F%f- 9&x8&
 	
 )1Kf4E4Ec4J6KMM#&	Y'' L  Ls   D&5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
(       as  [        U
5      nUR                  (       a<  [        UR                  =(       d    S5      [        UR                  =(       d    S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_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 ,,)*WXX%%(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   