Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
tls.cpython-313.pyc156 linesDownload Raw Back to __pycache__
1�

2�j�;��"�%SSKJr SrSSKrSSKrSSKrSSKrSSKJrJ	r	 SSK3Jr SSKJ
r
 SSKJr SSKJrJrJr S	S4KJrJrJrJrJr S	SKJrJr S	SKJrJrJrJ r J!r!J"r" \RFS
:�a	SSKJ$r$J%r% OSSK&J$r$J%r% \RFS:�aSSKJ'r' OSSK&J'r' \"S5r(\$"S5r)\*\*\+\+4S4r,S\-S'\*\,S4r.S\-S'"SS\5r/\"SS9"SS\55r0\"SS9"SS\!\055r1"SS \ 5r2g)!�)�annotations)�TLSAttribute�TLSConnectable�TLSListener�	TLSStreamN)�Callable�Mapping)�	dataclass)�wraps)�5SSLContext)�Any�	TypeAlias�TypeVar�)�BrokenResourceError�EndOfStream�aclose_forcefully�get_cancelled_exc_class�	to_thread)�TypedAttributeSet�typed_attribute)�
AnyByteStream�AnyByteStreamConnectable�6ByteStream�ByteStreamConnectable�Listener�	TaskGroup)��)�TypeVarTuple�Unpack)r�)�override�T_Retval�PosArgsT.r�_PCTRTT�_PCTRTTTc�7�\rSrSr%Sr\"5rS\S'\"5rS\S'\"5r	S\S'\"5r8S	\S9'\"5rS\S'\"5rS
\S'\"5r
S\S'\"5rS\S'\"5rS
\S'\"5rS\S'Srg)r�5z5Contains Transport Layer Security related attributes.�10str | None�
alpn_protocol�bytes�channel_binding_tls_uniqueztuple[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�11ssl_object�standard_compatible�str�tls_version�N)�__name__�12__module__�__qualname__�__firstlineno__�__doc__rr+�__annotations__r-r.r/r0r2r3r5r6r8�__static_attributes__r9��WD:\code\apps\devtools\python\user_packages\Python313\site-packages\anyio/streams/tls.pyrr5s���?�!0� 1�M�:�1�(7�(9���9�#2�#4�F� �4�FU�EV��B�V�,;�,=��\�=�'�)�K��)�9H�8I�N�5�I� /� 1�J�
�1�!0� 1���1�&�(�K��(rArF)�eqc���\rSrSr%SrS\S'S\S'S\S'S	\S13'S	\S'\SSSS
S.SSjj5rSSjrSSjr	SSjr14SSSjjrSSjrSSjr
\SSj5rSrg) r�Qa15A stream wrapper that encrypts all sent data and decrypts received data.16 17This class has no public initializer; use :meth:`wrap` instead.18All extra attributes from :class:`~TLSAttribute` are supported.19 20:var AnyByteStream transport_stream: the wrapped stream21 22r�transport_streamr1r6r4�_ssl_objectz
ssl.MemoryBIO�	_read_bio�23_write_bioNT)r2�hostname�ssl_contextr6c��# �UcU(+nU(d�U(a[RRO[RRn[R"U5n[[S5(a$U=R[R)-sl[R"5n[R"5n[U5[RLaURXxX#S9n	O-[R"URUUUUS5IShv�Nn	U"UUU	UUS9n24U25RU	R5IShv�N U26$N3N7f)a\27Wrap an existing stream with Transport Layer Security.28 29This performs a TLS handshake with the peer.30 31:param transport_stream: a bytes-transporting stream to wrap32:param server_side: ``True`` if this is the server side of the connection,33    ``False`` if this is the client side (if omitted, will be set to ``False``34    if ``hostname`` has been provided, ``False`` otherwise). Used only to create35    a default context when an explicit context has not been provided.36:param hostname: host name of the peer (if host name checking is desired)37:param ssl_context: the SSLContext object to use (if not provided, a secure38    default will be created)39:param standard_compatible: if ``False``, skip the closing handshake when40    closing the connection, and don't raise an exception if the peer does the41    same42:raises ~ssl.SSLError: if the TLS handshake fails43 44N�OP_IGNORE_UNEXPECTED_EOF)r2�server_hostname)rFr6rGrHrI)�ssl�Purpose�CLIENT_AUTH�SERVER_AUTH�create_default_context�hasattr�optionsrM�	MemoryBIO�typer�wrap_bior�run_sync�_call_sslobject_method�do_handshake)�clsrFr2rJrKr6�purpose�bio_in�bio_outr5�wrappers           rB�wrap�TLSStream.wrapcs,���:��&�,�K��+6����'�'�C�K�K�<S�<S�
��4�4�W�=�K��s�6�7�7��#�#��(D�(D�'D�D�#�������-�-�/��������.�$�-�-��[�.��J� )�1�1��$�$������
 ��J��-� 3�"���45���,�,�Z�-D�-D�E�E�E���#� 	F�s$�DE�E�,E�46E�E�Ec��# �U"U6nURR(a;URRURR	55IShv�N U$N![47RGa URR(a<URRURR	55IShv�N URR5IShv�NnURRU5 GO�![a URR5 GO�[a@nURR5 URR5 [UeSnAff=f[48Ra@ URRURR	55IShv�N GO[49Ra@nURR5 URR5 [UeSnAf[50R a�nURR5 URR5 [#U[51R$5(d!UR&(a/SUR&;aUR((a[Ue[SeeSnAff=fGM�7f)N�UNEXPECTED_EOF_WHILE_READING)rI�pendingrF�send�readrO�SSLWantReadError�receiverH�writer�	write_eof�OSErrorr�SSLWantWriteError�SSLSyscallError�SSLError�52isinstance�SSLEOFError�strerrorr6)�self�func�args�result�data�excs      rBrZ� TLSStream._call_sslobject_method�s����(
��t���H�?�?�*�*��/�/�4�4�T�_�_�5I�5I�5K�L�L�L��
�M��I�'�'�
/�
/����.�.�"�3�3�8�8����9M�9M�9O�P�P�P�!%�!6�!6�!>�!>�!@�@�@�D��N�N�(�(��.��#�/��N�N�,�,�.�.��7��N�N�,�,�.��O�O�-�-�/�-�3�6��7���(�(�
I��+�+�0�0����1E�1E�1G�H�H�H��&�&�
3����(�(�*����)�)�+�)�s�2���<�<�
����(�(�*����)�)�+��c�3�?�?�3�3��L�L�%C�s�|�|�%S��/�/�1�s�:�)�t�3���
��1�s��K�A$�AK�A"�K�$K�:AD�C�"D�.C1�/D�4K�K�$F�6K�7K�:	F�;E>�>F�AK�G�K�K�K�+;H&�&K�=BK�K�Kc��# �URURR5IShv�N URR	5 UR53R	5 URURR54$N^7f)zl54Does the TLS closing handshake.55 56:return: a tuple of (wrapped byte stream, bytes left in the read buffer)57 58N)rZrG�unwraprHrkrIrFrg�rss rBr{�TLSStream.unwrap�sk����)�)�$�*:�*:�*A�*A�B�B�B���� � �"����!�!�#��$�$�d�n�n�&9�&9�&;�;�;�	C�s�)B�B59�ABc��# �UR(aUR5IShv�N URR5IShv�N gN'![a  [UR5IShv�N ef=fN47f�N)r6r{�
BaseExceptionrrF�acloser|s rBr��TLSStream.aclose�sl����#�#�
��k�k�m�#�#�60�#�#�*�*�,�,�,�$�� �
�'��(=�(=�>�>�>��
��	-�sC�B�A�A�A�B�61A?�B�A�"A<�4A7�5A<�<Bc��# �URURRU5IShv�NnU(d[eU$N7fr)rZrGrgr)rs�	max_bytesrws   rBri�TLSStream.receive�s:����0�0��1A�1A�1F�1F�	�R�R�������	S�s�*A�A�Ac��l# �URURRU5IShv�N gN7fr)rZrGrj)rs�items  rBrf�TLSStream.send�s'����)�)�$�*:�*:�*@�*@�$�G�G�G�s�*4�2�4c��<# �UR[R5n[R"SU5nU(aQ[UR
S55[UR
S5=(d S5pCX44S:a[SU35e[S5e7f)NzTLSv(\d+)(?:\.(\d+))?�rr)r�rz;send_eof() requires at least TLSv1.3; current session uses z7send_eof() has not yet been implemented for TLS streams)�extrarr8�re�match�int�group�NotImplementedError)rsr8r��major�minors     rB�send_eof�TLSStream.send_eof�s�����j�j��!9�!9�:�����1�;�?����u�{�{�1�~�.��E�K�K��N�4G�a�0H�5��~��&�)�$�$/�=�2���62"�E�63�	64�s�BBc�H^�0TRRE[RTRR65[RTRR[RTRR[RU4Sj[RU4Sj[RU4Sj[RU4Sj[RU4Sj[RU4Sj[RTRR 066E$)Nc�:>�TRRS5$)NF�rG�getpeercertr|s�rB�<lambda>�,TLSStream.extra_attributes.<locals>.<lambda>s���4�3C�3C�3O�3O�PU�3VrAc�:>�TRRS5$)NTr�r|s�rBr�r�s���$�:J�:J�:V�:V��;rAc�0>�TRR$r)rGr2r|s�rBr�r�s���d�.>�.>�.J�.JrAc�r>�TRR(aTRR5$S$r)rGr2r3r|s�rBr�r�s3����#�#�/�/�� � �/�/�1���rAc�>�TR$r�r6r|s�rBr�r�����d�6N�6NrAc�>�TR$r)rGr|s�rBr�r�s���T�-=�-=rA)rF�extra_attributesrr+rG�selected_alpn_protocolr-�get_channel_bindingr.r/r0r2r3r6r5r8�versionr|s`rBr��TLSStream.extra_attributess����67��#�#�4�4�68��&�&��(8�(8�(O�(O��3�3�� � �4�4�����!1�!1�!8�!8��)�)�+V��0�0�3�
�$�$�&J��'�'�*�69
�,�,�.N��#�#�%=��$�$�d�&6�&6�&>�&>�'70�	71rAr9)rFrr2zbool | NonerJr*rK�ssl.SSLContext | Noner6r1�returnr)rtz&Callable[[Unpack[PosArgsT]], T_Retval]ruzUnpack[PosArgsT]r�r$)r�ztuple[AnyByteStream, bytes]�r��None)i)r�r�r�r,)r�r,r�r��r�zMapping[Any, Callable[[], Any]])r:r;r<r=r>r?�classmethodrarZr{r�rirfr��propertyr�r@r9rArBrrQs����$�#����������72$(�#�-1�$(�D�'�D�!�	D�73�D�+�
D�"�D�74�D��D�L,�:�,�CS�,�	�,�\75<�-��H�
76��77��78rArc��\rSrSr%SrS\S'S\S'SrS\S	'S79rS\S'\SS
j5r	SSSjjr80SSjr\SSj5r
Srg)ri aj81A convenience listener that wraps another listener and auto-negotiates a TLS session82on every accepted connection.83 84If the TLS handshake times out or raises an exception,85:meth:`handle_handshake_error` is called to do whatever post-mortem processing is86deemed necessary.87 88Supports only the :attr:`~TLSAttribute.standard_compatible` extra attribute.89 90:param Listener listener: the listener to wrap91:param ssl_context: the SSL context object92:param standard_compatible: a flag passed through to :meth:`TLSStream.wrap`93:param handshake_timeout: time limit for the TLS handshake94    (passed to :func:`~anyio.fail_after`)95z
Listener[Any]�listenerzssl.SSLContextrKTr1r6��float�handshake_timeoutc��# �[U5IShv�N [U[55(d([R"[965R
SUS9 [U[5(a[U[55(aegNu7f)au97Handle an exception raised during the TLS handshake.98 99This method does 3 things:100 101#. Forcefully closes the original stream102#. Logs the exception (unless it was a cancellation exception) using the103   ``anyio.streams.tls`` logger104#. Reraises the exception if it was a base exception or a cancellation exception105 106:param exc: the exception107:param stream: the original stream108 109NzError during TLS handshake)�exc_info)rrpr�logging�	getLoggerr:�	exception�	Exception)rx�streams  rB�handle_handshake_error�"TLSListener.handle_handshake_error8sz���  ��'�'�'��#�6�8�9�9�110
���h�'�1�1�,�s�
2�
�111�#�y�)�)�Z��=T�=V�-W�-W��.X�	(�s�B	�B�A6B	Nc��^^# �[T5SUU4Sjj5nTRRX25IShv�N gN7f)Nc��`># �SSKJn U"TR5 [R	UTR112TRS9IShv�NnSSS5 T"W5IShv�N gN!,(df   N!=fN![a$nTRX05IShv�N SnAgSnAff=f7f)Nr)�113fail_after)rKr6)	�r�r�rrarKr6r�r�)r�r��wrapped_streamrx�handlerrss    ��rB�handler_wrapper�*TLSListener.serve.<locals>.handler_wrapper]s�����%�114
.��� 6� 6�7�+4�>�>��$(�$4�$4�,0�,D�,D�,:�,�&�N�8��n�-�-�-�&�8�7��.��!�
?��1�1�#�>�>�>��
?�su�B.�A=�-A*�115A(�A*�A=�B.�"A;�#B.�(A*�*116A8�4A=�;B.�=117B+�B&�B�B&�!B.�&B+�+B.)r�rr�r�)rr��serve)rsr��118task_groupr�s``  rBr��TLSListener.serveXs8����119120�w��
	.�121�
	.��m�m�!�!�/�>�>�>�s�6A�A�Ac��T# �URR5IShv�N gN7fr)r�r�r|s rBr��TLSListener.acloseos����m�m�"�"�$�$�$�s�(�&�(c�0^�[RU4Sj0$)Nc�>�TR$rr�r|s�rBr��.TLSListener.extra_attributes.<locals>.<lambda>ur�rA)rr6r|s`rBr��TLSListener.extra_attributesrs���
�,�,�.N�122�	123rAr9)rxr�r�rr�r�r)r�zCallable[[TLSStream], Any]r�zTaskGroup | Noner�r�r�r�)r:r;r<r=r>r?r6r��staticmethodr�r�r�r�r�r@r9rArBrr s}���"���� $���$�!��u�!�����D(,�?�+�?�%�?�124�	?�.%��125��126rArc�T�\rSrSrSrSSSS.S	Sjjr\S127Sj5rSrg)riya�128Wraps another connectable and does TLS negotiation after a successful connection.129 130:param connectable: the connectable to wrap131:param hostname: host name of the server (if host name checking is desired)132:param ssl_context: the SSLContext object to use (if not provided, a secure default133    will be created)134:param standard_compatible: if ``False``, skip the closing handshake when closing135    the connection, and don't raise an exception if the server does the same136NT�rJrKr6c�H�XlU=(d. [R"[RR5Ul[
UR137[R5(d+[S[UR1385R35eX lX@lg)Nz7ssl_context must be an instance of ssl.SSLContext, not )
�connectablerOrSrPrRrKrpr�	TypeErrorrWr:rJr6)rsr�rJrKr6s     rB�__init__�TLSConnectable.__init__�s���'��'2�(139�c�6P�6P��K�K�#�#�7140����$�*�*�C�N�N�;�;��I���(�(�)�2�2�3�5��
�!�
�#6� rAc��# �URR5IShv�Nn[RUURUR141URS9IShv�N$NAN![a [U5IShv�N ef=f7f)Nr�)	r��connectrrarJrKr6r�r)rsr�s  rBr��TLSConnectable.connect�s�����'�'�/�/�1�1��		�"������� �,�,�$(�$<�$<�	(���
�2����	�#�F�+�+�+��	�sD�B	�A"�B	�7A&�A$�A&�!B	�$A&�&B�>B�?B�B	)r�rJrKr6)142r�rrJr*rKr�r6r1r�r�)r�r)	r:r;r<r=r>r�r#r�r@r9rArBrrys[��	� $�-1�$(�
7�-�7��	7�143+�7�"�
7�144�7�(���rAr)3�145__future__r�__all__r�r�rO�sys�collections.abcrr	�dataclassesr146�	functoolsrr�typingr
rrr�rrrrr�_core._typedattrrr�abcrrrrrr�version_infor r!�typing_extensionsr#r$r%�tupler7r&r?r'rrrrr9rArB�<module>r�s ��"����	�147�148�-�!���*�*���B������w��+�+�6����w���*��:����149�#���5��c��?�C�/�0���0��G�S�L�)��)�)�)�$�)�8�e��K150�151�K152��K153�\�e��U154�(�9�%�U155��U156�p,�*�,rA
codekingpro/portable-devtools · Team Ai