refactor: update MITM bypass logic and enhance combo name validation

This commit is contained in:
decolua
2026-03-19 22:47:32 +07:00
parent a0500dfc85
commit f1c53a319e
6 changed files with 54 additions and 62 deletions
+6 -3
View File
@@ -63,14 +63,17 @@ try {
// ── Helpers ───────────────────────────────────────────────────
const cachedTargetIPs = {};
const CACHE_TTL_MS = 5 * 60 * 1000;
async function resolveTargetIP(hostname) {
if (cachedTargetIPs[hostname]) return cachedTargetIPs[hostname];
const cached = cachedTargetIPs[hostname];
if (cached && Date.now() - cached.ts < CACHE_TTL_MS) return cached.ip;
const resolver = new dns.Resolver();
resolver.setServers(["8.8.8.8"]);
const resolve4 = promisify(resolver.resolve4.bind(resolver));
const addresses = await resolve4(hostname);
cachedTargetIPs[hostname] = addresses[0];
return cachedTargetIPs[hostname];
cachedTargetIPs[hostname] = { ip: addresses[0], ts: Date.now() };
return cachedTargetIPs[hostname].ip;
}
function collectBodyRaw(req) {