
    i;                    T   % S SK Jr  S SKrS SKrS SKrS SKrS SKJrJr  S SK	J
r
  S SKJr  S SKJr  S SKJrJr  SS	KJrJrJrJrJr  SS
KJrJr  SSKJrJrJrJrJrJ r   \RB                  S:  a  S SKJ"r"  OS SK#J"r"  \RB                  S:  a	  S SKJ$r$J%r%  OS SK#J$r$J%r%  \RB                  S:  a  S SKJ&r&  OS SK#J&r&  \" S5      r'\$" S5      r(\)\)\*\*4   S4   r+S\,S'   \)\+S4   r-S\,S'    " S S\5      r.\
" SS9 " S S\5      5       r/\
" SS9 " S S\\/   5      5       r0 " S  S!\5      r1g)"    )annotationsN)CallableMapping)	dataclass)wraps)
SSLContext)AnyTypeVar   )BrokenResourceErrorEndOfStreamaclose_forcefullyget_cancelled_exc_class	to_thread)TypedAttributeSettyped_attribute)AnyByteStreamAnyByteStreamConnectable
ByteStreamByteStreamConnectableListener	TaskGroup)   
   )	TypeAlias)r      )TypeVarTupleUnpack)r      )overrideT_RetvalPosArgsT.r   _PCTRTT_PCTRTTTc                  
   \ rS rSr% Sr\" 5       rS\S'   \" 5       rS\S'   \" 5       r	S\S'   \" 5       r
S	\S
'   \" 5       rS\S'   \" 5       rS\S'   \" 5       rS\S'   \" 5       rS\S'   \" 5       rS\S'   \" 5       rS\S'   Srg)TLSAttribute3   z5Contains 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_version N)__name__
__module____qualname____firstlineno____doc__r   r)   __annotations__r+   r,   r-   r.   r0   r1   r3   r4   r6   __static_attributes__r7       Y/var/www/html/qgis-automation/mouza_env/lib/python3.13/site-packages/anyio/streams/tls.pyr&   r&   3   s    ? !0 1M:1(7(99#2#4F 4 FUEVBV,;,=\=')K) 9H8IN5I / 1J1 !0 11&(K(r?   r&   F)eqc                      \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S	\S'   \SSSSS.           SS jj5       r      SS jrSS jr	SS jr
SSS jjrSS jrSS jr\SS j5       rSrg) 	TLSStreamO   a  
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/   r4   r2   _ssl_objectzssl.MemoryBIO	_read_bio
_write_bioNT)r0   hostnamessl_contextr4   c                 #    Uc  U(       + nU(       d  U(       a  [         R                  R                  O[         R                  R                  n[         R                  " U5      n[        [         S5      (       a$  U=R                  [         R                  ) -  sl        [         R                  " 5       n[         R                  " 5       n[        U5      [         R                  L a  UR                  XxX#S9n	O-[        R                  " UR                  UUUUS5      I Sh  vN n	U " UUU	UUS9n
U
R                  U	R                  5      I Sh  vN   U
$  N3 N7f)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)r0   server_hostname)rE   r4   rF   rG   rH   )sslPurposeCLIENT_AUTHSERVER_AUTHcreate_default_contexthasattroptionsrL   	MemoryBIOtyper   wrap_bior   run_sync_call_sslobject_methoddo_handshake)clsrE   r0   rI   rJ   r4   purposebio_inbio_outr3   wrappers              r@   wrapTLSStream.wrapa   s,    : &,K+6''CKK<S<S  44W=K s677##(D(D'DD#--/ .$--[ . J  )11$$  J - 3"
 ,,Z-D-DEEE#  	Fs$   DEE,E
EEEc                  #      U" U6 nU R                   R                  (       a;  U R                  R                  U R                   R	                  5       5      I S h  vN   U$  N! [
        R                   Ga     U R                   R                  (       a<  U R                  R                  U R                   R	                  5       5      I S h  vN    U R                  R                  5       I S h  vN  nU R                  R                  U5         GO! [         a    U R                  R                  5           GO[         a@  nU R                  R                  5         U R                   R                  5         [        UeS nAff = f[
        R                   a@    U R                  R                  U R                   R	                  5       5      I S h  vN     GO[
        R                   a@  nU R                  R                  5         U R                   R                  5         [        UeS nAf[
        R                    a  nU R                  R                  5         U R                   R                  5         [#        U[
        R$                  5      (       d!  UR&                  (       a/  SUR&                  ;   a  U R(                  (       a  [        Ue[        S ee S nAff = fGM  7f)NUNEXPECTED_EOF_WHILE_READING)rH   pendingrE   sendreadrN   SSLWantReadErrorreceiverG   writer   	write_eofOSErrorr   SSLWantWriteErrorSSLSyscallErrorSSLError
isinstanceSSLEOFErrorstrerrorr4   )selffuncargsresultdataexcs         r@   rY    TLSStream._call_sslobject_method   s     (tH ??**//44T__5I5I5KLLL MI '' //.."33889M9M9OPPP!%!6!6!>!>!@@@D NN((. # /NN,,.. 7NN,,.OO--/-367 (( I++001E1E1GHHH&& 3((*))+)s2<< ((*))+c3??33LL%Cs||%S//1s:)t31 s   KA$ AKA"K$K:ADC"D.C1/D4KK$F6K7K:	F;E>>FAKGKKK+;H&&K=BKKKc                  #    U R                  U R                  R                  5      I Sh  vN   U R                  R	                  5         U R
                  R	                  5         U R                  U R                  R                  5       4$  N^7f)zl
Does the TLS closing handshake.

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

N)rY   rF   unwraprG   rj   rH   rE   rf   rr   s    r@   rz   TLSStream.unwrap   sk      ))$*:*:*A*ABBB  "!!#$$dnn&9&9&;;; 	Cs   )BB
ABc                  #    U R                   (       a   U R                  5       I S h  vN   U R                  R                  5       I S h  vN   g  N'! [         a     [        U R                  5      I S h  vN    e f = f N47fN)r4   rz   BaseExceptionr   rE   acloser{   s    r@   r   TLSStream.aclose   sl     ##kkm##
 ##**,,, $  '(=(=>>> 	-sC   BA AA B
A?BA "A<4A75A<<Bc                   #    U R                  U R                  R                  U5      I S h  vN nU(       d  [        eU$  N7fr~   )rY   rF   rf   r   )rr   	max_bytesrv   s      r@   rh   TLSStream.receive   s:     001A1A1F1F	RR	 Ss   *AA Ac                l   #    U R                  U R                  R                  U5      I S h  vN   g  N7fr~   )rY   rF   ri   )rr   items     r@   re   TLSStream.send   s'     ))$*:*:*@*@$GGGs   *424c                <  #    U R                  [        R                  5      n[        R                  " SU5      nU(       aQ  [        UR                  S5      5      [        UR                  S5      =(       d    S5      pCX44S:  a  [        SU 35      e[        S5      e7f)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&   r6   rematchintgroupNotImplementedError)rr   r6   r   majorminors        r@   send_eofTLSStream.send_eof   s     jj!9!9:1;?u{{1~.EKKN4Ga0H5~&)$$/=2 
 "E
 	
s   BBc                H  ^  0 T R                   R                  E[        R                  T R                  R
                  [        R                  T R                  R                  [        R                  T R                  R                  [        R                  U 4S j[        R                  U 4S j[        R                  U 4S j[        R                  U 4S j[        R                  U 4S j[        R                  U 4S j[        R                  T R                  R                   0
E$ )Nc                 :   > T R                   R                  S5      $ )NFrF   getpeercertr{   s   r@   <lambda>,TLSStream.extra_attributes.<locals>.<lambda>  s    43C3C3O3OPU3Vr?   c                 :   > T R                   R                  S5      $ )NTr   r{   s   r@   r   r     s    $:J:J:V:V;r?   c                 0   > T R                   R                  $ r~   )rF   r0   r{   s   r@   r   r     s    d.>.>.J.Jr?   c                 r   > T R                   R                  (       a  T R                   R                  5       $ S $ r~   )rF   r0   r1   r{   s   r@   r   r     s3    ++ 261A1A1P1P1R 22r?   c                    > T R                   $ r~   r4   r{   s   r@   r   r         d6N6Nr?   c                    > T R                   $ r~   )rF   r{   s   r@   r   r     s    T-=-=r?   )rE   extra_attributesr&   r)   rF   selected_alpn_protocolr+   get_channel_bindingr,   r-   r.   r0   r1   r4   r3   r6   versionr{   s   `r@   r   TLSStream.extra_attributes  s    
##44
&&(8(8(O(O33  44!1!1!8!8))+V00 3 $$&J'' * ,,.N##%=$$d&6&6&>&>#
 	
r?   r7   )rE   r   r0   zbool | NonerI   r(   rJ   ssl.SSLContext | Noner4   r/   returnrC   )rs   z&Callable[[Unpack[PosArgsT]], T_Retval]rt   zUnpack[PosArgsT]r   r!   )r   ztuple[AnyByteStream, bytes]r   None)i   )r   r   r   r*   )r   r*   r   r   r   zMapping[Any, Callable[[], Any]])r8   r9   r:   r;   r<   r=   classmethodr`   rY   rz   r   rh   re   r   propertyr   r>   r7   r?   r@   rC   rC   O   s     $#
 $(#-1$(D'D !	D
 D +D "D 
D DL,:,CS,	,\
<-H
 
 
r?   rC   c                      \ rS rSr% SrS\S'   S\S'   SrS\S	'   S
rS\S'   \SS j5       r	 S     SS jjr
SS jr\SS j5       rSrg)TLSListeneri  aj  
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.SSLContextrJ   Tr/   r4      floathandshake_timeoutc                  #    [        U5      I Sh  vN   [        U [        5       5      (       d(  [        R                  " [
        5      R                  SU S9  [        U [        5      (       a  [        U [        5       5      (       a  e g Nu7f)au  
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   ro   r   logging	getLoggerr8   	exception	Exception)rw   streams     r@   handle_handshake_error"TLSListener.handle_handshake_error4  sz        ''' #6899
 h'11,s 2 
 #y))Z=T=V-W-W .X 	(s   B	BA6B	Nc                   ^ ^#    [        T5      SUU 4S jj5       nT R                  R                  X25      I S h  vN   g  N7f)Nc                `  >#    SSK Jn   U" TR                  5         [        R	                  U TR
                  TR                  S9I S h  vN nS S S 5        T" W5      I S h  vN   g  N! , (       d  f       N!= f N! [         a$  nTR                  X05      I S h  vN     S nAg S nAff = f7f)Nr   )
fail_after)rJ   r4   )	 r   r   rC   r`   rJ   r4   r   r   )r   r   wrapped_streamrw   handlerrr   s       r@   handler_wrapper*TLSListener.serve.<locals>.handler_wrapperY  s     %
. 6 67+4>>$($4$4,0,D,D ,: , &N 8 n---& 87 . ! ?11#>>>?su   B.A= -A*
A(A*A= B."A;#B.(A**
A84A= ;B.=
B+B&BB&!B.&B++B.)r   r   r   r   )r   r   serve)rr   r   
task_groupr   s   ``  r@   r   TLSListener.serveT  s8     
 
w	. 
	. mm!!/>>>s   6AA Ac                T   #    U R                   R                  5       I S h  vN   g  N7fr~   )r   r   r{   s    r@   r   TLSListener.aclosek  s     mm""$$$s   (&(c                0   ^  [         R                  U 4S j0$ )Nc                    > T R                   $ r~   r   r{   s   r@   r   .TLSListener.extra_attributes.<locals>.<lambda>q  r   r?   )r&   r4   r{   s   `r@   r   TLSListener.extra_attributesn  s     ,,.N
 	
r?   r7   )rw   r   r   r   r   r   r~   )r   zCallable[[TLSStream], Any]r   zTaskGroup | Noner   r   r   r   )r8   r9   r:   r;   r<   r=   r4   r   staticmethodr   r   r   r   r   r>   r7   r?   r@   r   r     s}    "  $$!u! D (,?+? %? 
	?.% 
 
r?   r   c                  T    \ rS rSrSrSSSS.         S	S jjr\S
S j5       rSrg)TLSConnectableiu  a  
Wraps another connectable and does TLS negotiation after a successful connection.

:param connectable: the connectable to wrap
:param hostname: host name of the server (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 server does the same
NTrI   rJ   r4   c               H   Xl         U=(       d.    [        R                  " [        R                  R                  5      U l        [        U R
                  [        R                  5      (       d+  [        S[        U R
                  5      R                   35      eX l        X@l        g )Nz7ssl_context must be an instance of ssl.SSLContext, not )connectablerN   rR   rO   rQ   rJ   ro   r   	TypeErrorrV   r8   rI   r4   )rr   r   rI   rJ   r4   s        r@   __init__TLSConnectable.__init__  s     ''2 (
c6P6PKK##7
 $**CNN;;I(()2235  !#6 r?   c                  #    U R                   R                  5       I S h  vN n [        R                  UU R                  U R
                  U R                  S9I S h  vN $  NA N! [         a    [        U5      I S h  vN    e f = f7f)Nr   )	r   connectrC   r`   rI   rJ   r4   r   r   )rr   r   s     r@   r   TLSConnectable.connect  s     ''//11		" ,,$($<$<	 (    2  	#F+++	sD   B	A"B	7A& A$A& !B	$A& &B>B?BB	)r   rI   rJ   r4   )
r   r   rI   r(   rJ   r   r4   r/   r   r   )r   rC   )	r8   r9   r:   r;   r<   r   r    r   r>   r7   r?   r@   r   r   u  s[    	  $-1$(7-7 	7
 +7 "7 
7(  r?   r   )2
__future__r   r   r   rN   syscollections.abcr   r   dataclassesr   	functoolsr   r   typingr	   r
   r   r   r   r   r   r   _core._typedattrr   r   abcr   r   r   r   r   r   version_infor   typing_extensionsr   r   r    r!   r"   tupler5   r#   r=   r$   r&   rC   r   r   r7   r?   r@   <module>r      s(   "  	 
 
 - !     B  w +w++6w*:
#5c?C/0 0GSL)) ))$ )8 eI

 I
 I
X eU
(9% U
 U
p,* ,r?   