Add runtime version reporting and display
This commit is contained in:
@@ -31,6 +31,7 @@ import {
|
||||
} from '../shared/contracts/state.js';
|
||||
import { HarborError, normalizeHarborError } from '../shared/errors.js';
|
||||
import { createJsonStore, createStateStore } from './services/stateStore.js';
|
||||
import { buildVersionInfo } from './version.js';
|
||||
|
||||
const MAX_BODY_BYTES = 1_000_000;
|
||||
const SUBSCRIPTION_REFRESH_INTERVAL_MS = 15 * 60 * 1000;
|
||||
@@ -63,6 +64,7 @@ if (stateStore.recovery) {
|
||||
}
|
||||
|
||||
const remoteDataplane = settings.appMode === 'gateway' && Boolean(process.env.DATAPLANE_SOCKET);
|
||||
const versionInfo = buildVersionInfo(settings.appMode);
|
||||
const singboxRuntime = remoteDataplane
|
||||
? createDataplaneClient(settings.dataplaneSocket)
|
||||
: createSingboxRuntime({
|
||||
@@ -462,6 +464,16 @@ async function handleApi(req, res) {
|
||||
return sendJson(res, 200, await publicState());
|
||||
}
|
||||
|
||||
if (req.method === 'GET' && req.url === '/api/version') {
|
||||
if (!remoteDataplane) return sendJson(res, 200, versionInfo);
|
||||
const runtime = await singboxRuntime.refresh();
|
||||
return sendJson(res, 200, {
|
||||
...versionInfo,
|
||||
components: { gatewayBackend: runtime.gatewayBackendVersion || null },
|
||||
runtime: { singBox: runtime.singBoxVersion || null },
|
||||
});
|
||||
}
|
||||
|
||||
if (req.method === 'GET' && req.url === '/api/shared-proxy') {
|
||||
return sendJson(res, 200, buildSharedProxyInfo({
|
||||
appMode: settings.appMode,
|
||||
|
||||
Reference in New Issue
Block a user