diff --git a/core/client.js b/core/client.js index 9e0e2f82..fcc9bcdf 100644 --- a/core/client.js +++ b/core/client.js @@ -575,6 +575,11 @@ Client.prototype.isLocal = function() { return [ '127.0.0.1', '::ffff:127.0.0.1' ].includes(this.remoteAddress); }; +Client.prototype.friendlyRemoteAddress = function() { + // convert any :ffff: IPv4's to 32bit version + return this.remoteAddress.replace(/^::ffff:/, '') +} + /////////////////////////////////////////////////////////////////////////////// // Default error handlers /////////////////////////////////////////////////////////////////////////////// diff --git a/core/client_connections.js b/core/client_connections.js index 1f24a584..ae1de622 100644 --- a/core/client_connections.js +++ b/core/client_connections.js @@ -113,6 +113,7 @@ function addNewClient(client, clientSock) { const connInfo = { remoteAddress : remoteAddress, + freiendlyRemoteAddress: client.friendlyRemoteAddress(), serverName : client.session.serverName, isSecure : client.session.isSecure, }; diff --git a/core/predefined_mci.js b/core/predefined_mci.js index 78938443..690b4029 100644 --- a/core/predefined_mci.js +++ b/core/predefined_mci.js @@ -121,7 +121,7 @@ const PREDEFINED_MCI_GENERATORS = { UD : function themeId(client) { return userStatAsString(client, UserProps.ThemeId, ''); }, UC : function loginCount(client) { return userStatAsCountString(client, UserProps.LoginCount, 0); }, ND : function connectedNode(client) { return client.node.toString(); }, - IP : function clientIpAddress(client) { return client.remoteAddress.replace(/^::ffff:/, ''); }, // convert any :ffff: IPv4's to 32bit version + IP : function clientIpAddress(client) { return client.remoteAddress.friendlyRemoteAddress() }, ST : function serverName(client) { return client.session.serverName; }, FN : function activeFileBaseFilterName(client) { const activeFilter = FileBaseFilters.getActiveFilter(client); diff --git a/core/user_login.js b/core/user_login.js index a5e2ece3..2c327442 100644 --- a/core/user_login.js +++ b/core/user_login.js @@ -238,6 +238,6 @@ function transformLoginError(err, client, username) { err = Errors.BadLogin('To many failed login attempts', ErrorReasons.TooMany); } - client.log.warn( { username, ip : client.remoteAddress, reason : err.message }, `Failed login attempt for user "${username}", ${client.remoteAddress}`); + client.log.warn( { username, ip : client.remoteAddress, reason : err.message }, `Failed login attempt for user "${username}", ${client.friendlyRemoteAddress()}`); return err; } \ No newline at end of file