mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: allow rate limit override
This commit is contained in:
1 parent
a70c55e585
commit
688ccf811b
2 files changed
+4
-3
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.3.13",
|
"version": "3.3.14",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
"minio": "7.0.25",
|
"minio": "7.0.25",
|
||||||
"moment-timezone": "^0.5.34",
|
"moment-timezone": "^0.5.34",
|
||||||
"mongodb": "^3.7.3",
|
"mongodb": "^3.7.3",
|
||||||
"nanoid": "^3.1.30",
|
"nanoid": "^3.2.0",
|
||||||
"nodemailer": "^6.7.2",
|
"nodemailer": "^6.7.2",
|
||||||
"notp": "^2.0.3",
|
"notp": "^2.0.3",
|
||||||
"p-queue": "^7.1.0",
|
"p-queue": "^7.1.0",
|
||||||
|
|||||||
@@ -314,8 +314,9 @@ export class HandlerCommon {
|
|||||||
|
|
||||||
async limitRate(op: string, periodSecs: number, maxOperations: number) {
|
async limitRate(op: string, periodSecs: number, maxOperations: number) {
|
||||||
if (ignoredLimit.includes(op)) return;
|
if (ignoredLimit.includes(op)) return;
|
||||||
// TODO: support limit override
|
|
||||||
if (this.user && this.user.hasPriv(PRIV.PRIV_UNLIMITED_ACCESS)) return;
|
if (this.user && this.user.hasPriv(PRIV.PRIV_UNLIMITED_ACCESS)) return;
|
||||||
|
const overrideLimit = system.get(`limit.${op}`);
|
||||||
|
if (overrideLimit) maxOperations = overrideLimit;
|
||||||
await opcount.inc(op, this.request.ip, periodSecs, maxOperations);
|
await opcount.inc(op, this.request.ip, periodSecs, maxOperations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user