mirror of
https://github.com/janoside/btc-rpc-explorer.git
synced 2026-08-13 12:33:13 +02:00
trying to debug rate-limiting on demo site
This commit is contained in:
parent
209b2c2f07
commit
9bab4a3669
2 changed files with 24 additions and 2 deletions
3
app.js
3
app.js
|
|
@ -267,7 +267,8 @@ if (rateLimitWindowMinutes == -1) {
|
|||
return false;
|
||||
},
|
||||
handler: function (req, res, next) {
|
||||
debugErrorLog(`Rate-limiting request: ip=${req.ip}, req=${req.originalUrl}`)
|
||||
debugErrorLog(`Rate-limiting request: req=${JSON.stringify(utils.expressRequestToJson(req))}`);
|
||||
|
||||
res.status(429).json({
|
||||
message: "Too many requests, please try again later.",
|
||||
});
|
||||
|
|
|
|||
23
app/utils.js
23
app/utils.js
|
|
@ -1373,6 +1373,26 @@ function bip32Addresses(extPubkey, addressType, account, limit=10, offset=0) {
|
|||
return addresses;
|
||||
}
|
||||
|
||||
function expressRequestToJson(req) {
|
||||
return {
|
||||
method: req.method,
|
||||
url: req.url,
|
||||
headers: req.headers,
|
||||
query: req.query,
|
||||
params: req.params,
|
||||
body: req.body,
|
||||
cookies: req.cookies,
|
||||
signedCookies: req.signedCookies,
|
||||
ip: req.ip,
|
||||
ips: req.ips,
|
||||
protocol: req.protocol,
|
||||
secure: req.secure,
|
||||
originalUrl: req.originalUrl,
|
||||
hostname: req.hostname,
|
||||
baseUrl: req.baseUrl,
|
||||
};
|
||||
}
|
||||
|
||||
function difficultyAdjustmentEstimates(eraStartBlockHeader, currentBlockHeader) {
|
||||
let difficultyPeriod = parseInt(Math.floor(currentBlockHeader.height / coinConfig.difficultyAdjustmentBlockCount));
|
||||
let blocksUntilDifficultyAdjustment = ((difficultyPeriod + 1) * coinConfig.difficultyAdjustmentBlockCount) - currentBlockHeader.height;
|
||||
|
|
@ -1671,5 +1691,6 @@ module.exports = {
|
|||
awaitPromises: awaitPromises,
|
||||
perfLogNewItem: perfLogNewItem,
|
||||
perfLog: perfLog,
|
||||
fileCache: fileCache
|
||||
fileCache: fileCache,
|
||||
expressRequestToJson: expressRequestToJson
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue