Enable connectivity diagnostics in Connect mode
This commit is contained in:
+1
-2
@@ -135,7 +135,7 @@ const deviceInventory = settings.appMode === 'gateway'
|
||||
vendor: createVendorLookup(),
|
||||
})
|
||||
: null;
|
||||
const localConnectivityDiagnostics = settings.appMode === 'gateway' && !remoteDataplane
|
||||
const localConnectivityDiagnostics = !remoteDataplane
|
||||
? createConnectivityDiagnosticsService({ proxyPort: settings.diagnosticsProxyPort })
|
||||
: null;
|
||||
let subscriptionRefreshPromise = null;
|
||||
@@ -699,7 +699,6 @@ async function handleApi(req, res) {
|
||||
}
|
||||
|
||||
if (req.method === 'POST' && req.url === '/api/diagnostics/connectivity') {
|
||||
if (settings.appMode !== 'gateway') throw new HarborError('ENDPOINT_NOT_FOUND');
|
||||
const { services = [] } = await readBody(req);
|
||||
const state = stateStore.read();
|
||||
const appliedServerId = state.appliedServerId || state.selectedServerId;
|
||||
|
||||
+12
-10
@@ -25,12 +25,10 @@ export function buildGatewayConfig(subscriptionConfig, selectedTag, {
|
||||
} = {}) {
|
||||
const clientMode = settings.appMode === 'client';
|
||||
const directClient = clientMode && clientDirect;
|
||||
const vpnOutbound = directClient
|
||||
? null
|
||||
: structuredClone(findOutbound(subscriptionConfig, selectedTag));
|
||||
if (!directClient && !vpnOutbound) throw new HarborError('SERVER_NOT_FOUND');
|
||||
if (vpnOutbound && !vpnOutbound.tag) vpnOutbound.tag = 'vpn-out';
|
||||
if (vpnOutbound?.type === 'vless' && !vpnOutbound.packet_encoding) {
|
||||
const vpnOutbound = structuredClone(findOutbound(subscriptionConfig, selectedTag));
|
||||
if (!vpnOutbound) throw new HarborError('SERVER_NOT_FOUND');
|
||||
if (!vpnOutbound.tag) vpnOutbound.tag = 'vpn-out';
|
||||
if (vpnOutbound.type === 'vless' && !vpnOutbound.packet_encoding) {
|
||||
vpnOutbound.packet_encoding = 'xudp';
|
||||
}
|
||||
const outboundTag = directClient ? 'direct' : vpnOutbound.tag;
|
||||
@@ -52,20 +50,24 @@ export function buildGatewayConfig(subscriptionConfig, selectedTag, {
|
||||
sniff: true,
|
||||
set_system_proxy: false,
|
||||
},
|
||||
...(!clientMode ? [{
|
||||
{
|
||||
type: 'mixed',
|
||||
tag: DIAGNOSTICS_INBOUND,
|
||||
listen: '127.0.0.1',
|
||||
listen_port: settings.diagnosticsProxyPort,
|
||||
sniff: true,
|
||||
set_system_proxy: false,
|
||||
}] : []),
|
||||
},
|
||||
];
|
||||
const directRules = normalizeRouteRules(routeRules)
|
||||
.filter((rule) => rule.enabled)
|
||||
.map((rule) => ({ [rule.type]: [rule.value], outbound: 'direct' }));
|
||||
const rules = clientMode
|
||||
? [...directRules, { inbound: [MIXED_INBOUND], outbound: outboundTag }]
|
||||
? [
|
||||
{ inbound: [DIAGNOSTICS_INBOUND], outbound: vpnOutbound.tag },
|
||||
...directRules,
|
||||
{ inbound: [MIXED_INBOUND], outbound: outboundTag },
|
||||
]
|
||||
: [
|
||||
{ inbound: [DIAGNOSTICS_INBOUND], outbound: outboundTag },
|
||||
...directRules,
|
||||
@@ -81,7 +83,7 @@ export function buildGatewayConfig(subscriptionConfig, selectedTag, {
|
||||
dns: { independent_cache: true },
|
||||
inbounds,
|
||||
outbounds: [
|
||||
...(vpnOutbound ? [vpnOutbound] : []),
|
||||
vpnOutbound,
|
||||
{ type: 'direct', tag: 'direct' },
|
||||
{ type: 'block', tag: 'block' },
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user