File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 55---------
66* Let the ` --dsn ` argument accept literal DSNs as well as aliases.
77* Accept ` --character-set ` as an alias for ` --charset ` at the CLI.
8+ * Add SSL/TLS version to ` status ` output.
89
910
1011Bug Fixes
Original file line number Diff line number Diff line change 88from mycli import __version__
99from mycli .packages .special import iocommands
1010from mycli .packages .special .main import ArgType , special_command
11- from mycli .packages .special .utils import format_uptime
11+ from mycli .packages .special .utils import format_uptime , get_ssl_version
1212from mycli .packages .sqlresult import SQLResult
1313
1414logger = logging .getLogger (__name__ )
@@ -126,6 +126,7 @@ def status(cur: Cursor, **_) -> list[SQLResult]:
126126
127127 output .append (("Server version:" , f'{ variables ["version" ]} { variables ["version_comment" ]} ' ))
128128 output .append (("Protocol version:" , variables ["protocol_version" ]))
129+ output .append (('SSL/TLS version:' , get_ssl_version (cur )))
129130
130131 if "unix" in cur .connection .host_info .lower ():
131132 host_info = cur .connection .host_info
Original file line number Diff line number Diff line change 1+ import logging
12import os
23import subprocess
34
5+ from pymysql .cursors import Cursor
6+
7+ logger = logging .getLogger (__name__ )
8+
9+ CACHED_SSL_VERSION : dict [int , str | None ] = {}
10+
411
512def handle_cd_command (arg : str ) -> tuple [bool , str | None ]:
613 """Handles a `cd` shell command by calling python's os.chdir."""
@@ -46,3 +53,21 @@ def format_uptime(uptime_in_seconds: str) -> str:
4653
4754 uptime = " " .join (uptime_values )
4855 return uptime
56+
57+
58+ def get_ssl_version (cur : Cursor ) -> str | None :
59+ if cur .connection .thread_id () in CACHED_SSL_VERSION :
60+ return CACHED_SSL_VERSION [cur .connection .thread_id ()] or None
61+
62+ query = 'SHOW STATUS LIKE "Ssl_version"'
63+ logger .debug (query )
64+ cur .execute (query )
65+
66+ ssl_version = None
67+ if one := cur .fetchone ():
68+ CACHED_SSL_VERSION [cur .connection .thread_id ()] = one [1 ]
69+ ssl_version = one [1 ] or None
70+ else :
71+ CACHED_SSL_VERSION [cur .connection .thread_id ()] = ''
72+
73+ return ssl_version
You can’t perform that action at this time.
0 commit comments