
    @OOfu                         d dl Z d dlZd dlm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 dd	lmZmZ d
gZededdddd ddededee
   dee   dee   dee   dee   dededeedf   fd       Zy)    N)asynccontextmanager)AsyncGeneratorCallableOptionalcast   )QuicConfiguration)QuicConnectionQuicTokenHandler)SessionTicketHandler   )QuicConnectionProtocolQuicStreamHandlerconnectT)configurationcreate_protocolsession_ticket_handlerstream_handlertoken_handlerwait_connected
local_porthostportr   r   r   r   r   r   r   returnc               L  K   t        j                         }	d}
|	j                  | |t        j                         d{   }|d   d   }t        |      dk(  rd|d   z   |d   ddf}|t        d	
      }|j                  | |_        t        |||      t        j                  t        j                  t        j                        }d}	 |j                  t        j                  t        j                  d       |j                  |
|ddf       d	}|s|j                          	 |	j                  fd|       d{   \  }}t!        t"        |      }	 |j%                  |       |r|j'                          d{    | |j                          |j)                          d{    |j                          y7 # |s|j                          w w xY w7 7 _7 4# |j                          |j)                          d{  7   |j                          w xY ww)aq  
    Connect to a QUIC server at the given `host` and `port`.

    :meth:`connect()` returns an awaitable. Awaiting it yields a
    :class:`~aioquic.asyncio.QuicConnectionProtocol` which can be used to
    create streams.

    :func:`connect` also accepts the following optional arguments:

    * ``configuration`` is a :class:`~aioquic.quic.configuration.QuicConfiguration`
      configuration object.
    * ``create_protocol`` allows customizing the :class:`~asyncio.Protocol` that
      manages the connection. It should be a callable or class accepting the same
      arguments as :class:`~aioquic.asyncio.QuicConnectionProtocol` and returning
      an instance of :class:`~aioquic.asyncio.QuicConnectionProtocol` or a subclass.
    * ``session_ticket_handler`` is a callback which is invoked by the TLS
      engine when a new session ticket is received.
    * ``stream_handler`` is a callback which is invoked whenever a stream is
      created. It must accept two arguments: a :class:`asyncio.StreamReader`
      and a :class:`asyncio.StreamWriter`.
    * ``local_port`` is the UDP port number that this client wants to bind.
    z::)typeNr      r   z::ffff:r   T)	is_client)r   r   r   Fc                              S )N)r    )
connectionr   r   s   W/var/www/premiumrankchecker/venv/lib/python3.12/site-packages/aioquic/asyncio/client.py<lambda>zconnect.<locals>.<lambda>Q   s    
>J     )sock)asyncioget_event_loopgetaddrinfosocket
SOCK_DGRAMlenr	   server_namer
   AF_INET6
setsockoptIPPROTO_IPV6IPV6_V6ONLYbindclosecreate_datagram_endpointr   r   r   r   wait_closed)r   r   r   r   r   r   r   r   r   loop
local_hostinfosaddrr%   	completed	transportprotocolr!   s      ` `           @r"   r   r      s    F !!#DJ ""4F4E4E"FFE8A;D
4yA~DG#T!Wa3 )D9  ($(!#5#J ==&*;*;<DI++V-?-?C		:z1a01	JJL $ = =J !> ! Ix *H5H))+++""$$$Q G0 JJL  , 	% 	""$$$s   <H$GBH$AG .H$G H$&G& G"	G& #H$/G$0H$GH$"G& $H$&$H!
HH!!H$)r&   r)   
contextlibr   typingr   r   r   r   quic.configurationr	   quic.connectionr
   r   tlsr   r;   r   r   __all__strintboolr   r    r$   r"   <module>rE      s      * ; ; 2 > & ?+ 
 26*@=A2604N
N
N -.	N
 h'N %%9:N ./N ,-N N N *D01N Nr$   