MCPcopy Create free account
hub / github.com/cmliu/WorkerVless2sub / getRandomProxyByMatch

Function getRandomProxyByMatch

_worker.js:305–325  ·  view source on GitHub ↗
(CC, socks5Data)

Source from the content-addressed store, hash-verified

303}
304
305function getRandomProxyByMatch(CC, socks5Data) {
306 // 将匹配字符串转换为小写
307 const lowerCaseMatch = CC.toLowerCase();
308
309 // 过滤出所有以指定匹配字符串结尾的代理字符串
310 let filteredProxies = socks5Data.filter(proxy => proxy.toLowerCase().endsWith(`#${lowerCaseMatch}`));
311
312 // 如果没有匹配的代理,尝试匹配 "US"
313 if (filteredProxies.length === 0) {
314 filteredProxies = socks5Data.filter(proxy => proxy.toLowerCase().endsWith(`#us`));
315 }
316
317 // 如果还是没有匹配的代理,从整个代理列表中随机选择一个
318 if (filteredProxies.length === 0) {
319 return socks5Data[Math.floor(Math.random() * socks5Data.length)];
320 }
321
322 // 从匹配的代理中随机选择一个并返回
323 const randomProxy = filteredProxies[Math.floor(Math.random() * filteredProxies.length)];
324 return randomProxy;
325}
326
327async function MD5MD5(text) {
328 const encoder = new TextEncoder();

Callers 1

fetchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected