Fix cooldown value

This commit is contained in:
Simon Warta
2022-07-12 10:46:21 +02:00
parent 09f3e0ab0b
commit 86d9edb46a
3 changed files with 8 additions and 2 deletions
+3 -2
View File
@@ -67,10 +67,11 @@ export class Webserver {
const entry = this.addressCounter.get(address);
if (entry !== undefined) {
if (entry.getTime() + 24 * 3600 > Date.now()) {
const cooldownMs = constants.cooldown * 3600 * 1000;
if (entry.getTime() + cooldownMs > Date.now()) {
throw new HttpError(
405,
"Too many request from the same address. Blocked to prevent draining. Please wait 24h and try it again!",
`Too many request for the same address. Blocked to prevent draining. Please wait ${constants.cooldown}h and try it again!`,
);
}
}
+1
View File
@@ -17,3 +17,4 @@ export const pathPattern = process.env.FAUCET_PATH_PATTERN || "m/44'/118'/0'/0/a
export const tokenConfig: TokenConfiguration = {
bankTokens: parseBankTokens(process.env.FAUCET_TOKENS || "ucosm, ustake"),
};
export const cooldown = 24; // hours