File: //var/opt/nydus/ops/mysql/connector/__pycache__/protocol.cpython-39.pyc
a
�,�h�� � @ sD d Z ddlmZ ddlZddlZddlmZ ddlmZm Z ddl
mZmZm
Z
mZmZmZmZmZmZ ddlmZ dd lmZmZmZmZmZ dd
lmZ ddlmZm Z m!Z!m"Z" ddl#m#Z# dd
l$m%Z%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 e�rddl1m2Z2 dZ3dZ4dZ5dZ6dZ7dZ8dZ9dZ:G dd� d�Z;dS )z,Implements the MySQL Client/Server protocol.� )�annotationsN)�deque)�Decimal�DecimalException) �
TYPE_CHECKING�Any�Deque�Dict�List�Optional�Sequence�Tuple�Union� )�utils)�PARAMETER_COUNT_AVAILABLE�
ClientFlag� FieldFlag� FieldType� ServerCmd)�MySQLConverter)�
DatabaseError�InterfaceError�ProgrammingError�
get_exception)�logger)�MySQLAuthPlugin�get_auth_plugin)�"MySQLCachingSHA2PasswordAuthPlugin)�BinaryProtocolType�DescriptionType�
EofPacketType�
HandShakeType�OkPacketType�StatsPacketType�
StrOrBytes)�MySQLSocket�
� � � �- i @c @ s� e Zd ZdZeddd�dd��Zeddd�dd��Zeddd�d d
��Zeddd�d
d��Zedddd�dd��Z ed~dddddddddd� dd��Z
edededdddddf
ddddddddddddddd �d!d"��Z
eedefddddd#�d$d%��Zeddd&dd'�d(d)��Zed�dddd+�d,d-��Zeddd.�d/d0��Zedd1d.�d2d3��Zedd4d.�d5d6��Zed�ddd8d9�d:d;��Zdd<d.�d=d>�Zed�ddd@dA�dBdC��Zd�dDdEddFdG�dHdI�Zedd8dJdK�dLdM��Zedd8dNdK�dOdP��Zed�dddRdS�dTdU��ZedddVdW�dXdY��ZeddZd.�d[d\��Zd�d]ddd^d_�d`da�Zd�dDd]dddbdc�ddde�Zeddfd.�dgdh��Zeddidj�dkdl��Z edmdJdj�dndo��Z!edpdJdj�dqdr��Z"eddddds�dtdu��Z#d�ddwdxddyddzddd{� d|d}�Z$dS )��
MySQLProtocolzRImplements MySQL client/server protocol
Create and parses MySQL packets.
�bytes)�pkt�returnc C s | d t kstd��| dd� S )a Parse a MySQL auth more data packet.
Args:
pkt: Packet representing an `auth more data` response.
Returns:
auth_data: Authentication method data (see [1]).
Raises:
InterfaceError: If packet's status tag doesn't
match `protocol.EXCHANGE_FURTHER_STATUS`.
References:
[1]: https://dev.mysql.com/doc/dev/mysql-server/latest/ page_protocol_connection_phase_packets_protocol_auth_more_data.html
� z"Failed parsing AuthMoreData packet� N)�EXCHANGE_FURTHER_STATUSr )r. � r3 �K/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/connector/protocol.py�parse_auth_more_data\ s z"MySQLProtocol.parse_auth_more_datazTuple[str, bytes]c C sV | d t krtd��tj| dd� dd�\} }| rJ| d dkrJ| dd� } |�� | fS ) a| Parse a MySQL auth switch request packet.
Args:
pkt: Packet representing an `auth switch request` response.
Returns:
plugin_name: Name of the client authentication plugin to switch to.
plugin_provided_data: Plugin provided data (see [1]).
Raises:
InterfaceError: If packet's status tag doesn't
match `protocol.AUTH_SWITCH_STATUS`.
References:
[1]: https://dev.mysql.com/doc/dev/mysql-server/ latest/page_protocol_connection_phase_packets_protocol_
auth_switch_request.html
r0 z'Failed parsing AuthSwitchRequest packetr1 N� ��end���r )�AUTH_SWITCH_STATUSr r �read_string�decode)r. �plugin_namer3 r3 r4 �parse_auth_switch_requestr s z'MySQLProtocol.parse_auth_switch_requestc C sF t �| dd� d�\} }|tkr(td��t j| dd�\} }|�� | fS )a� Parse a MySQL auth next factor packet.
Args:
pkt: Packet representing an `auth next factor` response.
Returns:
plugin_name: Name of the client authentication plugin.
plugin_provided_data: Initial authentication data for that
client plugin (see [1]).
Raises:
InterfaceError: If packet's packet type doesn't
match `protocol.MFA_STATUS`.
References:
[1]: https://dev.mysql.com/doc/dev/mysql-server/latest/ page_protocol_connection_phase_packets_protocol_auth_ next_factor_request.html
r0 Nr z.Failed parsing AuthNextFactor packet (invalid)r6 r7 )r �read_int�
MFA_STATUSr r; r<