fix: add localnet configuration for Proxychains4 (#547)

This commit is contained in:
samanhappy
2026-01-02 18:42:00 +08:00
committed by GitHub
parent b279a1a62c
commit ef1bc0d305

View File

@@ -84,9 +84,7 @@ const generateProxychainsConfig = (
if (fs.existsSync(proxyConfig.configPath)) { if (fs.existsSync(proxyConfig.configPath)) {
return proxyConfig.configPath; return proxyConfig.configPath;
} }
console.warn( console.warn(`[${serverName}] Custom proxychains config not found: ${proxyConfig.configPath}`);
`[${serverName}] Custom proxychains config not found: ${proxyConfig.configPath}`,
);
return null; return null;
} }
@@ -97,13 +95,19 @@ const generateProxychainsConfig = (
} }
const proxyType = proxyConfig.type || 'socks5'; const proxyType = proxyConfig.type || 'socks5';
const proxyLine = proxyConfig.username && proxyConfig.password const proxyLine =
? `${proxyType} ${proxyConfig.host} ${proxyConfig.port} ${proxyConfig.username} ${proxyConfig.password}` proxyConfig.username && proxyConfig.password
: `${proxyType} ${proxyConfig.host} ${proxyConfig.port}`; ? `${proxyType} ${proxyConfig.host} ${proxyConfig.port} ${proxyConfig.username} ${proxyConfig.password}`
: `${proxyType} ${proxyConfig.host} ${proxyConfig.port}`;
const configContent = `# Proxychains4 configuration for MCP server: ${serverName} const configContent = `# Proxychains4 configuration for MCP server: ${serverName}
# Generated by MCPHub # Generated by MCPHub
localnet 127.0.0.0/255.0.0.0
localnet 10.0.0.0/255.0.0.0
localnet 172.16.0.0/255.240.0.0
localnet 192.168.0.0/255.255.0.0
strict_chain strict_chain
proxy_dns proxy_dns
remote_dns_subnet 224 remote_dns_subnet 224
@@ -824,9 +828,10 @@ export const getServersInfo = async (
// Apply user filtering only when NOT using pagination (pagination already filtered at DAO level) // Apply user filtering only when NOT using pagination (pagination already filtered at DAO level)
// Or when no pagination parameters provided (backward compatibility) // Or when no pagination parameters provided (backward compatibility)
const shouldApplyUserFilter = !isPaginated; const shouldApplyUserFilter = !isPaginated;
const filterServerInfos: ServerInfo[] = shouldApplyUserFilter && dataService.filterData const filterServerInfos: ServerInfo[] =
? dataService.filterData(filteredServerInfos, user) shouldApplyUserFilter && dataService.filterData
: filteredServerInfos; ? dataService.filterData(filteredServerInfos, user)
: filteredServerInfos;
const infos = filterServerInfos const infos = filterServerInfos
.filter((info) => requestedServerNames.has(info.name)) // Only include requested servers .filter((info) => requestedServerNames.has(info.name)) // Only include requested servers