
    af                     \   d dl mZ d dlmZ ddgZej                            e           ej                            e           ej	                            e           ej
                            e           ej                            e           dZed
d            Zed	             ZdS )    )public)parsersrss)
create_url	parse_urlNFc                 R   t          |          t          k    sJ | dk    rd|z  }ne|,t          |          t          k    r|t          dd          v sJ |d| |fz  }n-|rd                    |           }nd                    |           }|rd	}nd
}d                    ||          S )a  
    Create a RawSocket URL from components.

    :param hostname: RawSocket server hostname (for TCP/IP sockets) or
        filesystem path (for Unix domain sockets).
    :type hostname: str

    :param port: For TCP/IP sockets, RawSocket service port or ``None`` (to select default
        ports ``80`` or ``443`` depending on ``isSecure``. When ``hostname=="unix"``,
        this defines the path to the Unix domain socket instead of a TCP/IP network socket.
    :type port: int or str

    :param isSecure: Set ``True`` for secure RawSocket (``rss`` scheme).
    :type isSecure: bool

    :returns: Constructed RawSocket URL.
    :rtype: str
    unixzunix:%sNr     z%s:%dz{}:443z{}:80r   r   z{}://{})typeboolintrangeformat)hostnameportisSecurenetlocschemes        I/var/www/html/env/lib/python3.11/site-packages/autobahn/rawsocket/util.pyr   r   3   s    * >>T!!!!6T!|T

c 1 1deAuoo6M6M6MN$//FF 2!22 11 FF+++    c                    t          j         |           }|j        dvr't          d                    |j                            |j        r|j        dk    rt          d          |j        2|j        dk    r't          d                    |j                            |j        2|j        dk    r't          d                    |j                            |j        dk    r=|j        |j        z   }|	                    d	          d
         }|j        dk    |j        |fS |j        2|j        dk    r't          d                    |j                            |j
        |j
        dk    r|j        dk    rd}nd}nt          |j
                  }|d
k     s|dk    r"t          d                    |                    |j        dk    |j        |fS )a  
    Parses as RawSocket URL into it's components and returns a tuple:

     - ``isSecure`` is a flag which is ``True`` for ``rss`` URLs.
     - ``host`` is the hostname or IP from the URL.

    and for TCP/IP sockets:

     - ``tcp_port`` is the port from the URL or standard port derived from
       scheme (``rs`` => ``80``, ``rss`` => ``443``).

    or for Unix domain sockets:

     - ``uds_path`` is the path on the local host filesystem.

    :param url: A valid RawSocket URL, i.e. ``rs://localhost:9000`` for TCP/IP sockets or
        ``rs://unix:/tmp/file.sock`` for Unix domain sockets (UDS).
    :type url: str

    :returns: A 3-tuple ``(isSecure, host, tcp_port)`` (TCP/IP) or ``(isSecure, host, uds_path)`` (UDS).
    :rtype: tuple
    )r   r   z@invalid RawSocket URL: protocol scheme '{}' is not for RawSocket z'invalid RawSocket URL: missing hostnameNz+invalid RawSocket URL: non-empty query '{}'z.invalid RawSocket URL: non-empty fragment '{}'r
   :   r   z*invalid RawSocket URL: non-empty path '{}'r   P   i  r   zinvalid port {})urlparser   	Exceptionr   r   queryfragmentr   pathsplitr   r   )urlparsedfpuds_pathtcp_ports        r   r   r   `   s   0 s##F}M))Zaabhboppqqq? Cfo33ABBB|FLB$6$6ELLV\ZZ[[["v"'<'<HOOPVP_``aaa&   ]V[(88C==#
 }%v@@
 ;"v{b'8'8HOOPVP[\\]]];&+"3"3}$$6;''Ha<<8e++-44X>>???}%v@@r   )NF)autobahn.utilr   urllibr   r   	wsschemesuses_relativeextenduses_netlocuses_params
uses_queryuses_fragment__all__r   r    r   r   <module>r3      s   8 !           % $ $ $ $ $5M	    i ( ( (    I & & &    I & & &    9 % % %    i ( ( ( ), ), ), ),X BA BA BA BA BAr   