§
    ÐÁ³gÆ1  ã                  óî  — d dl mZ d dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z
 d dlmZ d dlmZmZ ddlmZmZmZmZ dd	lmZmZ dd
lmZmZmZmZ ej        dk    r	d dlmZmZ nd dl mZmZ  ed¦  «        Z! ed¦  «        Z"e#e#e$e$f         df         Z%e#e%df         Z& G d„ de¦  «        Z' e
d¬¦  «         G d„ de¦  «        ¦   «         Z( e
d¬¦  «         G d„ dee(         ¦  «        ¦   «         Z)dS )é    )ÚannotationsN)ÚCallableÚMapping)Ú	dataclass)Úwraps)ÚAnyÚTypeVaré   )ÚBrokenResourceErrorÚEndOfStreamÚaclose_forcefullyÚget_cancelled_exc_class)ÚTypedAttributeSetÚtyped_attribute)ÚAnyByteStreamÚ
ByteStreamÚListenerÚ	TaskGroup)é   é   )ÚTypeVarTupleÚUnpackÚT_RetvalÚPosArgsT.c                  ó@  — e Zd ZU dZ e¦   «         Zded<    e¦   «         Zded<    e¦   «         Zded<    e¦   «         Z	ded	<    e¦   «         Z
d
ed<    e¦   «         Zded<    e¦   «         Zded<    e¦   «         Zded<    e¦   «         Zded<    e¦   «         Zded<   dS )ÚTLSAttributez5Contains Transport Layer Security related attributes.ú
str | NoneÚalpn_protocolÚbytesÚchannel_binding_tls_uniqueztuple[str, str, int]Úcipherz*None | dict[str, str | _PCTRTTT | _PCTRTT]Úpeer_certificatezbytes | NoneÚpeer_certificate_binaryÚboolÚserver_sidez!list[tuple[str, str, int]] | NoneÚshared_ciphersússl.SSLObjectÚ
ssl_objectÚstandard_compatibleÚstrÚtls_versionN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r    r!   r"   r#   r%   r&   r(   r)   r+   © ó    úO/var/www/html/mpstechhub/venv/lib/python3.11/site-packages/anyio/streams/tls.pyr   r       s!  € € € € € € Ø?Ð?ð !0 Ñ 1Ô 1€MÐ1Ð1Ð1Ñ1à(7¨Ñ(9Ô(9ÐÐ9Ð9Ð9Ñ9à#2 ?Ñ#4Ô#4€FÐ4Ð4Ð4Ñ4ð FUÀ_ÑEVÔEVÐÐVÐVÐVÑVà,;¨OÑ,=Ô,=ÐÐ=Ð=Ð=Ñ=à'˜Ñ)Ô)€KÐ)Ð)Ð)Ñ)ð 9H¸Ñ8IÔ8I€NÐIÐIÐIÑIà / Ñ 1Ô 1€JÐ1Ð1Ð1Ñ1ð !0 Ñ 1Ô 1ÐÐ1Ð1Ð1Ñ1à&�Ñ(Ô(€KÐ(Ð(Ð(Ñ(Ð(Ð(r2   r   F)Úeqc                  ó´   — e Zd ZU dZded<   ded<   ded<   ded	<   ded
<   edddddœd*d„¦   «         Zd+d„Zd,d„Zd-d„Z	d.d/d$„Z
d0d&„Zd-d'„Zed1d)„¦   «         ZdS )2Ú	TLSStreama  
    A stream wrapper that encrypts all sent data and decrypts received data.

    This class has no public initializer; use :meth:`wrap` instead.
    All extra attributes from :class:`~TLSAttribute` are supported.

    :var AnyByteStream transport_stream: the wrapped stream

    r   Útransport_streamr$   r)   r'   Ú_ssl_objectzssl.MemoryBIOÚ	_read_bioÚ
_write_bioNT)r%   ÚhostnameÚssl_contextr)   r%   úbool | Noner;   r   r<   ússl.SSLContext | NoneÚreturnc             ƒ  óÆ  K  — |€| }|sh|rt           j        j        nt           j        j        }t          j        |¦  «        }t          t           d¦  «        r|xj        t           j         z  c_        t          j        ¦   «         }t          j        ¦   «         }| 	                    ||||¬¦  «        }	 | |||	||¬¦  «        }
|
 
                    |	j        ¦  «        ƒ d{V —† |
S )aÔ  
        Wrap an existing stream with Transport Layer Security.

        This performs a TLS handshake with the peer.

        :param transport_stream: a bytes-transporting stream to wrap
        :param server_side: ``True`` if this is the server side of the connection,
            ``False`` if this is the client side (if omitted, will be set to ``False``
            if ``hostname`` has been provided, ``False`` otherwise). Used only to create
            a default context when an explicit context has not been provided.
        :param hostname: host name of the peer (if host name checking is desired)
        :param ssl_context: the SSLContext object to use (if not provided, a secure
            default will be created)
        :param standard_compatible: if ``False``, skip the closing handshake when
            closing the connection, and don't raise an exception if the peer does the
            same
        :raises ~ssl.SSLError: if the TLS handshake fails

        NÚOP_IGNORE_UNEXPECTED_EOF)r%   Úserver_hostname)r7   r)   r8   r9   r:   )ÚsslÚPurposeÚCLIENT_AUTHÚSERVER_AUTHÚcreate_default_contextÚhasattrÚoptionsrA   Ú	MemoryBIOÚwrap_bioÚ_call_sslobject_methodÚdo_handshake)Úclsr7   r%   r;   r<   r)   ÚpurposeÚbio_inÚbio_outr(   Úwrappers              r3   ÚwrapzTLSStream.wrapN   s  è è € ð: ÐØ&˜,ˆKàð 	Eà+6ÐS•”Ô'Ð'½C¼KÔ<Sð õ Ô4°WÑ=Ô=ˆKõ •sÐ6Ñ7Ô7ð EØÐ#Ô#­Ô(DÐ'DÑDÐ#Ô#å”‘”ˆÝ”-‘/”/ˆØ ×)Ò)Ø�G¨Àhð *ñ 
ô 
ˆ
ð �#Ø-Ø 3Ø"ØØð
ñ 
ô 
ˆð ×,Ò,¨ZÔ-DÑEÔEÐEÐEÐEÐEÐEÐEÐEØˆr2   Úfuncú&Callable[[Unpack[PosArgsT]], T_Retval]ÚargsúUnpack[PosArgsT]r   c              ‡  óÜ  K  — 	 	  ||Ž }| j         j        r7| j                             | j                              ¦   «         ¦  «        ƒ d {V —† |S # t
          j        $ rò 	 | j         j        r7| j                             | j                              ¦   «         ¦  «        ƒ d {V —† | j                             ¦   «         ƒ d {V —†}| j         	                    |¦  «         np# t          $ r | j                             ¦   «          Y nKt          $ r?}| j                             ¦   «          | j                              ¦   «          t          |‚d }~ww xY wY �nt
          j        $ r: | j                             | j                              ¦   «         ¦  «        ƒ d {V —† Y nÖt
          j        $ r?}| j                             ¦   «          | j                              ¦   «          t          |‚d }~wt
          j        $ ry}| j                             ¦   «          | j                              ¦   «          t#          |t
          j        ¦  «        s|j        r d|j        v r| j        rt          |‚t          d ‚‚ d }~ww xY w�Œj)NTÚUNEXPECTED_EOF_WHILE_READING)r:   Úpendingr7   ÚsendÚreadrC   ÚSSLWantReadErrorÚreceiver9   Úwriter   Ú	write_eofÚOSErrorr   ÚSSLWantWriteErrorÚSSLSyscallErrorÚSSLErrorÚ
isinstanceÚSSLEOFErrorÚstrerrorr)   )ÚselfrT   rV   ÚresultÚdataÚexcs         r3   rL   z TLSStream._call_sslobject_method‡   sÁ  è è € ð)	ð(Ø˜˜t˜�ðH ”?Ô*ð MØÔ/×4Ò4°T´_×5IÒ5IÑ5KÔ5KÑLÔLÐLÐLÐLÐLÐLÐLÐLà�øõM Ô'ð /ð /ð /ð/à”Ô.ð QØ"Ô3×8Ò8¸¼×9MÒ9MÑ9OÔ9OÑPÔPÐPÐPÐPÐPÐPÐPÐPà!%Ô!6×!>Ò!>Ñ!@Ô!@Ð@Ð@Ð@Ð@Ð@Ð@�Dð ”N×(Ò(¨Ñ.Ô.Ð.Ð.øõ #ð /ð /ð /Ø”N×,Ò,Ñ.Ô.Ð.Ð.Ð.Ýð 7ð 7ð 7Ø”N×,Ò,Ñ.Ô.Ð.Ø”O×-Ò-Ñ/Ô/Ð/Ý-°3Ð6øøøøð7øøøøùõ Ô(ð Ið Ið IØÔ+×0Ò0°´×1EÒ1EÑ1GÔ1GÑHÔHÐHÐHÐHÐHÐHÐHÐHÐHÐHÝÔ&ð 3ð 3ð 3Ø”×(Ò(Ñ*Ô*Ð*Ø”×)Ò)Ñ+Ô+Ð+Ý)¨sÐ2øøøøÝ”<ð ð ð Ø”×(Ò(Ñ*Ô*Ð*Ø”×)Ò)Ñ+Ô+Ð+Ý˜c¥3¤?Ñ3Ô3ð 4Ø”Lð4Ø%CÀsÄ|Ð%SÐ%SàÔ/ð 4Ý1°sÐ:å)¨tÐ3àøøøøðøøøñ1)	sb   …A ÁI)ÁA"CÃI)Ã#E	Ã?I)Ä	E	Ä
:EÅE	Å	I)ÅAI)ÆI)Æ$:GÇI)Ç0A4I$É$I)útuple[AnyByteStream, bytes]c              ƒ  óô   K  — |                       | j        j        ¦  «        ƒ d{V —† | j                             ¦   «          | j                             ¦   «          | j        | j                             ¦   «         fS )z„
        Does the TLS closing handshake.

        :return: a tuple of (wrapped byte stream, bytes left in the read buffer)

        N)rL   r8   Úunwrapr9   r`   r:   r7   r\   ©rh   s    r3   rn   zTLSStream.unwrapµ   sx   è è € ð ×)Ò)¨$Ô*:Ô*AÑBÔBÐBÐBÐBÐBÐBÐBÐBØŒ× Ò Ñ"Ô"Ð"ØŒ×!Ò!Ñ#Ô#Ð#ØÔ$ d¤n×&9Ò&9Ñ&;Ô&;Ð;Ð;r2   ÚNonec              ƒ  óà   K  — | j         rE	 |                      ¦   «         ƒ d {V —† n)# t          $ r t          | j        ¦  «        ƒ d {V —† ‚ w xY w| j                             ¦   «         ƒ d {V —† d S ©N)r)   rn   ÚBaseExceptionr   r7   Úaclosero   s    r3   rt   zTLSStream.acloseÁ   s©   è è € ØÔ#ð 	ðØ—k’k‘m”mÐ#Ð#Ð#Ð#Ð#Ð#Ð#Ð#øÝ ð ð ð Ý'¨Ô(=Ñ>Ô>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Øðøøøð Ô#×*Ò*Ñ,Ô,Ð,Ð,Ð,Ð,Ð,Ð,Ð,Ð,Ð,s	   ‹& ¦&Aé   Ú	max_bytesÚintr   c              ƒ  óh   K  — |                       | j        j        |¦  «        ƒ d {V —†}|st          ‚|S rr   )rL   r8   r\   r   )rh   rv   rj   s      r3   r^   zTLSStream.receiveË   sF   è è € Ø×0Ò0°Ô1AÔ1FÈ	ÑRÔRÐRÐRÐRÐRÐRÐRˆØð 	ÝÐàˆr2   Úitemc              ƒ  óV   K  — |                       | j        j        |¦  «        ƒ d {V —† d S rr   )rL   r8   r_   )rh   ry   s     r3   r[   zTLSStream.sendÒ   s:   è è € Ø×)Ò)¨$Ô*:Ô*@À$ÑGÔGÐGÐGÐGÐGÐGÐGÐGÐGÐGr2   c              ƒ  óP  K  — |                       t          j        ¦  «        }t          j        d|¦  «        }|r`t          |                     d¦  «        ¦  «        t          |                     d¦  «        pd¦  «        }}||fdk     rt          d|› �¦  «        ‚t          d¦  «        ‚)NzTLSv(\d+)(?:\.(\d+))?é   r
   r   )r|   r   z;send_eof() requires at least TLSv1.3; current session uses z7send_eof() has not yet been implemented for TLS streams)Úextrar   r+   ÚreÚmatchrw   ÚgroupÚNotImplementedError)rh   r+   r   ÚmajorÚminors        r3   Úsend_eofzTLSStream.send_eofÕ   s°   è è € Ø—j’j¥Ô!9Ñ:Ô:ˆÝ”Ð1°;Ñ?Ô?ˆØð 	Ý˜uŸ{š{¨1™~œ~Ñ.Ô.µ°E·K²KÀ±N´NÐ4GÀaÑ0HÔ0H�5ˆEØ�uˆ~ Ò&Ð&Ý)ð2Ø$/ð2ð 2ñô ð õ
 "ØEñ
ô 
ð 	
r2   úMapping[Any, Callable[[], Any]]c                óˆ  ‡ — i ‰ j         j        ¥t          j        ‰ j        j        t          j        ‰ j        j        t          j        ‰ j        j        t          j	        ˆ fd„t          j
        ˆ fd„t          j        ˆ fd„t          j        ˆ fd„t          j        ˆ fd„t          j        ˆ fd„t          j        ‰ j        j        i
¥S )Nc                 ó8   •— ‰ j                              d¦  «        S )NF©r8   Úgetpeercertro   s   €r3   ú<lambda>z,TLSStream.extra_attributes.<locals>.<lambda>í   s   ø€ °4Ô3C×3OÒ3OÐPUÑ3VÔ3V€ r2   c                 ó8   •— ‰ j                              d¦  «        S )NTrˆ   ro   s   €r3   rŠ   z,TLSStream.extra_attributes.<locals>.<lambda>î   s   ø€ ¸$Ô:J×:VÒ:VØñ;ô ;€ r2   c                 ó   •— ‰ j         j        S rr   )r8   r%   ro   s   €r3   rŠ   z,TLSStream.extra_attributes.<locals>.<lambda>ñ   s   ø€ ¨dÔ.>Ô.J€ r2   c                 óR   •— ‰ j         j        r‰ j                              ¦   «         nd S rr   )r8   r%   r&   ro   s   €r3   rŠ   z,TLSStream.extra_attributes.<locals>.<lambda>ò   s-   ø€ ØÔÔ+ð2°Ô1A×1PÒ1PÑ1RÔ1RÐ1Ràð r2   c                 ó   •— ‰ j         S rr   ©r)   ro   s   €r3   rŠ   z,TLSStream.extra_attributes.<locals>.<lambda>õ   ó
   ø€ °dÔ6N€ r2   c                 ó   •— ‰ j         S rr   )r8   ro   s   €r3   rŠ   z,TLSStream.extra_attributes.<locals>.<lambda>ö   s
   ø€ ¨TÔ-=€ r2   )r7   Úextra_attributesr   r   r8   Úselected_alpn_protocolr    Úget_channel_bindingr!   r"   r#   r%   r&   r)   r(   r+   Úversionro   s   `r3   r’   zTLSStream.extra_attributesä   sÞ   ø€ ð
ØÔ#Ô4ð
åÔ&¨Ô(8Ô(OÝÔ3ØÔ Ô4åÔ Ô!1Ô!8ÝÔ)Ð+VÐ+VÐ+VÐ+VÝÔ0ð 3ð 3ð 3ð 3õ Ô$Ð&JÐ&JÐ&JÐ&JÝÔ'ð *ð *ð *ð *õ Ô,Ð.NÐ.NÐ.NÐ.NÝÔ#Ð%=Ð%=Ð%=Ð%=ÝÔ$ dÔ&6Ô&>ð#
ð 
ð 	
r2   )r7   r   r%   r=   r;   r   r<   r>   r)   r$   r?   r6   )rT   rU   rV   rW   r?   r   )r?   rl   ©r?   rp   )ru   )rv   rw   r?   r   )ry   r   r?   rp   ©r?   r…   )r,   r-   r.   r/   r0   ÚclassmethodrS   rL   rn   rt   r^   r[   r„   Úpropertyr’   r1   r2   r3   r6   r6   <   s7  € € € € € € ðð ð $Ð#Ð#Ñ#ØÐÐÑØÐÐÑØÐÐÑØÐÐÑàð
 $(Ø#Ø-1Ø$(ð6ð 6ð 6ð 6ð 6ñ „[ð6ðp,ð ,ð ,ð ,ð\
<ð 
<ð 
<ð 
<ð-ð -ð -ð -ðð ð ð ð ðHð Hð Hð Hð
ð 
ð 
ð 
ð ð
ð 
ð 
ñ „Xð
ð 
ð 
r2   r6   c                  óˆ   — e Zd ZU dZded<   ded<   dZded<   d	Zd
ed<   edd„¦   «         Z	 ddd„Z	dd„Z
ed d„¦   «         ZdS )!ÚTLSListeneraš  
    A convenience listener that wraps another listener and auto-negotiates a TLS session
    on every accepted connection.

    If the TLS handshake times out or raises an exception,
    :meth:`handle_handshake_error` is called to do whatever post-mortem processing is
    deemed necessary.

    Supports only the :attr:`~TLSAttribute.standard_compatible` extra attribute.

    :param Listener listener: the listener to wrap
    :param ssl_context: the SSL context object
    :param standard_compatible: a flag passed through to :meth:`TLSStream.wrap`
    :param handshake_timeout: time limit for the TLS handshake
        (passed to :func:`~anyio.fail_after`)
    zListener[Any]Úlistenerzssl.SSLContextr<   Tr$   r)   é   ÚfloatÚhandshake_timeoutrk   rs   Ústreamr   r?   rp   c              ƒ  ó,  K  — t          |¦  «        ƒ d{V —† t          | t          ¦   «         ¦  «        s.t          j        t
          ¦  «                             d| ¬¦  «         t          | t          ¦  «        rt          | t          ¦   «         ¦  «        r‚ dS )a½  
        Handle an exception raised during the TLS handshake.

        This method does 3 things:

        #. Forcefully closes the original stream
        #. Logs the exception (unless it was a cancellation exception) using the
           ``anyio.streams.tls`` logger
        #. Reraises the exception if it was a base exception or a cancellation exception

        :param exc: the exception
        :param stream: the original stream

        NzError during TLS handshake)Úexc_info)r   re   r   ÚloggingÚ	getLoggerr,   Ú	exceptionÚ	Exception)rk   r    s     r3   Úhandle_handshake_errorz"TLSListener.handle_handshake_error  s«   è è € õ    Ñ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'õ ˜#Õ6Ñ8Ô8Ñ9Ô9ð 	õ
 Ô�hÑ'Ô'×1Ò1Ø,°sð 2ñ ô ð õ
 ˜#�yÑ)Ô)ð 	­Z¸Õ=TÑ=VÔ=VÑ-WÔ-Wð 	Øð	ð 	r2   NÚhandlerúCallable[[TLSStream], Any]Ú
task_groupúTaskGroup | Nonec              ƒ  óˆ   ‡ ‡K  — t          ‰¦  «        dˆˆ fd„¦   «         }‰ j                             ||¦  «        ƒ d {V —† d S )Nr    r   r?   rp   c              “  óN  •K  — ddl m} 	  |‰j        ¦  «        5  t                               | ‰j        ‰j        ¬¦  «        ƒ d {V —†}d d d ¦  «         n# 1 swxY w Y    ‰|¦  «        ƒ d {V —† d S # t          $ r'}‰                     || ¦  «        ƒ d {V —† Y d }~d S d }~ww xY w)Nr
   )Ú
fail_after)r<   r)   )	Ú r®   rŸ   r6   rS   r<   r)   rs   r§   )r    r®   Úwrapped_streamrk   r¨   rh   s       €€r3   Úhandler_wrapperz*TLSListener.serve.<locals>.handler_wrapper8  sP  øè è € à%Ð%Ð%Ð%Ð%Ð%ð
.Ø�Z Ô 6Ñ7Ô7ð ð Ý+4¯>ª>ØØ$(Ô$4Ø,0Ô,Dð ,:ñ ,ô ,ð &ð &ð &ð &ð &ð &�Nðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð �g˜nÑ-Ô-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ð-øõ !ð ?ð ?ð ?Ø×1Ò1°#°vÑ>Ô>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>øøøøð?øøøs:   ‹A3 ›.AÁ	A3 ÁAÁA3 ÁAÁA3 Á3
B$Á=BÂB$)r    r   r?   rp   )r   rœ   Úserve)rh   r¨   rª   r±   s   ``  r3   r²   zTLSListener.serve3  so   øøè è € õ
 
ˆw‰Œð	.ð 	.ð 	.ð 	.ð 	.ð 	.ñ 
Œð	.ð Œm×!Ò! /°:Ñ>Ô>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>r2   c              ƒ  óH   K  — | j                              ¦   «         ƒ d {V —† d S rr   )rœ   rt   ro   s    r3   rt   zTLSListener.acloseJ  s2   è è € ØŒm×"Ò"Ñ$Ô$Ð$Ð$Ð$Ð$Ð$Ð$Ð$Ð$Ð$r2   r…   c                ó&   ‡ — t           j        ˆ fd„iS )Nc                 ó   •— ‰ j         S rr   r�   ro   s   €r3   rŠ   z.TLSListener.extra_attributes.<locals>.<lambda>P  r�   r2   )r   r)   ro   s   `r3   r’   zTLSListener.extra_attributesM  s!   ø€ õ Ô,Ð.NÐ.NÐ.NÐ.Nð
ð 	
r2   )rk   rs   r    r   r?   rp   rr   )r¨   r©   rª   r«   r?   rp   r–   r—   )r,   r-   r.   r/   r0   r)   rŸ   Ústaticmethodr§   r²   rt   r™   r’   r1   r2   r3   r›   r›   û   sÏ   € € € € € € ðð ð" ÐÐÑØÐÐÑØ $ÐÐ$Ð$Ð$Ñ$Ø!ÐÐ!Ð!Ð!Ñ!àðð ð ñ „\ððD (,ð?ð ?ð ?ð ?ð ?ð.%ð %ð %ð %ð ð
ð 
ð 
ñ „Xð
ð 
ð 
r2   r›   )*Ú
__future__r   r£   r~   rC   ÚsysÚcollections.abcr   r   Údataclassesr   Ú	functoolsr   Útypingr   r	   r¯   r   r   r   r   Ú_core._typedattrr   r   Úabcr   r   r   r   Úversion_infor   r   Útyping_extensionsr   r   Útupler*   Ú_PCTRTTÚ_PCTRTTTr   r6   r›   r1   r2   r3   ú<module>rÄ      sc  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø 
€
€
€
Ø 
€
€
€
Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð BÐ AÐ AÐ AÐ AÐ AÐ AÐ AØ @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @àÔ�wÒÐØ+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Ð+à6Ð6Ð6Ð6Ð6Ð6Ð6Ð6àˆ7�:ÑÔ€Øˆ<˜
Ñ#Ô#€Ø
��c˜3�h” Ð$Ô
%€Ø�˜#�Ô€ð)ð )ð )ð )ð )Ð$ñ )ô )ð )ð8 €ˆeÐÑÔð{
ð {
ð {
ð {
ð {
�
ñ {
ô {
ñ Ôð{
ð| €ˆeÐÑÔðU
ð U
ð U
ð U
ð U
�(˜9Ô%ñ U
ô U
ñ ÔðU
ð U
ð U
r2   