Spaces:
Paused
Paused
File size: 984 Bytes
fb2754a ce9e053 fb2754a ce9e053 fb2754a ce9e053 fb2754a ce9e053 fb2754a ce9e053 fb2754a ce9e053 fb2754a ce9e053 fb2754a ce9e053 fb2754a ce9e053 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | // src/proxy.js — Manual proxy support (no external fetch)
// HF Spaces Secrets-এ PROXY_LIST দাও: "ip1:port1,ip2:port2"
let proxyList = process.env.PROXY_LIST
? process.env.PROXY_LIST.split(",").map((p) => p.trim()).filter(Boolean)
: [];
let currentIndex = 0;
// Round-robin
function getNextProxy() {
if (!proxyList.length) return null;
const proxy = `http://${proxyList[currentIndex % proxyList.length]}`;
currentIndex++;
return proxy;
}
function removeCurrentProxy() {
if (!proxyList.length) return;
const idx = (currentIndex - 1 + proxyList.length) % proxyList.length;
proxyList.splice(idx, 1);
console.log(`🗑️ Proxy removed. Remaining: ${proxyList.length}`);
}
function getStats() {
return {
total: proxyList.length,
active: currentIndex % Math.max(proxyList.length, 1),
};
}
// No-op — external fetch নেই
async function fetchProxies() {}
module.exports = { fetchProxies, getNextProxy, removeCurrentProxy, getStats };
|