Add client.friendlyRemoteAddress() for 'clean' remote IP

This commit is contained in:
Bryan Ashby
2022-06-04 17:39:48 -06:00
parent 0b11e629a6
commit 1ba866f2ca
4 changed files with 8 additions and 2 deletions

View File

@@ -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
///////////////////////////////////////////////////////////////////////////////