zeddemore-logger 2.2.6 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ip_address.js +10 -0
- package/lib/request.js +3 -4
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
|
|
3
|
+
function parseIpAddress(ipAddress) {
|
|
4
|
+
const ipChain = (_.isString(ipAddress) && !!ipAddress.trim().length) ? ipAddress.split(',').map((ip) => ip.trim()) : [ ];
|
|
5
|
+
return !!ipChain.length ? ipChain[ 0 ] : null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
parseIpAddress,
|
|
10
|
+
};
|
package/lib/request.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
|
|
5
5
|
const enums = require('./enums');
|
|
6
|
+
const { parseIpAddress } = require('./ip_address');
|
|
6
7
|
|
|
7
8
|
const { httpRequestHeaders: rqh } = enums;
|
|
8
9
|
|
|
@@ -50,10 +51,8 @@ function parseRequestAcceptLanguage(req) {
|
|
|
50
51
|
function parseRequestIpAddress(req) {
|
|
51
52
|
const LOCALHOST_IPS = [ '127.0.0.1', '::1' ];
|
|
52
53
|
const body = req.body || { };
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const ipAddress = body.ipAddress || xForwardedForClient || req.socket.remoteAddress;
|
|
56
|
-
return LOCALHOST_IPS.includes(ipAddress) ? 'localhost' : ipAddress;
|
|
54
|
+
const requestIpAddress = parseIpAddress(body.ipAddress) || parseIpAddress(req.get(rqh.FORWARDED_FOR)) || parseIpAddress(req.socket.remoteAddress);
|
|
55
|
+
return LOCALHOST_IPS.includes(requestIpAddress) ? 'localhost' : requestIpAddress;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
function parseRequestUserAgent(req) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zeddemore-logger",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8",
|
|
4
4
|
"description": "Node.js Express logger using Morgan and Winston for thread and caller info tracking",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"morgan": "^1.10.1",
|
|
28
28
|
"nodemailer": "^8.0.5",
|
|
29
29
|
"object-sizeof": "^2.6.5",
|
|
30
|
-
"uuid": "^
|
|
30
|
+
"uuid": "^11.1.1",
|
|
31
31
|
"winston": "^3.17.0",
|
|
32
32
|
"winston-transport": "^4.9.0"
|
|
33
33
|
}
|