Add client.friendlyRemoteAddress() for 'clean' remote IP
This commit is contained in:
parent
0b11e629a6
commit
1ba866f2ca
|
@ -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
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -113,6 +113,7 @@ function addNewClient(client, clientSock) {
|
|||
|
||||
const connInfo = {
|
||||
remoteAddress : remoteAddress,
|
||||
freiendlyRemoteAddress: client.friendlyRemoteAddress(),
|
||||
serverName : client.session.serverName,
|
||||
isSecure : client.session.isSecure,
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue