
    ,hJ                        d dl mZ d dlZd dlZd dlZddlmZmZ ddgZ	dZ
ej                   G d d             Zdd	Zej                   G d
 d             ZddZddZy)    )annotationsN   )InvalidProxy
InvalidURI	parse_uriWebSocketURIz:/?#[]@!$&'()*+,;=c                      e Zd ZU dZded<   ded<   ded<   ded<   ded	<   d
Zded<   d
Zded<   edd       Zedd       Z	y
)r   a  
    WebSocket URI.

    Attributes:
        secure: :obj:`True` for a ``wss`` URI, :obj:`False` for a ``ws`` URI.
        host: Normalized to lower case.
        port: Always set even if it's the default.
        path: May be empty.
        query: May be empty if the URI doesn't include a query component.
        username: Available when the URI contains `User Information`_.
        password: Available when the URI contains `User Information`_.

    .. _User Information: https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1

    boolsecurestrhostintportpathqueryN
str | Noneusernamepasswordc                x    | j                   r| j                   }nd}| j                  r|d| j                  z   z  }|S )N/?)r   r   )selfresource_names     P/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/websockets/uri.pyr   zWebSocketURI.resource_name+   s7    99 IIMM::S4::--M    c                h    | j                   y | j                  J | j                   | j                  fS Nr   r   r   s    r   	user_infozWebSocketURI.user_info5   /    == }}((t}}--r   )returnr   r"   ztuple[str, str] | None)
__name__
__module____qualname____doc____annotations__r   r   propertyr   r     r   r   r   r      s\      L
I
I
IJHjHj  . .r   c           	        t         j                  j                  |       }|j                  dvrt	        | d      |j
                  t	        | d      |j                  dk7  rt	        | d      |j                  dk(  }|j
                  }|j                  xs |rdnd}|j                  }|j                  }|j                  }|j                  }||t	        | d	      	 | j                  d
       t#        |||||||      S # t        $ r |j                  d      j                         }t         j                  j                  |t               }t         j                  j                  |t               }|N|J t         j                  j                  |t               }t         j                  j                  |t               }Y w xY w)z
    Parse and validate a WebSocket URI.

    Args:
        uri: WebSocket URI.

    Returns:
        Parsed WebSocket URI.

    Raises:
        InvalidURI: If ``uri`` isn't a valid WebSocket URI.

    )wswsszscheme isn't ws or wsshostname isn't provided z"fragment identifier is meaninglessr-     P   "username provided without passwordasciiidnasafe)urllibparseurlparseschemer   hostnamefragmentr   r   r   r   r   encodeUnicodeEncodeErrordecodequoteDELIMSr   )	uriparsedr   r   r   r   r   r   r   s	            r   r   r   =   s    \\""3'F}}M)677788"BCC]]e#F??D;;1&3bD;;DLLEHH  0BCCA

7 dD%8LL  	A {{6"))+||!!$V!4""5v"6''||))()@H||))()@H	As   C? ?CGGc                  ^    e Zd ZU dZded<   ded<   ded<   dZded	<   dZded
<   edd       Zy)Proxya  
    Proxy.

    Attributes:
        scheme: ``"socks5h"``, ``"socks5"``, ``"socks4a"``, ``"socks4"``,
            ``"https"``, or ``"http"``.
        host: Normalized to lower case.
        port: Always set even if it's the default.
        username: Available when the proxy address contains `User Information`_.
        password: Available when the proxy address contains `User Information`_.

    .. _User Information: https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1

    r   r:   r   r   r   Nr   r   r   c                h    | j                   y | j                  J | j                   | j                  fS r   r   r   s    r   r    zProxy.user_info   r!   r   r#   )	r$   r%   r&   r'   r(   r   r   r)   r    r*   r   r   rE   rE   o   s>     K
I
IHjHj. .r   rE   c                `   t         j                  j                  |       }|j                  dvrt	        | d|j                   d      |j
                  t	        | d      |j                  dvrt	        | d      |j                  dk7  rt	        | d      |j                  dk7  rt	        | d	      |j                  }|j
                  }|j                  xs |j                  d
k(  rdnd}|j                  }|j                  }||t	        | d      	 | j                  d       t#        |||||      S # t        $ rr |j                  d      j                         }|N|J t         j                  j                  |t               }t         j                  j                  |t               }Y w xY w)z
    Parse and validate a proxy.

    Args:
        proxy: proxy.

    Returns:
        Parsed proxy.

    Raises:
        InvalidProxy: If ``proxy`` isn't a valid proxy.

    )socks5hsocks5socks4asocks4httpshttpzscheme z isn't supportedr.   )r/   r   zpath is meaninglessr/   zquery is meaninglesszfragment is meaninglessrL   r0   r1   r2   r3   r4   r5   )r7   r8   r9   r:   r   r;   r   r   r<   r   r   r   r=   r>   r?   r@   rA   rE   )proxyrC   r:   r   r   r   r   s          r   parse_proxyrO      s    \\""5)F}}WW5GFMM?:J"KLL5";<<{{)#5"788||r5"899"5";<<]]F??D;;C&--7":3DHH  05"FGG	AW tXx88  A {{6"))+''||))()@H||))()@HAs   D2 2A8F-,F-c                T   t         j                  j                  | j                   d| j                         ryt         j                  j                         }| j                  rg d}ng d}|D ]7  }|j                  |      }||dk(  r|j                  d      rd|dd z   }|c S  y)	zU
    Return the proxy to use for connecting to the given WebSocket URI, if any.

    :N)r-   socksrL   )r,   rR   rL   rM   rR   zhttp://z
socks5h://   )	r7   requestproxy_bypassr   r   
getproxiesr   get
startswith)rB   proxiesschemesr:   rN   s        r   	get_proxyr[      s    
 ~~""chhZq
#;< nn'')G
zz+2 F# U%5%5i%@$uQRy0L r   )rB   r   r"   r   )rN   r   r"   rE   )rB   r   r"   r   )
__future__r   dataclassesurllib.parser7   urllib.request
exceptionsr   r   __all__rA   	dataclassr   r   rE   rO   r[   r*   r   r   <module>rc      sx    "    0 
' 
 (. (. (.V/Md . . .</9d!r   