feat: add getSingBoxCheck js method

This commit is contained in:
divocat
2025-10-11 20:17:24 +03:00
parent fd0b981186
commit 5486dfb0a4
6 changed files with 62 additions and 8 deletions

View File

@@ -0,0 +1,24 @@
import { executeShellCommand } from '../../helpers';
import { Podkop } from '../types';
export async function getSingBoxCheck(): Promise<
Podkop.MethodResponse<Podkop.SingBoxCheckResult>
> {
const response = await executeShellCommand({
command: '/usr/bin/podkop',
args: ['check_sing_box'],
timeout: 10000,
});
if (response.stdout) {
return {
success: true,
data: JSON.parse(response.stdout) as Podkop.SingBoxCheckResult,
};
}
return {
success: false,
error: '',
};
}

View File

@@ -1,6 +1,6 @@
import { executeShellCommand } from '../../helpers';
export async function getSingboxStatus(): Promise<{
export async function getSingBoxStatus(): Promise<{
running: number;
enabled: number;
status: string;

View File

@@ -1,6 +1,7 @@
export * from './getConfigSections';
export * from './getDashboardSections';
export * from './getPodkopStatus';
export * from './getSingboxStatus';
export * from './getSingBoxStatus';
export * from './getDNSCheck';
export * from './getNftRulesCheck';
export * from './getSingBoxCheck';

View File

@@ -1,7 +1,7 @@
import {
getDashboardSections,
getPodkopStatus,
getSingboxStatus,
getSingBoxStatus,
} from '../../methods';
import {
getClashApiUrl,
@@ -52,7 +52,7 @@ async function fetchServicesInfo() {
try {
const [podkop, singbox] = await Promise.all([
getPodkopStatus(),
getSingboxStatus(),
getSingBoxStatus(),
]);
store.set({

View File

@@ -88,4 +88,13 @@ export namespace Podkop {
rules_proxy_counters: 0 | 1;
rules_other_mark_exist: 0 | 1;
}
export interface SingBoxCheckResult {
sing_box_installed: 0 | 1;
sing_box_version_ok: 0 | 1;
sing_box_service_exist: 0 | 1;
sing_box_autostart_disabled: 0 | 1;
sing_box_process_running: 0 | 1;
sing_box_ports_listening: 0 | 1;
}
}