feat: добавлено использование хеширования для ключа кеша
All checks were successful
Build and Deploy Gateway / build-and-deploy (push) Successful in 6s
All checks were successful
Build and Deploy Gateway / build-and-deploy (push) Successful in 6s
Refs: None
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import http from "node:http";
|
import http from "node:http";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import crypto from "node:crypto";
|
||||||
import { spawn, spawnSync } from "node:child_process";
|
import { spawn, spawnSync } from "node:child_process";
|
||||||
import { settings } from "./config.js";
|
import { settings } from "./config.js";
|
||||||
import { fetchSubscription } from "./subscription.js";
|
import { fetchSubscription } from "./subscription.js";
|
||||||
@@ -625,7 +626,8 @@ async function handleApi(req, res) {
|
|||||||
return sendJson(res, 400, { success: false, error: "Укажите url" });
|
return sendJson(res, 400, { success: false, error: "Укажите url" });
|
||||||
|
|
||||||
// Кеш — файл рядом с custom-rule-sets.json
|
// Кеш — файл рядом с custom-rule-sets.json
|
||||||
const cacheKey = Buffer.from(url).toString("base64url").slice(0, 48);
|
// Используем crypto hash чтобы избежать коллизий при одинаковом префиксе URL
|
||||||
|
const cacheKey = crypto.createHash("sha1").update(url).digest("hex");
|
||||||
const cacheFile = path.join(
|
const cacheFile = path.join(
|
||||||
settings.dataDir,
|
settings.dataDir,
|
||||||
`ruleset-cache-${cacheKey}.json`,
|
`ruleset-cache-${cacheKey}.json`,
|
||||||
|
|||||||
Reference in New Issue
Block a user