Simplify proxy routing and configuration

This commit is contained in:
2026-07-11 04:42:16 +03:00
parent efa46d1ee5
commit d3b7f0d613
22 changed files with 786 additions and 787 deletions

View File

@@ -5,7 +5,10 @@ const parsePort = (value, fallback) => {
const parsed = Number.parseInt(value, 10);
return Number.isInteger(parsed) ? parsed : fallback;
};
const proxyPort = parsePort(process.env.PROXY_PORT, 8080);
const proxyPort = parsePort(
process.env.PROXY_PORT,
process.env.APP_MODE === "client" ? 8082 : 8080,
);
const clientProxyPortStart = parsePort(
process.env.CLIENT_PROXY_PORT_START,
proxyPort,

View File

@@ -607,7 +607,7 @@ function publicState() {
const customRules = readJson(settings.customRulesPath, []);
const deviceProfiles = readDeviceProfiles();
const clientSettings = readClientSettings();
const { subscriptionUrl, ...rest } = state;
const { subscriptionUrl, servers = [], ...rest } = state;
return {
mode: settings.appMode,
port: settings.port,
@@ -640,6 +640,10 @@ function publicState() {
directBypassAvailable: IPSET_AVAILABLE,
sourceBypassCidrs: sourceBypassCidrs(deviceProfiles),
...rest,
servers: servers.map((server) => ({
...server,
tag: String(server.tag || '').trim(),
})),
};
}
@@ -1324,7 +1328,7 @@ async function handleApi(req, res) {
servers.map(async (server) => {
const ping = await tcpPing(server.server, server.server_port, 3000);
return {
tag: server.tag,
tag: String(server.tag || '').trim(),
...ping,
checkedAt: new Date().toISOString(),
};

View File

@@ -123,7 +123,7 @@ export function parseSubscriptionBody(body) {
const servers = outbounds
.filter((outbound) => PROXY_TYPES.has(outbound.type))
.map((outbound) => ({
tag: outbound.tag || `${outbound.type}-${outbound.server || 'server'}`,
tag: String(outbound.tag || `${outbound.type}-${outbound.server || 'server'}`).trim(),
type: outbound.type,
server: outbound.server || 'unknown',
server_port: outbound.server_port || 443,