diff --git a/src/config.ts b/src/config.ts index 8fe1ed1..0306ab7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -71,6 +71,7 @@ addDefaults(config, { }, validityCheck: { userAgent: null, + userAgentR: null, }, userCounterURL: null, userCounterRatio: 10, diff --git a/src/routes/postBranding.ts b/src/routes/postBranding.ts index bed298b..5850c4e 100644 --- a/src/routes/postBranding.ts +++ b/src/routes/postBranding.ts @@ -58,7 +58,7 @@ export async function postBranding(req: Request, res: Response) { const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress); const isBanned = await checkBanStatus(hashedUserID, hashedIP); - if (!validSubmittedData(userAgent)) { + if (!validSubmittedData(userAgent, req.headers["user-agent"])) { Logger.warn(`Rejecting submission based on invalid data: ${hashedUserID} ${videoID} ${videoDuration} ${userAgent} ${req.headers["user-agent"]}`); res.status(200).send("OK"); return; diff --git a/src/routes/postSkipSegments.ts b/src/routes/postSkipSegments.ts index ef4d4d9..0b828fd 100644 --- a/src/routes/postSkipSegments.ts +++ b/src/routes/postSkipSegments.ts @@ -509,7 +509,7 @@ export async function postSkipSegments(req: Request, res: Response): Promise)[key]; + if (check === null) { + continue; + } else { + switch (key) { + case "userAgent": + if (!userAgent.match(check)) { + return false; + } + break; + case "userAgentR": + if (!userAgentR.match(new RegExp(check))) { + return false; + } + break; + } + } + } + + return true; } export async function canSubmitGlobal(userID: HashedUserID): Promise {