§
     @gC/  ã                  ó”  — d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZ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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)Ú	dataclass)Úwraps)ÚAnyÚCallableÚMappingÚTupleÚTypeVaré   )ÚBrokenResourceErrorÚEndOfStreamÚaclose_forcefullyÚget_cancelled_exc_class)ÚTypedAttributeSetÚtyped_attribute)ÚAnyByteStreamÚ
ByteStreamÚListenerÚ	TaskGroupÚT_Retval.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*dict[str, str | _PCTRTTT | _PCTRTT] | NoneÚ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'   © ó    úE/var/www/piapp/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ð DSÀ?ÑCTÔCTÐÐTÐTÐTÑTà,;¨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Ð(Ð(Ð(Ñ(Ð(Ð(r.   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 | Noner7   r   r8   ú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)r3   r%   r4   r5   r6   )ÚsslÚPurposeÚCLIENT_AUTHÚSERVER_AUTHÚcreate_default_contextÚhasattrÚoptionsr=   Ú	MemoryBIOÚwrap_bioÚ_call_sslobject_methodÚdo_handshake)Úclsr3   r!   r7   r8   r%   ÚpurposeÚbio_inÚbio_outr$   Úwrappers              r/   ÚwrapzTLSStream.wrapF   s  è è € ð8 ÐØ&˜,ˆ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Øˆr.   ÚfuncúCallable[..., T_Retval]ÚargsÚobjectr   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        $ rr}| j                             ¦   «          | j                              ¦   «          t#          |t
          j        ¦  «        s	d|j        v r| j        rt          |‚t          d ‚‚ d }~ww xY w�Œc)NTÚUNEXPECTED_EOF_WHILE_READING)r6   Úpendingr3   ÚsendÚreadr?   ÚSSLWantReadErrorÚreceiver5   Úwriter   Ú	write_eofÚOSErrorr   ÚSSLWantWriteErrorÚSSLSyscallErrorÚSSLErrorÚ
isinstanceÚSSLEOFErrorÚstrerrorr%   )ÚselfrP   rR   ÚresultÚdataÚexcs         r/   rH   z TLSStream._call_sslobject_method~   s·  è è € ð*	ð)Ø˜˜t˜�ðJ ”?Ô*ð MØÔ/×4Ò4°T´_×5IÒ5IÑ5KÔ5KÑLÔLÐLÐLÐLÐLÐLÐLÐLà�øõO Ô'ð /ð /ð /ð/à”Ô.ð 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øøøøÝ”<ð ð ð Ø”×(Ò(Ñ*Ô*Ð*Ø”×)Ò)Ñ+Ô+Ð+å˜s¥C¤OÑ4Ô4ð4à5¸¼ÐEÐEàÔ/ð 4Ý1°sÐ:å)¨tÐ3àøøøøðøøøñ1*	sb   …A ÁI"ÁA"CÃI"Ã#E	Ã?I"Ä	E	Ä
:EÅE	Å	I"ÅAI"ÆI"Æ$:GÇI"Ç0A-IÉ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)rH   r4   Úunwrapr5   r\   r6   r3   rX   ©rd   s    r/   rj   zTLSStream.unwrap­   sx   è è € ð ×)Ò)¨$Ô*:Ô*AÑBÔBÐBÐBÐBÐBÐBÐBÐBØŒ× Ò Ñ"Ô"Ð"ØŒ×!Ò!Ñ#Ô#Ð#ØÔ$ d¤n×&9Ò&9Ñ&;Ô&;Ð;Ð;r.   ÚNonec              ƒ  óà   K  — | j         rE	 |                      ¦   «         ƒ d {V —† n)# t          $ r t          | j        ¦  «        ƒ d {V —† ‚ w xY w| j                             ¦   «         ƒ d {V —† d S ©N)r%   rj   ÚBaseExceptionr   r3   Úacloserk   s    r/   rp   zTLSStream.aclose¹   s©   è è € ØÔ#ð 	ðØ—k’k‘m”mÐ#Ð#Ð#Ð#Ð#Ð#Ð#Ð#øÝ ð ð ð Ý'¨Ô(=Ñ>Ô>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Øðøøøð Ô#×*Ò*Ñ,Ô,Ð,Ð,Ð,Ð,Ð,Ð,Ð,Ð,Ð,s	   ‹& ¦&Aé   Ú	max_bytesÚintr   c              ƒ  óh   K  — |                       | j        j        |¦  «        ƒ d {V —†}|st          ‚|S rn   )rH   r4   rX   r   )rd   rr   rf   s      r/   rZ   zTLSStream.receiveÃ   sF   è è € Ø×0Ò0°Ô1AÔ1FÈ	ÑRÔRÐRÐRÐRÐRÐRÐRˆØð 	ÝÐàˆr.   Úitemc              ƒ  óV   K  — |                       | j        j        |¦  «        ƒ d {V —† d S rn   )rH   r4   r[   )rd   ru   s     r/   rW   zTLSStream.sendÊ   s:   è è € Ø×)Ò)¨$Ô*:Ô*@À$ÑGÔGÐGÐGÐGÐGÐGÐGÐGÐGÐGr.   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   )rx   é   z;send_eof() requires at least TLSv1.3; current session uses z7send_eof() has not yet been implemented for TLS streams)Úextrar   r'   ÚreÚmatchrs   ÚgroupÚNotImplementedError)rd   r'   r|   ÚmajorÚminors        r/   Ú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ñ
ô 
ð 	
r.   ú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©r4   Úgetpeercertrk   s   €r/   ú<lambda>z,TLSStream.extra_attributes.<locals>.<lambda>ã   s   ø€ °4Ô3C×3OÒ3OÐPUÑ3VÔ3V€ r.   c                 ó8   •— ‰ j                              d¦  «        S )NTr…   rk   s   €r/   r‡   z,TLSStream.extra_attributes.<locals>.<lambda>ä   s   ø€ ¸$Ô:J×:VÒ:VØñ;ô ;€ r.   c                 ó   •— ‰ j         j        S rn   )r4   r!   rk   s   €r/   r‡   z,TLSStream.extra_attributes.<locals>.<lambda>ç   s   ø€ ¨dÔ.>Ô.J€ r.   c                 óR   •— ‰ j         j        r‰ j                              ¦   «         nd S rn   )r4   r!   r"   rk   s   €r/   r‡   z,TLSStream.extra_attributes.<locals>.<lambda>è   s-   ø€ ØÔÔ+ð2°Ô1A×1PÒ1PÑ1RÔ1RÐ1Ràð r.   c                 ó   •— ‰ j         S rn   ©r%   rk   s   €r/   r‡   z,TLSStream.extra_attributes.<locals>.<lambda>ë   ó
   ø€ °dÔ6N€ r.   c                 ó   •— ‰ j         S rn   )r4   rk   s   €r/   r‡   z,TLSStream.extra_attributes.<locals>.<lambda>ì   s
   ø€ ¨TÔ-=€ r.   )r3   Úextra_attributesr   r   r4   Úselected_alpn_protocolr   Úget_channel_bindingr   r   r   r!   r"   r%   r$   r'   Úversionrk   s   `r/   r�   zTLSStream.extra_attributesÜ   sÝ   ø€ ð
ØÔ#Ô4ð
åÔ&¨Ô(8Ô(OÝÔ3°TÔ5EÔ5YÝÔ Ô!1Ô!8ÝÔ)Ð+VÐ+VÐ+VÐ+VÝÔ0ð 3ð 3ð 3ð 3õ Ô$Ð&JÐ&JÐ&JÐ&JÝÔ'ð *ð *ð *ð *õ Ô,Ð.NÐ.NÐ.NÐ.NÝÔ#Ð%=Ð%=Ð%=Ð%=ÝÔ$ dÔ&6Ô&>ð
ð 
ð 	
r.   )r3   r   r!   r9   r7   r   r8   r:   r%   r    r;   r2   )rP   rQ   rR   rS   r;   r   )r;   rh   ©r;   rl   )rq   )rr   rs   r;   r   )ru   r   r;   rl   ©r;   r‚   )r(   r)   r*   r+   r,   ÚclassmethodrO   rH   rj   rp   rZ   rW   r�   Úpropertyr�   r-   r.   r/   r2   r2   4   s7  € € € € € € ðð ð $Ð#Ð#Ñ#ØÐÐÑØÐÐÑØÐÐÑØÐÐÑàð
 $(Ø#Ø-1Ø$(ð5ð 5ð 5ð 5ð 5ñ „[ð5ðn-ð -ð -ð -ð^
<ð 
<ð 
<ð 
<ð-ð -ð -ð -ðð ð ð ð ðHð Hð Hð Hð
ð 
ð 
ð 
ð ð
ð 
ð 
ñ „Xð
ð 
ð 
r.   r2   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.SSLContextr8   Tr    r%   é   ÚfloatÚhandshake_timeoutrg   ro   Ústreamr   r;   rl   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)r   ra   r   ÚloggingÚ	getLoggerr(   Ú	exceptionÚ	Exception)rg   r�   s     r/   Úhandle_handshake_errorz"TLSListener.handle_handshake_error  s�   è è € õ    Ñ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'õ ˜#Õ6Ñ8Ô8Ñ9Ô9ð 	PÝÔ�hÑ'Ô'×1Ò1Ð2NÑOÔOÐOõ ˜#�yÑ)Ô)ð 	­Z¸Õ=TÑ=VÔ=VÑ-WÔ-Wð 	Øð	ð 	r.   NÚhandlerúCallable[[TLSStream], Any]Ú
task_groupúTaskGroup | Nonec              ƒ  óˆ   ‡ ‡K  — t          ‰¦  «        dˆˆ fd„¦   «         }‰ j                             ||¦  «        ƒ d {V —† d S )Nr�   r   r;   rl   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)r8   r%   )	Ú rª   rœ   r2   rO   r8   r%   ro   r£   )r�   rª   Úwrapped_streamrg   r¤   rd   s       €€r/   Úhandler_wrapperz*TLSListener.serve.<locals>.handler_wrapper'  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;   rl   )r   r™   Úserve)rd   r¤   r¦   r­   s   ``  r/   r®   zTLSListener.serve"  so   øøè è € õ
 
ˆw‰Œð	.ð 	.ð 	.ð 	.ð 	.ð 	.ñ 
Œð	.ð Œm×!Ò! /°:Ñ>Ô>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>r.   c              ƒ  óH   K  — | j                              ¦   «         ƒ d {V —† d S rn   )r™   rp   rk   s    r/   rp   zTLSListener.aclose9  s2   è è € ØŒm×"Ò"Ñ$Ô$Ð$Ð$Ð$Ð$Ð$Ð$Ð$Ð$Ð$r.   r‚   c                ó&   ‡ — t           j        ˆ fd„iS )Nc                 ó   •— ‰ j         S rn   rŒ   rk   s   €r/   r‡   z.TLSListener.extra_attributes.<locals>.<lambda>?  r�   r.   )r   r%   rk   s   `r/   r�   zTLSListener.extra_attributes<  s!   ø€ õ Ô,Ð.NÐ.NÐ.NÐ.Nð
ð 	
r.   )rg   ro   r�   r   r;   rl   rn   )r¤   r¥   r¦   r§   r;   rl   r“   r”   )r(   r)   r*   r+   r,   r%   rœ   Ústaticmethodr£   r®   rp   r–   r�   r-   r.   r/   r˜   r˜   ñ   sÎ   € € € € € € ðð ð  ÐÐÑØÐÐÑØ $ÐÐ$Ð$Ð$Ñ$Ø!ÐÐ!Ð!Ð!Ñ!àðð ð ñ „\ðð8 (,ð?ð ?ð ?ð ?ð ?ð.%ð %ð %ð %ð ð
ð 
ð 
ñ „Xð
ð 
ð 
r.   r˜   )#Ú
__future__r   rŸ   r{   r?   Údataclassesr   Ú	functoolsr   Útypingr   r   r   r	   r
   r«   r   r   r   r   Ú_core._typedattrr   r   Úabcr   r   r   r   r   r&   Ú_PCTRTTÚ_PCTRTTTr   r2   r˜   r-   r.   r/   ú<module>r»      s  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø 
€
€
€
Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ð BÐ AÐ AÐ AÐ AÐ AÐ AÐ AØ @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @àˆ7�:ÑÔ€Ø
��c˜3�h” Ð$Ô
%€Ø�˜#�Ô€ð)ð )ð )ð )ð )Ð$ñ )ô )ð )ð8 €ˆeÐÑÔðy
ð y
ð y
ð y
ð y
�
ñ y
ô y
ñ Ôðy
ðx €ˆeÐÑÔðN
ð N
ð N
ð N
ð N
�(˜9Ô%ñ N
ô N
ñ ÔðN
ð N
ð N
r.   