HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/websocket/__pycache__/_url.cpython-310.pyc
o

�_a��@sxdZ	ddlZddlZddlZddlmZmZddgZdd�ZddgZ	d	d
�Z
dd�Zd
d�Zdd�Z
		ddd�ZdS)z

�N)�unquote�urlparse�	parse_url�get_proxy_infocCs�d|vrtd��|�dd�\}}t|dd�}|jr|j}ntd��d}|jr)|j}d}|d	kr4|s3d
}n|dkr?d}|s>d
}ntd|��|jrL|j}nd}|jrX|d|j7}||||fS)z�
    parse url and the result is tuple of
    (hostname, port, resource path and the flag of secure mode)

    Parameters
    ----------
    url: str
        url string.
    �:zurl is invalid��http)�schemezhostname is invalidrF�ws�P�wssTi�zscheme %s is invalid�/�?)�
ValueError�splitr�hostname�port�path�query)�urlr	�parsedrr�	is_secure�resource�r�0/usr/lib/python3/dist-packages/websocket/_url.pyr!s6
���	localhostz	127.0.0.1cCs(zt�|�WdStjyYdSw)NFT)�socket�	inet_aton�error)�addrrrr�_is_ip_addressRs��r cCsLz|�d�\}}t|�odt|�kodkWSWSty%YdSw)Nr
r� F)rr �intr)rr�netmaskrrr�_is_subnet_address[s(�r$cCsZt�dt�|��d}|�d�\}}t�dt�|��d}ddt|�>d@}||@|kS)Nz!Irr
l��r!)�struct�unpackrrrr")�ip�net�ipaddr�netaddrr#rrr�_is_address_in_networkcs
r+cs�|stj�dtj�dd���dd�}|r|�d�}|st}d|vr#dS�|vr)dSt��r8t�fdd	�|D��Sd
d	�|D�D]
}��|�rIdSq?dS)N�no_proxy�NO_PROXY�� �,�*Tcsg|]}t|�rt�|��qSr)r$r+)�.0�subnet�rrr�
<listcomp>ysz%_is_no_proxy_host.<locals>.<listcomp>cSsg|]	}|�d�r|�qS)�.)�
startswith)r2�domainrrrr5zsF)	�os�environ�get�replacer�DEFAULT_NO_PROXY_HOSTr �any�endswith)rr,�vr8rr4r�_is_no_proxy_hostls" 

�rArc
Cs�t||�rdS|r|}|}|||fSdg}	|r|	�dd�|	D]2}
tj�|
tj�|
��d���dd�}|rQt|�}|jrFt	|j�t	|j
�fnd}|j|j|fSqdS)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
        before falling back to "http_proxy"
    proxy_host: str
        http proxy host name.
    http_proxy_port: str or int
        http proxy port.
    http_no_proxy: list
        Whitelisted host names that don't use the proxy.
    http_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.
    )NrN�
http_proxyr�https_proxyr.r/N)
rA�insertr9r:r;�upperr<r�usernamer�passwordrr)
rr�
proxy_host�
proxy_port�
proxy_authr,�
proxy_typer�auth�env_keys�key�value�proxyrrrr�s"

$�)NrNNr)�__doc__r9rr%�urllib.parserr�__all__rr=r r$r+rArrrrr�<module>s .		�