feat: add some shell methods

This commit is contained in:
divocat
2025-10-14 23:15:17 +03:00
parent ffa0073441
commit 739e0d2ba7
3 changed files with 75 additions and 2 deletions

View File

@@ -44,4 +44,20 @@ export const PodkopShellMethods = {
group,
proxy,
]),
restart: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.RESTART),
start: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.START),
stop: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.STOP),
enable: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.ENABLE),
disable: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.DISABLE),
globalCheck: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.GLOBAL_CHECK),
showSingBoxConfig: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.SHOW_SING_BOX_CONFIG),
checkLogs: async () =>
callBaseMethod<unknown>(Podkop.AvailableMethods.CHECK_LOGS),
};

View File

@@ -21,6 +21,36 @@ export namespace ClashAPI {
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Podkop {
// Available commands:
// start Start podkop service
// stop Stop podkop service
// reload Reload podkop configuration
// restart Restart podkop service
// enable Enable podkop autostart
// disable Disable podkop autostart
// main Run main podkop process
// list_update Update domain lists
// check_proxy Check proxy connectivity
// check_nft Check NFT rules
// check_nft_rules Check NFT rules status
// check_sing_box Check sing-box installation and status
// check_github Check GitHub connectivity
// check_logs Show podkop logs from system journal
// check_sing_box_connections Show active sing-box connections
// check_sing_box_logs Show sing-box logs
// check_dnsmasq Check DNSMasq configuration
// check_fakeip Test FakeIP on router
// clash_api Clash API interface for managing proxies and groups
// show_config Display current podkop configuration
// show_version Show podkop version
// show_sing_box_config Show sing-box configuration
// show_sing_box_version Show sing-box version
// show_system_info Show system information
// get_status Get podkop service status
// get_sing_box_status Get sing-box service status
// check_dns_available Check DNS server availability
// global_check Run global system check
export enum AvailableMethods {
CHECK_DNS_AVAILABLE = 'check_dns_available',
CHECK_FAKEIP = 'check_fakeip',
@@ -29,6 +59,14 @@ export namespace Podkop {
CHECK_SING_BOX = 'check_sing_box',
GET_SING_BOX_STATUS = 'get_sing_box_status',
CLASH_API = 'clash_api',
RESTART = 'restart',
START = 'start',
STOP = 'stop',
ENABLE = 'enable',
DISABLE = 'disable',
GLOBAL_CHECK = 'global_check',
SHOW_SING_BOX_CONFIG = 'show_sing_box_config',
CHECK_LOGS = 'check_logs',
}
export enum AvailableClashAPIMethods {

View File

@@ -434,6 +434,14 @@ var Podkop;
AvailableMethods2["CHECK_SING_BOX"] = "check_sing_box";
AvailableMethods2["GET_SING_BOX_STATUS"] = "get_sing_box_status";
AvailableMethods2["CLASH_API"] = "clash_api";
AvailableMethods2["RESTART"] = "restart";
AvailableMethods2["START"] = "start";
AvailableMethods2["STOP"] = "stop";
AvailableMethods2["ENABLE"] = "enable";
AvailableMethods2["DISABLE"] = "disable";
AvailableMethods2["GLOBAL_CHECK"] = "global_check";
AvailableMethods2["SHOW_SING_BOX_CONFIG"] = "show_sing_box_config";
AvailableMethods2["CHECK_LOGS"] = "check_logs";
})(AvailableMethods = Podkop2.AvailableMethods || (Podkop2.AvailableMethods = {}));
let AvailableClashAPIMethods;
((AvailableClashAPIMethods2) => {
@@ -477,7 +485,15 @@ var PodkopShellMethods = {
Podkop.AvailableClashAPIMethods.SET_GROUP_PROXY,
group,
proxy
])
]),
restart: async () => callBaseMethod(Podkop.AvailableMethods.RESTART),
start: async () => callBaseMethod(Podkop.AvailableMethods.START),
stop: async () => callBaseMethod(Podkop.AvailableMethods.STOP),
enable: async () => callBaseMethod(Podkop.AvailableMethods.ENABLE),
disable: async () => callBaseMethod(Podkop.AvailableMethods.DISABLE),
globalCheck: async () => callBaseMethod(Podkop.AvailableMethods.GLOBAL_CHECK),
showSingBoxConfig: async () => callBaseMethod(Podkop.AvailableMethods.SHOW_SING_BOX_CONFIG),
checkLogs: async () => callBaseMethod(Podkop.AvailableMethods.CHECK_LOGS)
};
// src/podkop/methods/custom/getDashboardSections.ts
@@ -2745,7 +2761,7 @@ function renderDiagnosticSystemInfoWidget() {
},
{
key: "Luci App",
value: "1"
value: PODKOP_LUCI_APP_VERSION
},
{
key: "Sing-box",
@@ -2789,6 +2805,8 @@ async function runChecks() {
store.set({ diagnosticsRunAction: { loading: false } });
}
}
async function test() {
}
async function initController2() {
onMount("diagnostic-status").then(() => {
console.log("diagnostic controller initialized.");
@@ -2798,6 +2816,7 @@ async function initController2() {
renderDiagnosticRunActionWidget();
renderDiagnosticAvailableActionsWidget();
renderDiagnosticSystemInfoWidget();
test();
});
}