mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-08 20:47:02 +03:00
Only call user counter some of the time
This commit is contained in:
@@ -65,6 +65,7 @@ addDefaults(config, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
userCounterURL: null,
|
userCounterURL: null,
|
||||||
|
userCounterRatio: 10,
|
||||||
newLeafURLs: null,
|
newLeafURLs: null,
|
||||||
maxRewardTimePerSegmentInSeconds: 600,
|
maxRewardTimePerSegmentInSeconds: 600,
|
||||||
poiMinimumStartTime: 2,
|
poiMinimumStartTime: 2,
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import { NextFunction, Request, Response } from "express";
|
|||||||
|
|
||||||
export function userCounter(req: Request, res: Response, next: NextFunction): void {
|
export function userCounter(req: Request, res: Response, next: NextFunction): void {
|
||||||
if (req.method !== "OPTIONS") {
|
if (req.method !== "OPTIONS") {
|
||||||
axios.post(`${config.userCounterURL}/api/v1/addIP?hashedIP=${getIP(req)}`)
|
if (Math.random() < 1 / config.userCounterRatio) {
|
||||||
.catch(() => Logger.debug(`Failing to connect to user counter at: ${config.userCounterURL}`));
|
axios.post(`${config.userCounterURL}/api/v1/addIP?hashedIP=${getIP(req)}`)
|
||||||
|
.catch(() => Logger.debug(`Failing to connect to user counter at: ${config.userCounterURL}`));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export interface SBSConfig {
|
|||||||
minReputationToSubmitChapter: number;
|
minReputationToSubmitChapter: number;
|
||||||
minReputationToSubmitFiller: number;
|
minReputationToSubmitFiller: number;
|
||||||
userCounterURL?: string;
|
userCounterURL?: string;
|
||||||
|
userCounterRatio: number;
|
||||||
proxySubmission?: string;
|
proxySubmission?: string;
|
||||||
behindProxy: string | boolean;
|
behindProxy: string | boolean;
|
||||||
db: string;
|
db: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user