
    g1v                        d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	 ddl
mZmZmZmZmZmZ 	 ddlZej        ej        ej        ej        dZ eed          oej        Zn# e$ r dZdZY nw xY wd	d
lmZmZmZmZm Z m!Z!m"Z" dZ#dZ$dZ%dZ&de'de(fdZ) G d de          Z* G d de*          Z+ G d de+          Z, G d de          Z- G d de-          Z. G d de-          Z/dS )zGModule implementing low-level socket communication with MySQL servers.
    N)ABCabstractmethod)deque)AnyDequeListOptionalTupleUnion)TLSv1TLSv1.1TLSv1.2TLSv1.3HAS_TLSv1_3F   )ConnectionTimeoutErrorInterfaceErrorNotSupportedErrorOperationalErrorProgrammingErrorReadTimeoutErrorWriteTimeoutError2   i       errreturnc                 R    | j         st          |           nd| j          d| j         S )z`Reformat the IOError error message.

    This function reformats the IOError error message.
    zErrno z: )errnostrstrerror)r   s    c/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/mysql/connector/network.py_strioerrorr#   J   s0    
 9N3s888*N39*N*N*N*NN    c                       e Zd ZdZe	 	 ddej        dededee	         dee	         ddfd	            Z
edej        dedefd
            ZdS )NetworkBrokeraP  Broker class interface.

    The network object is a broker used as a delegate by a socket object. Whenever the
    socket wants to deliver or get packets to or from the MySQL server it needs to rely
    on its network broker (netbroker).

    The netbroker sends `payloads` and receives `packets`.

    A packet is a bytes sequence, it has a header and body (referred to as payload).
    The first `PACKET_HEADER_LENGTH` or `COMPRESSED_PACKET_HEADER_LENGTH`
    (as appropriate) bytes correspond to the `header`, the remaining ones represent the
    `payload`.

    The maximum payload length allowed to be sent per packet to the server is
    `MAX_PAYLOAD_LENGTH`. When  `send` is called with a payload whose length is greater
    than `MAX_PAYLOAD_LENGTH` the netbroker breaks it down into packets, so the caller
    of `send` can provide payloads of arbitrary length.

    Finally, data received by the netbroker comes directly from the server, expect to
    get a packet for each call to `recv`. The received packet contains a header and
    payload, the latter respecting `MAX_PAYLOAD_LENGTH`.
    Nsockaddresspayloadpacket_numbercompressed_packet_numberr   c                     dS )a  Send `payload` to the MySQL server.

        If provided a payload whose length is greater than `MAX_PAYLOAD_LENGTH`, it is
        broken down into packets.

        Args:
            sock: Object holding the socket connection.
            address: Socket's location.
            payload: Packet's body to send.
            packet_number: Sequence id (packet ID) to attach to the header when sending
                           plain packets.
            compressed_packet_number: Same as `packet_number` but used when sending
                                      compressed packets.

        Raises:
            :class:`OperationalError`: If something goes wrong while sending packets to
                                       the MySQL server.
        N )selfr'   r(   r)   r*   r+   s         r"   sendzNetworkBroker.sendj         r$   c                     dS )a)  Get the next available packet from the MySQL server.

        Args:
            sock: Object holding the socket connection.
            address: Socket's location.

        Returns:
            packet: A packet from the MySQL server.

        Raises:
            :class:`OperationalError`: If something goes wrong while receiving packets
                                       from the MySQL server.
            :class:`InterfaceError`: If something goes wrong while receiving packets
                                     from the MySQL server.
        Nr-   )r.   r'   r(   s      r"   recvzNetworkBroker.recv   r0   r$   NN)__name__
__module____qualname____doc__r   socketr    bytesr	   intr/   	bytearrayr2   r-   r$   r"   r&   r&   R   s         .  (,26 m  	
  } #+3- 
   ^6       ^  r$   r&   c                       e Zd ZdZddZddZdej        dededdfd	Z	ddej        de
defdZ	 	 ddej        dededee
         dee
         ddfdZdej        dedefdZdS )NetworkBrokerPlain,Broker class for MySQL socket communication.r   Nc                     d| _         d S N_pktnrr.   s    r"   __init__zNetworkBrokerPlain.__init__   s    r$   c                 *    | j         dz   dz  | _         dS zIncrement packet id.r      NrB   rD   s    r"   _set_next_pktnrz"NetworkBrokerPlain._set_next_pktnr   s    {Q#-r$   r'   r(   pktc                 (   	 |                     |           dS # t          j        t          f$ r}t	          d          |d}~wt
          $ r&}t          d|t          |          f          |d}~wt          $ r}t          d          |d}~ww xY w)z!Write packet to the comm channel.  r   N  r   valuesi  )	sendallr8   timeoutTimeoutErrorr   IOErrorr   r#   AttributeError)r.   r'   r(   rJ   r   s        r"   	_send_pktzNetworkBrokerPlain._send_pkt   s    		8LL- 	9 	9 	9#$///S8 	 	 	"G[-=-=#>    	8 	8 	8"...C7	8s,    BA  B!A..B;BBr   sizec                     t          |          }t          |          }|rC|                    ||          }|dk    r|dk    rt          d          ||d         }||z  }|C|S )z(Read `size` bytes from the comm channel.r   i  rM   N)r;   
memoryview	recv_intor   )r.   r'   rW   rJ   pkt_viewreads         r"   _recv_chunkzNetworkBrokerPlain._recv_chunk   s|    ooc?? 	>>(D11DqyyTAXX$40000HDLD  	 
r$   r)   r*   r+   c           
      X   ||                                   n|| _        t          |          t          k    rd}t	          t          |          t          z            D ]e}|                     ||dt          j        d| j                  z   |||t          z            z              |                                   |t          z  }f||d         }|                     ||t          j        dt          |                    dd         t          j        d| j                  z   |z              dS )zSend payload to the MySQL server.

        If provided a payload whose length is greater than `MAX_PAYLOAD_LENGTH`, it is
        broken down into packets.
        Nr      <B<I   )rI   rC   lenMAX_PAYLOAD_LENGTHrangerV   structpack)r.   r'   r(   r)   r*   r+   offset_s           r"   r/   zNetworkBrokerPlain.send   sA       """"'DK w<<---F3w<<+==>> 
- 
-#k$445fv0B'BBCD   $$&&&,,fgg&GKc'll++AaC0k$,,-	
 	
 	
 	
 	
r$   c                    	 |                      |t                    }t          j        d|dd         dz             d         |d         c}| _        ||                      ||          z   S # t
          j        t          f$ r}t          d|j	                  |d}~wt          $ r&}t          d	|t          |          f
          |d}~ww xY w)z+Receive `one` packet from the MySQL server.rW   ra   r   rb       rL   )r   msgNrN   rO   )r]   PACKET_HEADER_LENGTHrf   unpackrC   r8   rR   rS   r   r!   rT   r   r#   )r.   r'   r(   headerpayload_lenr   s         r"   r2   zNetworkBrokerPlain.recv   s    	%%d1E%FFF dF1Q3K'$9::1=q	 %K D,,T,DDDD- 	J 	J 	J"3<@@@cI 	 	 	"G[-=-=#>  	s$   A)A, ,CBC&!CCr   N)r   r3   )r4   r5   r6   r7   rE   rI   r8   r    r9   rV   r:   r;   r]   r	   r/   r2   r-   r$   r"   r=   r=      s5       66   . . . .8fm 8c 8 8$ 8 8 8 8
 
 
S 
 
 
 
 
" (,26*
 *
m*
 *
 	*

  }*
 #+3-*
 
*
 *
 *
 *
X        r$   r=   c                       e Zd ZdZd fdZedededee         fd            Z	ddZ
d	ej        d
ededdf fdZ	 	 dd	ej        d
ededee         dee         ddf fdZd	ej        dededdf fdZd	ej        d
edef fdZ xZS )NetworkBrokerCompressedr>   r   Nc                 |    t                                                       d| _        t                      | _        d S r@   )superrE   _compressed_pktnrr   _queue_read)r.   	__class__s    r"   rE   z NetworkBrokerCompressed.__init__  s3    !#-2WWr$   r)   pktnrc                    g }t          |           t          k    rd}t          t          |           t          z            D ]R}|                    dt	          j        d|          z   | ||t          z            z              |dz   dz  }|t          z  }S| |d         } |                    t	          j        dt          |                     dd         t	          j        d|          z   | z              |S )	z2Prepare a payload for sending to the MySQL server.r   r_   r`   r   rH   Nra   rb   )rc   rd   re   appendrf   rg   )r)   rz   pktsrh   ri   s        r"   _prepare_packetsz(NetworkBrokerCompressed._prepare_packets  s     w<<---F3w<<+==>> - -#k$../fv0B'BBCD  
 c),,fgg&GKc'll++AaC06;tU3K3KKgU	
 	
 	
 r$   c                 *    | j         dz   dz  | _         dS rG   )rw   rD   s    r"   _set_next_compressed_pktnrz2NetworkBrokerCompressed._set_next_compressed_pktnr   s    "&"81"<!Cr$   r'   r(   rJ   c                 X   t          j        |          }t          j        dt	          |                    dd         t          j        d| j                  z   t          j        dt	          |                    dd         z   |z   }t                                          |||          S )z1Compress packet and write it to the comm channel.ra   r   rb   r`   )zlibcompressrf   rg   rc   rw   rv   rV   )r.   r'   r(   rJ   compressed_pktry   s        r"   rV   z!NetworkBrokerCompressed._send_pkt$  s    s++Kc.11221Q37k$ 6778k$C))!A#./  	 ww  w444r$   r*   r+   c           
         ||                                   n|| _        ||                                  n|| _        t	          d                              |                     || j                            }t          |          t          t          z
  k    rd}t          t          |          t          z            D ]G}|                     |||||t          z                       |                                  |t          z  }H|                     ||||d                    dS t          |          t          k    r|                     |||           dS t                                          ||t          j        dt          |                    dd         t          j        d| j                  z   t          j        dd          dd         z   |z              dS )zSend `payload` as compressed packets to the MySQL server.

        If provided a payload whose length is greater than `MAX_PAYLOAD_LENGTH`, it is
        broken down into packets.
        Nr$   r   ra   rb   r`   )rI   rC   r   rw   r;   joinr~   rc   rd   rn   re   rV   MIN_COMPRESS_LENGTHrv   rf   rg   )
r.   r'   r(   r)   r*   r+   payload_preprh   ri   ry   s
            r"   r/   zNetworkBrokerCompressed.send/  s       """"'DK#+++----%=D" ~~**4+@+@$++V+VWWw<<-0DDDD F 3|,,0BBCC - -'<BT9T0T#U   //111,,NN4,vww*?@@@@@ 7||111tWl;;;;; !!Kc,&7&7881=k$(>??@k$**1Q3/0 ##    r$   compressed_plluncompressed_pllc                    t                                          ||          }|dk    r|n t          t          j        |                    }d}|t          |          k     rdt          j        d|||t          z   dz
           dz             d         }t          |z   t          |          |z
  k    rt                                          |t                    }t          j        d|dd         dz             d         |d         t          j        d|dd         dz             d         	 c}| _
        }t                                          ||          }||dk    r|nt          j        |          z  }| j                            |||t          z   |z                       |t          |z   z  }|t          |          k     bd	S d	S )
z&Handle reading of a compressed packet.rk   r   ra   r   rl   rb   r   r   N)rv   r]   r;   r   
decompressrc   rf   ro   rn   COMPRESSED_PACKET_HEADER_LENGTHrw   rx   r|   )
r.   r'   r   r   r   rJ   rh   pllrp   ry   s
            r"   _recv_compressed_pktz,NetworkBrokerCompressed._recv_compressed_pktl  s    ,,T,GG  1$$ N4?>::;; 	 s3xx-c&6,@#@1#DDEO C $c)CHHv,=== ,,T8W,XX M$qsg(=>>qA1IM$qsg(=>>qA	"*$ "'!4!4T!4!O!O '1,, #N88 ##C:N1NQT1T(T$UVVV*S00F? s3xxr$   c                 f   | j         s	 t                                          |t                    }t	          j        d|dd         dz             d         |d         t	          j        d|dd         dz             d         	 c}| _        }|                     |||           n]# t          j	        t          f$ r}t          d	          |d
}~wt          $ r&}t          d|t          |          f          |d
}~ww xY w| j         sd
S | j                                         }|d         | _        |S )z{Receive `one` or `several` packets from the MySQL server, enqueue them, and
        return the packet at the head.
        rk   ra   r   rb   rl   r   r   rL   rM   NrN   rO   )rx   rv   r]   r   rf   ro   rw   r   r8   rR   rS   r   rT   r   r#   popleftrC   )	r.   r'   r(   rp   r   r   r   rJ   ry   s	           r"   r2   zNetworkBrokerCompressed.recv  sb     	,,T8W,XX M$qsg(=>>qA1IM$qsg(=>>qA	"*$ ))$@PQQQQNL1 < < <&T222;   &S1A1A'B  
  	4&&((!f
s$   BB% %C?;CC?!C::C?rr   r3   )r4   r5   r6   r7   rE   staticmethodr9   r:   r   r~   r   r8   r    rV   r	   r/   r   r;   r2   __classcell__ry   s   @r"   rt   rt      s       665 5 5 5 5 5
 %  U    \2D D D D	5fm 	5c 	5 	5$ 	5 	5 	5 	5 	5 	5  (,26; ;m; ; 	;
  }; #+3-; 
; ; ; ; ; ;z.1M.136.1JM.1	.1 .1 .1 .1 .1 .1`! ! ! ! ! ! ! ! ! ! ! ! !r$   rt   c                      e Zd ZdZd dZd dZd dZd dZd dZd	e	e
         ddfd
ZdededdfdZ	 	 	 	 	 	 	 d!de	e         de	e         de	e         de	e         de	e         de	ee                  de	ee                  defdZ	 	 	 d"dede	e
         de	e
         de	e
         ddf
dZd#de	e
         defdZed d            Zeedefd                        ZdS )$MySQLSocketzMySQL socket communication interface.

    Examples:
        Subclasses: network.MySQLTCPSocket and network.MySQLUnixSocket.
    r   Nc                 V    d| _         d| _        d| _        t                      | _        dS )zsNetwork layer where transactions are made with plain (uncompressed) packets
        is enabled by default.
        N)r'   _connection_timeoutserver_hostr=   
_netbrokerrD   s    r"   rE   zMySQLSocket.__init__  s,    
 .2	26 *.);)=)=r$   c                 ,    t                      | _        dS )zIEnable network layer where transactions are made with compressed packets.N)rt   r   rD   s    r"   switch_to_compressed_modez%MySQLSocket.switch_to_compressed_mode  s    133r$   c                     	 | j                             t          j                   | j                                          dS # t
          t          f$ r Y dS w xY w)z'Shut down the socket before closing it.N)r'   shutdownr8   	SHUT_RDWRcloserU   OSErrorrD   s    r"   r   zMySQLSocket.shutdown  s_    	Iv/000IOO( 	 	 	DD	s   =A AAc                 j    	 | j                                          dS # t          t          f$ r Y dS w xY w)zClose the socket.N)r'   r   rU   r   rD   s    r"   close_connectionzMySQLSocket.close_connection  sF    	IOO( 	 	 	DD	s    22c                 .    |                                   d S N)r   rD   s    r"   __del__zMySQLSocket.__del__  s    r$   rR   c                 Z    || _         | j        r| j                            |           dS dS )zSet the connection timeout.N)r   r'   
settimeout)r.   rR   s     r"   set_connection_timeoutz"MySQLSocket.set_connection_timeout  s:    #* 9 	*I  )))))	* 	*r$   ssl_contexthostc                 :   | j         J | j         j        dk    rt          d          t          t	          d          	 |                    | j         |          | _         dS # t          $ r}t	          d          |d}~wt          j        t          f$ r+}t          d| j
        t          |          f          |d}~wt          j        $ r"}t          t          |                    |d}~wt          $ r"}t          t          |                    |d}~ww xY w)a  Upgrade an existing connection to TLS.

        Args:
            ssl_context (ssl.SSLContext): The SSL Context to be used.
            host (str): Server host name.

        Returns:
            None.

        Raises:
            ProgrammingError: If the transport does not expose the socket instance.
            NotSupportedError: If Python installation has no SSL support.
        Nr   z,SSL is not supported when using Unix sockets&Python installation has no SSL support)server_hostnamerN   rO   )r'   familyr   sslr   wrap_socket	NameErrorSSLErrorrT   r   r(   r#   CertificateErrorr    NotImplementedError)r.   r   r   r   s       r"   switch_to_sslzMySQLSocket.switch_to_ssl  sF    y$$$9q  "#QRRR;#$LMMM	4#//	4/PPDIII 	W 	W 	W#$LMMSVVg& 	 	 	 DL+c2B2B#C   # 	4 	4 	4 S**3" 	4 	4 	4 S**3	4s<    !A# #
D-A==D&B<<DC++D8DDFssl_cassl_certssl_keyssl_verify_certssl_verify_identitytls_versionstls_cipher_suitesc                    d}| j         st          d          t          t          d          |g }|g }	 |r|                    d           |d         }t
          |         }	t          j        |	          }
|dk    rZd	|vr|
xj        t          j        z  c_        d
|vr|
xj        t          j	        z  c_        d|vr|
xj        t          j
        z  c_        nt          j                    }
||
_        |rt          j        |
_        n%|rt          j        |
_        nt          j        |
_        |
                                 |rH	 |
                    |           n1# t&          t          j        f$ r}t          d|           |d}~ww xY w|rI	 |
                    ||           n1# t&          t          j        f$ r}t          d|           |d}~ww xY w|r.|d	k    r(|
                    d                    |                     |
S # t0          $ r}t          d          |d}~wt&          t2          t          j        t          j        f$ r"}t          t7          |                    |d}~ww xY w)a  Build a SSLContext.

        Args:
            ssl_ca: Certificate authority, opptional.
            ssl_cert: SSL certificate, optional.
            ssl_key: Private key, optional.
            ssl_verify_cert: Verify the SSL certificate if `True`.
            ssl_verify_identity: Verify host identity if `True`.
            tls_versions: TLS protocol versions, optional.
            tls_cipher_suites: Set of steps that helps to establish a secure connection.

        Returns:
            ssl_context (ssl.SSLContext): An SSL Context ready be used.

        Raises:
            NotSupportedError: Python installation has no SSL support.
            InterfaceError: Socket undefined or invalid ssl data.
        Ni   rM   r   T)reverser   r   r   r   r   zInvalid CA Certificate: zInvalid Certificate/Key: :)r'   r   r   r   sortTLS_VERSIONS
SSLContextoptionsOP_NO_TLSv1_2OP_NO_TLSv1_1OP_NO_TLSv1create_default_contextcheck_hostnameCERT_REQUIREDverify_modeCERT_OPTIONAL	CERT_NONEload_default_certsload_verify_locationsrT   r   load_cert_chainset_ciphersr   r   r   r   r    )r.   r   r   r   r   r   r   r   tls_versionssl_protocolcontextr   s               r"   build_ssl_contextzMySQLSocket.build_ssl_context  s   8 &*y 	- t,,,,;#$LMMML$ "6	4 7!!$!///*1o+K8.66)++ 443+<< 443+<<l223?: 466%8G" 4&)&7##$ 4&)&7##&)m#&&((( TT11&9999. T T T()IC)I)IJJPSST UU++Hg>>>>. U U U()JS)J)JKKQTTU
 ! A[I%=%=##CHH->$?$?@@@N 	W 	W 	W#$LMMSVV L	
 	4 	4 	4 !S**3	4sl   DH	 E H	 F	1FF		H	 F& %H	 &G<GG4H	 	
I/H##*I/I**I/r)   r*   r+   write_timeoutc                     	 | j         s2| j        +| j                            |rt          |          nd           n# t          $ r
}Y d}~nd}~ww xY w| j                            | j        | j        |||           dS )at  Send `payload` to the MySQL server.

        NOTE: if `payload` is an instance of `bytearray`, then `payload` might be
        changed by this method - `bytearray` is similar to passing a variable by
        reference.

        If you're sure you won't read `payload` after invoking `send()`,
        then you can use `bytearray.` Otherwise, you must use `bytes`.
        N)r*   r+   )r   r'   r   floatr   r   r/   r(   )r.   r)   r*   r+   r   ri   s         r"   r/   zMySQLSocket.sends  s     	,V151F	$$]%TU=%9%9%9PTUUU 	 	 	DDDD	 	IL'%= 	 	
 	
 	
 	
 	
   9< 
AAread_timeoutc                     	 | j         s2| j        +| j                            |rt          |          nd           n# t          $ r
}Y d}~nd}~ww xY w| j                            | j        | j                  S )z.Get packet from the MySQL server comm channel.N)r   r'   r   r   r   r   r2   r(   )r.   r   ri   s      r"   r2   zMySQLSocket.recv  s    	,T151F	$$L%RU<%8%8%8dSSS 	 	 	DDDD	 ##DIt|<<<r   c                     dS )zOpen the socket.Nr-   rD   s    r"   open_connectionzMySQLSocket.open_connection  r0   r$   c                     dS )zGet the location of the socket.Nr-   rD   s    r"   r(   zMySQLSocket.address  r0   r$   rr   )NNNFFNN)NNNr   )r4   r5   r6   r7   rE   r   r   r   r   r	   r:   r   r   r    r   boolr   r   r9   r/   r;   r2   r   r   propertyr(   r-   r$   r"   r   r     sa        > > > >4 4 4 4         *hsm * * * * *"4 "4C "4D "4 "4 "4 "4L !%"&!%*/.3,015`4 `4`4 3-`4 #	`4
 "$`4 &d^`4 tCy)`4 $DI.`4 
`4 `4 `4 `4J (,26'+
 

  }
 #+3-	

  }
 

 
 
 
@
= 
=# 
=) 
= 
= 
= 
=    ^ . . . . ^ X. . .r$   r   c                   f     e Zd ZdZddeddf fdZedefd            ZddZd	e	d
e	ddfdZ
 xZS )MySQLUnixSocketzpMySQL socket class using UNIX sockets.

    Opens a connection through the UNIX socket of the MySQL Server.
    /tmp/mysql.sockunix_socketr   Nc                 d    t                                                       || _        || _        d S r   )rv   rE   r   _address)r.   r   ry   s     r"   rE   zMySQLUnixSocket.__init__  s,     +(r$   c                     | j         S r   r   rD   s    r"   r(   zMySQLUnixSocket.address  
    }r$   c                 "   	 t          j         t           j        t           j                  | _        | j                            | j                   | j                            | j                   d S # t           j        t          f$ r+}t          d| j        t          |          f          |d }~wt          $ r+}t          d| j        t          |          f          |d }~wt          $ r"}t          t!          |                    |d }~ww xY w)N  rO   )r8   AF_UNIXSOCK_STREAMr'   r   r   connectr   rR   rS   r   r(   r#   rT   r   	Exceptionr    )r.   r   s     r"   r   zMySQLUnixSocket.open_connection  s-   	4" DI
 I  !9:::Id./////- 	 	 	(L$$     	 	 	 DL+c2B2B#C    	4 	4 	4 S**3	4s0   A,A0 0D&B,,D9&CD,D		Dargskwargsc                 :    t          j        dt                     dS )zSwitch the socket to use SSL.z2SSL is disabled when using unix socket connectionsN)warningswarnWarning)r.   r   r   s      r"   r   zMySQLUnixSocket.switch_to_ssl  s(     	@	
 	
 	
 	
 	
r$   )r   rr   )r4   r5   r6   r7   r    rE   r   r(   r   r   r   r   r   s   @r"   r   r     s         
) )C ) ) ) ) ) ) )
     X4 4 4 40

$'
	
 
 
 
 
 
 
 
r$   r   c            	       `     e Zd ZdZ	 	 	 ddedededd	f fd
Zedefd            Z	ddZ
 xZS )MySQLTCPSocketzYMySQL socket class using TCP/IP.

    Opens a TCP/IP connection to the MySQL Server.
    	127.0.0.1  Fr   port
force_ipv6r   Nc                     t                                                       || _        || _        || _        d| _        | d| | _        d S )Nr   r   )rv   rE   r   server_portr   _familyr   )r.   r   r   r   ry   s       r"   rE   zMySQLTCPSocket.__init__  sR     	 $ $ * $--t--r$   c                     | j         S r   r   rD   s    r"   r(   zMySQLTCPSocket.address  r   r$   c           	      
   d}	 t          j        | j        | j        dt           j        t           j                  }|D ]=}| j        r|d         t           j        k    r|} n|d         t           j        k    r|} n>| j        r|d         t          d| j                   |d         |d         }n># t          $ r1}t          d| j        | j        t          |          f          |d}~ww xY w|\  | _        }}}}	 t          j         | j        ||          | _        | j                            | j                   | j                            |           dS # t           j        t$          f$ r1}t'          d| j        | j        t          |          f          |d}~wt          $ r1}t          d| j        | j        t          |          f          |d}~wt(          $ r"}t+          t-          |                    |d}~ww xY w)z/Open the TCP/IP connection to the MySQL server.)NNNNNr   NzNo IPv6 address found for i  rO   r   )r8   getaddrinfor   r   r   SOL_TCPr   AF_INET6AF_INETr   rT   r#   r   r'   r   r   r   rR   rS   r   r   r   r    )	r.   addrinfo	addrinfosinfor   socktypeprotori   sockaddrs	            r"   r   zMySQLTCPSocket.open_connection  st    + 		*  " I "  ? tAw&/'A'A#HE7fn,,#HE -  V8A;#6$%T$BR%T%TUUU{"$Q< 	 	 	 ($*:K<L<LM   	 8@4x8	6dlHeDDDII  !9:::Ih'''''- 	 	 	($$$$     	 	 	 $$$$     	6 	6 	6"3s88,,#5	6sI   B,B1 1
C,;,C''C,=AE H.,FH',GH G==H)r   r   Frr   )r4   r5   r6   r7   r    r:   r   rE   r   r(   r   r   r   s   @r"   r   r     s            	. .. . 	.
 
. . . . . .     XB6 B6 B6 B6 B6 B6 B6 B6r$   r   )0r7   r8   rf   r   r   abcr   r   collectionsr   typingr   r   r   r	   r
   r   r   PROTOCOL_TLSv1PROTOCOL_TLSv1_1PROTOCOL_TLSv1_2PROTOCOL_TLSr   hasattrr   TLS_V1_3_SUPPORTEDImportErrorerrorsr   r   r   r   r   r   r   r   rd   rn   r   rT   r    r#   r&   r=   rt   r   r   r   r-   r$   r"   <module>r     s  : 
     # # # # # # # #       ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;JJJ #''#	 L !m44H   
CCC
                     "# OW O O O O OD D D D DC D D DNb b b b b b b bJ    0   Df. f. f. f. f.# f. f. f.R.
 .
 .
 .
 .
k .
 .
 .
bY6 Y6 Y6 Y6 Y6[ Y6 Y6 Y6 Y6 Y6s   2A% %	A10A1