mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-33506 Show original IP in the "aborted" message.
Add "real ip:<ip_or_localhost>" part to the aborted message Only for proxy-protocoled connection, so it does not not to cause confusion to normal users.
This commit is contained in:
@ -4773,11 +4773,29 @@ public:
|
||||
{
|
||||
if (global_system_variables.log_warnings > threshold)
|
||||
{
|
||||
char real_ip_str[64];
|
||||
real_ip_str[0]= 0;
|
||||
|
||||
/* For proxied connections, add the real IP to the warning message */
|
||||
if (net.using_proxy_protocol && net.vio)
|
||||
{
|
||||
if(net.vio->localhost)
|
||||
snprintf(real_ip_str, sizeof(real_ip_str), " real ip: 'localhost'");
|
||||
else
|
||||
{
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
if (!vio_getnameinfo((sockaddr *)&(net.vio->remote), buf,
|
||||
sizeof(buf),NULL, 0, NI_NUMERICHOST))
|
||||
{
|
||||
snprintf(real_ip_str, sizeof(real_ip_str), " real ip: '%s'",buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
Security_context *sctx= &main_security_ctx;
|
||||
sql_print_warning(ER_THD(this, ER_NEW_ABORTING_CONNECTION),
|
||||
thread_id, (db.str ? db.str : "unconnected"),
|
||||
sctx->user ? sctx->user : "unauthenticated",
|
||||
sctx->host_or_ip, reason);
|
||||
sctx->host_or_ip, real_ip_str, reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user