mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-01-31 14:50:58 +03:00
feat: add getSingBoxCheck js method
This commit is contained in:
24
fe-app-podkop/src/podkop/methods/getSingBoxCheck.ts
Normal file
24
fe-app-podkop/src/podkop/methods/getSingBoxCheck.ts
Normal 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: '',
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { executeShellCommand } from '../../helpers';
|
import { executeShellCommand } from '../../helpers';
|
||||||
|
|
||||||
export async function getSingboxStatus(): Promise<{
|
export async function getSingBoxStatus(): Promise<{
|
||||||
running: number;
|
running: number;
|
||||||
enabled: number;
|
enabled: number;
|
||||||
status: string;
|
status: string;
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
export * from './getConfigSections';
|
export * from './getConfigSections';
|
||||||
export * from './getDashboardSections';
|
export * from './getDashboardSections';
|
||||||
export * from './getPodkopStatus';
|
export * from './getPodkopStatus';
|
||||||
export * from './getSingboxStatus';
|
export * from './getSingBoxStatus';
|
||||||
export * from './getDNSCheck';
|
export * from './getDNSCheck';
|
||||||
export * from './getNftRulesCheck';
|
export * from './getNftRulesCheck';
|
||||||
|
export * from './getSingBoxCheck';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
getDashboardSections,
|
getDashboardSections,
|
||||||
getPodkopStatus,
|
getPodkopStatus,
|
||||||
getSingboxStatus,
|
getSingBoxStatus,
|
||||||
} from '../../methods';
|
} from '../../methods';
|
||||||
import {
|
import {
|
||||||
getClashApiUrl,
|
getClashApiUrl,
|
||||||
@@ -52,7 +52,7 @@ async function fetchServicesInfo() {
|
|||||||
try {
|
try {
|
||||||
const [podkop, singbox] = await Promise.all([
|
const [podkop, singbox] = await Promise.all([
|
||||||
getPodkopStatus(),
|
getPodkopStatus(),
|
||||||
getSingboxStatus(),
|
getSingBoxStatus(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
store.set({
|
store.set({
|
||||||
|
|||||||
@@ -88,4 +88,13 @@ export namespace Podkop {
|
|||||||
rules_proxy_counters: 0 | 1;
|
rules_proxy_counters: 0 | 1;
|
||||||
rules_other_mark_exist: 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1079,8 +1079,8 @@ async function getPodkopStatus() {
|
|||||||
return { enabled: 0, status: "unknown" };
|
return { enabled: 0, status: "unknown" };
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/podkop/methods/getSingboxStatus.ts
|
// src/podkop/methods/getSingBoxStatus.ts
|
||||||
async function getSingboxStatus() {
|
async function getSingBoxStatus() {
|
||||||
const response = await executeShellCommand({
|
const response = await executeShellCommand({
|
||||||
command: "/usr/bin/podkop",
|
command: "/usr/bin/podkop",
|
||||||
args: ["get_sing_box_status"],
|
args: ["get_sing_box_status"],
|
||||||
@@ -1130,6 +1130,25 @@ async function getNftRulesCheck() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// src/podkop/methods/getSingBoxCheck.ts
|
||||||
|
async function getSingBoxCheck() {
|
||||||
|
const response = await executeShellCommand({
|
||||||
|
command: "/usr/bin/podkop",
|
||||||
|
args: ["check_sing_box"],
|
||||||
|
timeout: 1e4
|
||||||
|
});
|
||||||
|
if (response.stdout) {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: JSON.parse(response.stdout)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// src/podkop/services/tab.service.ts
|
// src/podkop/services/tab.service.ts
|
||||||
var TabService = class _TabService {
|
var TabService = class _TabService {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -1691,7 +1710,7 @@ async function fetchServicesInfo() {
|
|||||||
try {
|
try {
|
||||||
const [podkop, singbox] = await Promise.all([
|
const [podkop, singbox] = await Promise.all([
|
||||||
getPodkopStatus(),
|
getPodkopStatus(),
|
||||||
getSingboxStatus()
|
getSingBoxStatus()
|
||||||
]);
|
]);
|
||||||
store.set({
|
store.set({
|
||||||
servicesInfoWidget: {
|
servicesInfoWidget: {
|
||||||
@@ -2070,7 +2089,8 @@ return baseclass.extend({
|
|||||||
getNftRulesCheck,
|
getNftRulesCheck,
|
||||||
getPodkopStatus,
|
getPodkopStatus,
|
||||||
getProxyUrlName,
|
getProxyUrlName,
|
||||||
getSingboxStatus,
|
getSingBoxCheck,
|
||||||
|
getSingBoxStatus,
|
||||||
initDashboardController,
|
initDashboardController,
|
||||||
initDiagnosticController,
|
initDiagnosticController,
|
||||||
injectGlobalStyles,
|
injectGlobalStyles,
|
||||||
|
|||||||
Reference in New Issue
Block a user