mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-21 15:08:14 +03:00
♻️ refactor(podkop): reorganize sections into subdirectory
This commit is contained in:
@@ -3,9 +3,9 @@
|
|||||||
'require form';
|
'require form';
|
||||||
'require network';
|
'require network';
|
||||||
'require view.podkop.networkUtils as networkUtils';
|
'require view.podkop.networkUtils as networkUtils';
|
||||||
'require view.podkop.configSection as config';
|
'require view.podkop.sections.config as config';
|
||||||
'require view.podkop.diagnosticSection as diagnostic';
|
'require view.podkop.sections.diagnostic as diagnostic';
|
||||||
'require view.podkop.additionalSection as additional';
|
'require view.podkop.sections.additional as additional';
|
||||||
|
|
||||||
return view.extend({
|
return view.extend({
|
||||||
async render() {
|
async render() {
|
||||||
|
|||||||
@@ -7,6 +7,14 @@
|
|||||||
'require view.podkop.constants as constants';
|
'require view.podkop.constants as constants';
|
||||||
|
|
||||||
// Helper Functions
|
// Helper Functions
|
||||||
|
// Common status object creator
|
||||||
|
function createStatus(state, message, color) {
|
||||||
|
return {
|
||||||
|
state,
|
||||||
|
message: _(message),
|
||||||
|
color: constants.STATUS_COLORS[color]
|
||||||
|
};
|
||||||
|
}
|
||||||
function formatDiagnosticOutput(output) {
|
function formatDiagnosticOutput(output) {
|
||||||
if (typeof output !== 'string') return '';
|
if (typeof output !== 'string') return '';
|
||||||
return output.trim()
|
return output.trim()
|
||||||
@@ -63,12 +71,6 @@ async function safeExec(command, args = [], timeout = constants.COMMAND_TIMEOUT)
|
|||||||
|
|
||||||
// Status Check Functions
|
// Status Check Functions
|
||||||
async function checkFakeIP() {
|
async function checkFakeIP() {
|
||||||
const createStatus = (state, message, color) => ({
|
|
||||||
state,
|
|
||||||
message: _(message),
|
|
||||||
color: constants.STATUS_COLORS[color]
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeoutId = setTimeout(() => controller.abort(), constants.FETCH_TIMEOUT);
|
const timeoutId = setTimeout(() => controller.abort(), constants.FETCH_TIMEOUT);
|
||||||
@@ -94,12 +96,6 @@ async function checkFakeIP() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkFakeIPCLI() {
|
async function checkFakeIPCLI() {
|
||||||
const createStatus = (state, message, color) => ({
|
|
||||||
state,
|
|
||||||
message: _(message),
|
|
||||||
color: constants.STATUS_COLORS[color]
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const singboxStatusResult = await safeExec('/usr/bin/podkop', ['get_sing_box_status']);
|
const singboxStatusResult = await safeExec('/usr/bin/podkop', ['get_sing_box_status']);
|
||||||
const singboxStatus = JSON.parse(singboxStatusResult.stdout || '{"running":0,"dns_configured":0}');
|
const singboxStatus = JSON.parse(singboxStatusResult.stdout || '{"running":0,"dns_configured":0}');
|
||||||
@@ -121,12 +117,6 @@ async function checkFakeIPCLI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkDNSAvailability() {
|
function checkDNSAvailability() {
|
||||||
const createStatus = (state, message, color) => ({
|
|
||||||
state,
|
|
||||||
message: _(message),
|
|
||||||
color: constants.STATUS_COLORS[color]
|
|
||||||
});
|
|
||||||
|
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
try {
|
try {
|
||||||
const dnsStatusResult = await safeExec('/usr/bin/podkop', ['check_dns_available']);
|
const dnsStatusResult = await safeExec('/usr/bin/podkop', ['check_dns_available']);
|
||||||
@@ -168,12 +158,6 @@ function checkDNSAvailability() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkBypass() {
|
async function checkBypass() {
|
||||||
const createStatus = (state, message, color) => ({
|
|
||||||
state,
|
|
||||||
message: _(message),
|
|
||||||
color: constants.STATUS_COLORS[color]
|
|
||||||
});
|
|
||||||
|
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
try {
|
try {
|
||||||
let configMode = 'proxy'; // Default fallback
|
let configMode = 'proxy'; // Default fallback
|
||||||
Reference in New Issue
Block a user