Merge branch 'qa' into invalidrequest-fix

This commit is contained in:
eonwarped 2023-05-15 17:07:44 -04:00 committed by GitHub
commit c513e9dbe9
Signed by untrusted user: github
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 10 deletions

14
package-lock.json generated
View File

@ -20,7 +20,7 @@
"dotenv": "^6.2.0",
"express": "^4.18.2",
"fs-extra": "^6.0.1",
"jayson": "^4.0.0",
"jayson": "^4.1.0",
"js-base64": "^2.6.4",
"line-by-line": "^0.1.6",
"loglevel": "^1.8.0",
@ -2294,9 +2294,9 @@
}
},
"node_modules/jayson": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jayson/-/jayson-4.0.0.tgz",
"integrity": "sha512-v2RNpDCMu45fnLzSk47vx7I+QUaOsox6f5X0CUlabAFwxoP+8MfAY0NQRFwOEYXIxm8Ih5y6OaEa5KYiQMkyAA==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.0.tgz",
"integrity": "sha512-R6JlbyLN53Mjku329XoRT2zJAE6ZgOQ8f91ucYdMCD4nkGCF9kZSrcGXpHIU4jeKj58zUZke2p+cdQchU7Ly7A==",
"dependencies": {
"@types/connect": "^3.4.33",
"@types/node": "^12.12.54",
@ -6357,9 +6357,9 @@
"requires": {}
},
"jayson": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jayson/-/jayson-4.0.0.tgz",
"integrity": "sha512-v2RNpDCMu45fnLzSk47vx7I+QUaOsox6f5X0CUlabAFwxoP+8MfAY0NQRFwOEYXIxm8Ih5y6OaEa5KYiQMkyAA==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.0.tgz",
"integrity": "sha512-R6JlbyLN53Mjku329XoRT2zJAE6ZgOQ8f91ucYdMCD4nkGCF9kZSrcGXpHIU4jeKj58zUZke2p+cdQchU7Ly7A==",
"requires": {
"@types/connect": "^3.4.33",
"@types/node": "^12.12.54",

View File

@ -48,7 +48,7 @@
"dotenv": "^6.2.0",
"express": "^4.18.2",
"fs-extra": "^6.0.1",
"jayson": "^4.0.0",
"jayson": "^4.1.0",
"js-base64": "^2.6.4",
"line-by-line": "^0.1.6",
"loglevel": "^1.8.0",

View File

@ -20,7 +20,12 @@ let server = null;
let database = null;
const requestLogger = function (req, _, next) {
console.log(`Incoming request from ${req.headers['cf-connecting-ip'] || req.headers['x-forwarded-for'] || req.socket.remoteAddress} - ${JSON.stringify(req.body)}`);
let truncatedBody = req.body;
if (Array.isArray(req.body) && req.body.length > 10) {
console.log(`Incoming batch request truncated to length 10 from ${req.body.length}`);
truncatedBody = req.body.slice(0, 10);
}
console.log(`Incoming request from ${req.headers['cf-connecting-ip'] || req.headers['x-forwarded-for'] || req.socket.remoteAddress} - ${JSON.stringify(truncatedBody)}`);
next();
}

View File

@ -503,7 +503,7 @@ const init = async (conf, callback) => {
serverP2P.use(bodyParser.json());
serverP2P.set('trust proxy', true);
serverP2P.set('trust proxy', 'loopback');
serverP2P.post('/p2p', jayson.server(p2p()).middleware(), { maxBatchLength: 0 }); // Batch is disabled for P2P as it is not used by the P2P layer at all right now. If in the future requests are batched, this should be updated
serverP2P.post('/p2p', jayson.server(p2p(), { maxBatchLength: 0 }).middleware()); // Batch is disabled for P2P as it is not used by the P2P layer at all right now. If in the future requests are batched, this should be updated
serverP2P.use((err, _req, res, _next) => {
console.error(err);
res.status(500).json({ error: 'Error processing requests' });