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

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');
};