Handle case where remoteAddress is not yet avail

This commit is contained in:
Bryan Ashby 2022-09-13 13:59:29 -06:00
parent 2a0ae05c45
commit a1188fb90c
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
1 changed files with 4 additions and 0 deletions

View File

@ -598,6 +598,10 @@ Client.prototype.isLocal = function () {
};
Client.prototype.friendlyRemoteAddress = function () {
if (!this.remoteAddress) {
return 'N/A';
}
// convert any :ffff: IPv4's to 32bit version
return this.remoteAddress.replace(/^::ffff:/, '').replace(/^::1$/, 'localhost');
};