Ë
    Õ±1hÉ  ã                  óâ   — d dl mZ d dlZd dlZd dlZd dlmZm	Z	m
Z
mZ d dlmZ d dlmZmZ ddlmZmZ dd	lmZmZmZ g d
¢Z G d„ d«      Zddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	 d	 	 	 	 	 	 	 dd„Zy)é    )ÚannotationsN)ÚAnyÚ	AwaitableÚCallableÚLiteral)ÚNotFound)ÚMapÚRequestRedirecté   )ÚRequestÚResponseé   )ÚServerÚServerConnectionÚserve)ÚrouteÚ
unix_routeÚRouterc                  ó`   — e Zd ZdZ	 	 d		 	 	 	 	 	 	 d
d„Zdd„Zdd„Zdd„Z	 	 	 	 	 	 dd„Zdd„Z	y)r   z*WebSocket router supporting :func:`route`.Nc                óz   — || _         || _        || _        | j                   j                  «       D ]	  }d|_        Œ y )NT)Úurl_mapÚserver_nameÚ
url_schemeÚ
iter_rulesÚ	websocket)Úselfr   r   r   Úrules        úW/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/websockets/asyncio/router.pyÚ__init__zRouter.__init__   s=   € ð ˆŒØ&ˆÔØ$ˆŒØ—L‘L×+Ñ+Ó-ò 	"ˆDØ!ˆD�Nñ	"ó    c                óP   — | j                   €|j                  d   S | j                   S )NÚHost)r   Úheaders)r   Ú
connectionÚrequests      r   Úget_server_namezRouter.get_server_name!   s)   € Ø×ÑÐ#Ø—?‘? 6Ñ*Ð*à×#Ñ#Ð#r    c                ó~   — |j                  t        j                  j                  d|› �«      }||j                  d<   |S )Nz	Found at ÚLocation)ÚrespondÚhttpÚ
HTTPStatusÚFOUNDr#   )r   r$   ÚurlÚresponses       r   ÚredirectzRouter.redirect'   s:   € Ø×%Ñ%¤d§o¡o×&;Ñ&;¸yÈÈÐ=NÓOˆØ'*ˆ×Ñ˜Ñ$Øˆr    c                óV   — |j                  t        j                  j                  d«      S )Nz	Not Found)r)   r*   r+   Ú	NOT_FOUND©r   r$   s     r   Ú	not_foundzRouter.not_found,   s   € Ø×!Ñ!¤$§/¡/×";Ñ";¸[ÓIÐIr    c                óÒ  — | j                   j                  | j                  ||«      | j                  ¬«      }	 t        j
                  j                  |j                  «      }|j                  |j                  |j                  ¬«      \  }}||c|_        |_        y# t        $ r&}| j                  ||j                  «      cY d}~S d}~wt        $ r | j                  |«      cY S w xY w)zRoute incoming request.)r   r   )Ú	path_infoÚ
query_argsN)r   Úbindr&   r   ÚurllibÚparseÚurlparseÚpathÚmatchÚqueryr
   r/   Únew_urlr   r3   ÚhandlerÚhandler_kwargs)r   r$   r%   Úurl_map_adapterÚparsedr?   Úkwargsr/   s           r   Úroute_requestzRouter.route_request/   sÐ   € ð Ÿ,™,×+Ñ+Ø×,Ñ,¨Z¸ÓAØ—‘ð ,ó 
ˆð		.Ü—\‘\×*Ñ*¨7¯<©<Ó8ˆFØ-×3Ñ3Ø Ÿ+™+Ø!Ÿ<™<ð 4ó ‰OˆG�Vð 9@ÀÐ5ˆ
Ô˜JÔ5Øøô ò 	?Ø—=‘= ¨X×-=Ñ-=Ó>Õ>ûÜò 	.Ø—>‘> *Ó-Ò-ð	.ús$   ¹AB Â	C&Â%CÃ C&ÃC&Ã%C&c              ƒ  óX   K  —  |j                   |fi |j                  ¤Žƒ d{  –—† S 7 Œ­w)zHandle a connection.N)r?   r@   r2   s     r   r?   zRouter.handlerD   s*   è ø€ à'�Z×'Ñ'¨
ÑP°j×6OÑ6OÑP×PÐPÐPús   ‚!*£(¤*)NÚws)r   r	   r   ú
str | Noner   ÚstrÚreturnÚNone)r$   r   r%   r   rI   rH   )r$   r   r-   rH   rI   r   )r$   r   rI   r   ©r$   r   r%   r   rI   zResponse | None)r$   r   rI   rJ   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r&   r/   r3   rD   r?   © r    r   r   r      sk   „ Ù4ð
 #'Øð	
"àð
"ð  ð
"ð ð	
"ð
 
ó
"ó$óó
JðØ*ðØ5<ðà	óô*Qr    r   )r   ÚsslÚcreate_routerc               óÞ   ‡‡	— |€dnd}|dur|�||d<   |€t         } || ||«      Š	|j                  dd«      Š‰€‰	j                  }n	 	 	 	 	 	 dˆˆ	fd„}t        ‰	j                  g|¢­d|i|¤ŽS )	a-	  
    Create a WebSocket server dispatching connections to different handlers.

    This feature requires the third-party library `werkzeug`_:

    .. code-block:: console

        $ pip install werkzeug

    .. _werkzeug: https://werkzeug.palletsprojects.com/

    :func:`route` accepts the same arguments as
    :func:`~websockets.sync.server.serve`, except as described below.

    The first argument is a :class:`werkzeug.routing.Map` that maps URL patterns
    to connection handlers. In addition to the connection, handlers receive
    parameters captured in the URL as keyword arguments.

    Here's an example::


        from websockets.asyncio.router import route
        from werkzeug.routing import Map, Rule

        async def channel_handler(websocket, channel_id):
            ...

        url_map = Map([
            Rule("/channel/<uuid:channel_id>", endpoint=channel_handler),
            ...
        ])

        # set this future to exit the server
        stop = asyncio.get_running_loop().create_future()

        async with route(url_map, ...) as server:
            await stop


    Refer to the documentation of :mod:`werkzeug.routing` for details.

    If you define redirects with ``Rule(..., redirect_to=...)`` in the URL map,
    when the server runs behind a reverse proxy that modifies the ``Host``
    header or terminates TLS, you need additional configuration:

    * Set ``server_name`` to the name of the server as seen by clients. When not
      provided, websockets uses the value of the ``Host`` header.

    * Set ``ssl=True`` to generate ``wss://`` URIs without actually enabling
      TLS. Under the hood, this bind the URL map with a ``url_scheme`` of
      ``wss://`` instead of ``ws://``.

    There is no need to specify ``websocket=True`` in each rule. It is added
    automatically.

    Args:
        url_map: Mapping of URL patterns to connection handlers.
        server_name: Name of the server as seen by clients. If :obj:`None`,
            websockets uses the value of the ``Host`` header.
        ssl: Configuration for enabling TLS on the connection. Set it to
            :obj:`True` if a reverse proxy terminates TLS connections.
        create_router: Factory for the :class:`Router` dispatching requests to
            handlers. Set it to a wrapper or a subclass to customize routing.

    NrF   ÚwssTrQ   Úprocess_requestc              “  ó‚   •K  —  ‰| |«      }t        |t        «      r
|ƒ d {  –—† }|�|S ‰j                  | |«      S 7 Œ­w©N)Ú
isinstancer   rD   )r$   r%   r.   Ú_process_requestÚrouters      €€r   rU   zroute.<locals>.process_request©   sI   øè ø€ ñ (¨
°GÓ<ˆHÜ˜(¤IÔ.Ø!)Ÿ>�ØÐ#Ø�Ø×'Ñ'¨
°GÓ<Ð<ð *ús   ƒ?¢=£?rK   )r   ÚpoprD   r   r?   )
r   r   rQ   rR   ÚargsrC   r   rU   rY   rZ   s
           @@r   r   r   I   s©   ù€ ðR ˜‘¨%€JØ
�$�˜3˜?Øˆˆu‰àÐÜˆá˜7 K°Ó<€Fð 	�
‰
Ð$ dÓ+ð ð Ðð × Ñ ñ 	ð	=Ø(ð	=Ø3:ð	=àö	=ô �—‘ÐR $ÒR¸ÐRÈ6ÑRÐRr    c                ó    — t        | fd|dœ|¤ŽS )aN  
    Create a WebSocket Unix server dispatching connections to different handlers.

    :func:`unix_route` combines the behaviors of :func:`route` and
    :func:`~websockets.asyncio.server.unix_serve`.

    Args:
        url_map: Mapping of URL patterns to connection handlers.
        path: File system path to the Unix socket.

    T)Úunixr;   )r   )r   r;   rC   s      r   r   r   ¶   s   € ô  �Ð9˜t¨$Ñ9°&Ñ9Ð9r    )r   r	   r\   r   r   rG   rQ   z,ssl_module.SSLContext | Literal[True] | NonerR   ztype[Router] | NonerC   r   rI   úAwaitable[Server]rW   )r   r	   r;   rG   rC   r   rI   r_   )Ú
__future__r   r*   rQ   Ú
ssl_moduleÚurllib.parser8   Útypingr   r   r   r   Úwerkzeug.exceptionsr   Úwerkzeug.routingr	   r
   Úhttp11r   r   Úserverr   r   r   Ú__all__r   r   r   rP   r    r   ú<module>ri      sË   ðÝ "ã Û Û ß 4Ó 4å (ß 1ç &ß 3Ñ 3ò ,€÷4Qñ 4Qðt #Ø8<Ø)-ñjSØðjSàðjSð ðjSð 
6ð	jSð
 'ðjSð ðjSð ójSð^ ð:Øð:à
ð:ð ð:ð ô	:r    