update time-series and add trust proxy setting for rate limiting

This commit is contained in:
Dave Horton
2022-09-16 13:21:10 +02:00
parent ace9e6a4fc
commit 0a01755a21
4 changed files with 20 additions and 9 deletions

11
app.js
View File

@@ -108,6 +108,17 @@ const limiter = rateLimit({
legacyHeaders: false, // Disable the `X-RateLimit-*` headers
});
if (process.env.JAMBONES_TRUST_PROXY) {
const proxyCount = parseInt(process.env.JAMBONES_TRUST_PROXY);
if (!isNaN(proxyCount) && proxyCount > 0) {
logger.info(`setting trust proxy to ${proxyCount} and mounting endpoint /ip`);
app.set('trust proxy', proxyCount);
app.get('/ip', (req, res) => {
logger.info({headers: req.headers}, 'received GET /ip');
res.send(req.ip);
});
}
}
app.use(limiter);
app.use(helmet());
app.use(helmet.hidePoweredBy());

View File

@@ -126,7 +126,7 @@ const createTestAlerts = async(writeAlerts, AlertType, account_sid) => {
data.push({timestamp, account_sid, alert_type: AlertType.CARRIER_NOT_PROVISIONED});
break;
case 4:
data.push({timestamp, account_sid, alert_type: AlertType.CALL_LIMIT, count: 50});
data.push({timestamp, account_sid, alert_type: AlertType.ACCOUNT_CALL_LIMIT, count: 50});
break;
default:
break;

14
package-lock.json generated
View File

@@ -13,7 +13,7 @@
"@google-cloud/text-to-speech": "^3.4.0",
"@jambonz/db-helpers": "^0.6.18",
"@jambonz/realtimedb-helpers": "^0.4.29",
"@jambonz/time-series": "^0.2.0",
"@jambonz/time-series": "^0.2.1",
"argon2-ffi": "^2.0.0",
"aws-sdk": "^2.1152.0",
"bent": "^7.3.12",
@@ -865,9 +865,9 @@
}
},
"node_modules/@jambonz/time-series": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.0.tgz",
"integrity": "sha512-yuZKZjSU0txB0YDHYuTF9JU5alysD33QbpkI+XxLiWD6Dn0RbGcO1LSDolCP94jDFxqPh3aJbI0/wDsTBYkpaA==",
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.1.tgz",
"integrity": "sha512-uAoeZ3ibS7kEOGdT+vaY8BB8hOV4q38eEaF+d5OvLQaHCrPonNiwB8tWhhXDwtYdDompfqVRUy/plNA9fyS7Vw==",
"dependencies": {
"debug": "^4.3.1",
"influx": "^5.9.3"
@@ -7120,9 +7120,9 @@
}
},
"@jambonz/time-series": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.0.tgz",
"integrity": "sha512-yuZKZjSU0txB0YDHYuTF9JU5alysD33QbpkI+XxLiWD6Dn0RbGcO1LSDolCP94jDFxqPh3aJbI0/wDsTBYkpaA==",
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.1.tgz",
"integrity": "sha512-uAoeZ3ibS7kEOGdT+vaY8BB8hOV4q38eEaF+d5OvLQaHCrPonNiwB8tWhhXDwtYdDompfqVRUy/plNA9fyS7Vw==",
"requires": {
"debug": "^4.3.1",
"influx": "^5.9.3"

View File

@@ -22,7 +22,7 @@
"@google-cloud/text-to-speech": "^3.4.0",
"@jambonz/db-helpers": "^0.6.18",
"@jambonz/realtimedb-helpers": "^0.4.29",
"@jambonz/time-series": "^0.2.0",
"@jambonz/time-series": "^0.2.1",
"argon2-ffi": "^2.0.0",
"aws-sdk": "^2.1152.0",
"bent": "^7.3.12",