✏️ fix RateLimit onlyIp typo
This commit is contained in:
parent
c977f4ad54
commit
bec70800df
@ -86,7 +86,7 @@ export class FosscordServer extends Server {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.app = api;
|
this.app = api;
|
||||||
api.use(RateLimit({ bucket: "global", count: 10, window: 5, bot: 250 }));
|
api.use(RateLimit({ bucket: "global", count: 10, window: 5, bot: 250 }));
|
||||||
api.use(RateLimit({ bucket: "error", count: 5, error: true, window: 5, bot: 15, onylIp: true }));
|
api.use(RateLimit({ bucket: "error", count: 5, error: true, window: 5, bot: 15, onlyIp: true }));
|
||||||
api.use("/guilds/:id", RateLimit({ count: 5, window: 5 }));
|
api.use("/guilds/:id", RateLimit({ count: 5, window: 5 }));
|
||||||
api.use("/webhooks/:id", RateLimit({ count: 5, window: 5 }));
|
api.use("/webhooks/:id", RateLimit({ count: 5, window: 5 }));
|
||||||
api.use("/channels/:id", RateLimit({ count: 5, window: 5 }));
|
api.use("/channels/:id", RateLimit({ count: 5, window: 5 }));
|
||||||
|
@ -42,14 +42,14 @@ export default function RateLimit(opts: {
|
|||||||
MODIFY?: number;
|
MODIFY?: number;
|
||||||
error?: boolean;
|
error?: boolean;
|
||||||
success?: boolean;
|
success?: boolean;
|
||||||
onylIp?: boolean;
|
onlyIp?: boolean;
|
||||||
}): any {
|
}): any {
|
||||||
Cache.init(); // will only initalize it once
|
Cache.init(); // will only initalize it once
|
||||||
|
|
||||||
return async (req: Request, res: Response, next: NextFunction): Promise<any> => {
|
return async (req: Request, res: Response, next: NextFunction): Promise<any> => {
|
||||||
const bucket_id = opts.bucket || req.originalUrl.replace(API_PREFIX_TRAILING_SLASH, "");
|
const bucket_id = opts.bucket || req.originalUrl.replace(API_PREFIX_TRAILING_SLASH, "");
|
||||||
var user_id = getIpAdress(req);
|
var user_id = getIpAdress(req);
|
||||||
if (!opts.onylIp && req.user_id) user_id = req.user_id;
|
if (!opts.onlyIp && req.user_id) user_id = req.user_id;
|
||||||
|
|
||||||
var max_hits = opts.count;
|
var max_hits = opts.count;
|
||||||
if (opts.bot && req.user_bot) max_hits = opts.bot;
|
if (opts.bot && req.user_bot) max_hits = opts.bot;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user