Simplify proxy routing and configuration
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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(),
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user