Compare commits

...

7 Commits

Author SHA1 Message Date
itdoginfo
2aee77b9a2 v0.4.4 Added independent_cache 2025-06-02 15:40:14 +03:00
itdoginfo
2a1a220dc8 v0.4.3 2025-05-22 12:07:08 +03:00
itdoginfo
608caba090 Merge pull request #115 from itdoginfo/fix/comments
♻️ refactor(podkop): update command scheduling and priority handling
2025-05-22 12:01:53 +03:00
Ivan K
04af8c9649 ♻️ refactor(podkop): update command scheduling and priority handling 2025-05-22 11:09:02 +03:00
itdoginfo
88d108e5ab Fix i18n version 2025-05-21 19:43:27 +03:00
itdoginfo
8ce6790355 v0.4.2 2025-05-21 19:18:07 +03:00
itdoginfo
8e7b40cf56 Ready image 2025-05-21 19:17:55 +03:00
9 changed files with 70 additions and 58 deletions

View File

@@ -1,6 +1,4 @@
FROM openwrt/sdk:x86_64-v23.05.5
RUN ./scripts/feeds update -a && ./scripts/feeds install luci-base && mkdir -p /builder/package/feeds/utilites/ && mkdir -p /builder/package/feeds/luci/
FROM itdoginfo/openwrt-sdk:24.10.1
COPY ./podkop /builder/package/feeds/utilites/podkop
COPY ./luci-app-podkop /builder/package/feeds/luci/luci-app-podkop

3
Dockerfile-SDK Normal file
View File

@@ -0,0 +1,3 @@
FROM openwrt/sdk:x86_64-v24.10.1
RUN ./scripts/feeds update -a && ./scripts/feeds install luci-base && mkdir -p /builder/package/feeds/utilites/ && mkdir -p /builder/package/feeds/luci/

View File

@@ -111,6 +111,7 @@ main() {
read -r -p '' RUS
case $RUS in
y)
opkg remove luci-i18n-podkop*
opkg install "$DOWNLOAD_DIR/$ru"
break
;;

View File

@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-podkop
PKG_VERSION:=0.4.1
PKG_VERSION:=0.4.4
PKG_RELEASE:=1
LUCI_TITLE:=LuCI podkop app

View File

@@ -72,20 +72,20 @@ const FETCH_TIMEOUT = 10000; // 10 seconds
const BUTTON_FEEDBACK_TIMEOUT = 1000; // 1 second
const DIAGNOSTICS_INITIAL_DELAY = 100; // 100 milliseconds
// Массив задержек для приоритетов выполнения команд в диагностике (в миллисекундах)
const RUN_PRIORITY = [
0, // Приоритет 0 - Критический (выполняется немедленно)
100, // Приоритет 1 - Очень высокий
300, // Приоритет 2 - Высокий
500, // Приоритет 3 - Выше среднего
700, // Приоритет 4 - Средний
900, // Приоритет 5 - Ниже среднего
1100, // Приоритет 6 - Низкий
1300, // Приоритет 7 - Очень низкий
1500, // Приоритет 8 - Фоновый
1700, // Приоритет 9 - Отложенный
1900 // Приоритет 10 - Наименее важный
];
// Интервалы планирования команд в диагностике (в миллисекундах)
const COMMAND_SCHEDULING = {
P0_PRIORITY: 0, // Наивысший приоритет (без задержки)
P1_PRIORITY: 100, // Очень высокий приоритет
P2_PRIORITY: 300, // Высокий приоритет
P3_PRIORITY: 500, // Выше среднего
P4_PRIORITY: 700, // Стандартный приоритет
P5_PRIORITY: 900, // Ниже среднего
P6_PRIORITY: 1100, // Низкий приоритет
P7_PRIORITY: 1300, // Очень низкий приоритет
P8_PRIORITY: 1500, // Фоновое выполнение
P9_PRIORITY: 1700, // Выполнение в режиме простоя
P10_PRIORITY: 1900 // Наименьший приоритет
};
return baseclass.extend({
STATUS_COLORS,
@@ -102,6 +102,6 @@ return baseclass.extend({
FETCH_TIMEOUT,
BUTTON_FEEDBACK_TIMEOUT,
DIAGNOSTICS_INITIAL_DELAY,
RUN_PRIORITY,
COMMAND_SCHEDULING,
CACHE_TIMEOUT
});

View File

@@ -44,7 +44,13 @@ function safeExec(command, args, priority, callback, timeout = constants.COMMAND
// Helper functions for handling checks
function runCheck(checkFunction, priority, callback) {
priority = (typeof priority === 'number') ? priority : 0;
// Default to highest priority execution if priority is not provided or invalid
let schedulingDelay = constants.COMMAND_SCHEDULING.P0_PRIORITY;
// If priority is a string, try to get the corresponding delay value
if (typeof priority === 'string' && constants.COMMAND_SCHEDULING[priority] !== undefined) {
schedulingDelay = constants.COMMAND_SCHEDULING[priority];
}
const executeCheck = async () => {
try {
@@ -62,7 +68,7 @@ function runCheck(checkFunction, priority, callback) {
};
if (callback && typeof callback === 'function') {
setTimeout(executeCheck, constants.RUN_PRIORITY[priority]);
setTimeout(executeCheck, schedulingDelay);
return;
} else {
return executeCheck();
@@ -70,7 +76,13 @@ function runCheck(checkFunction, priority, callback) {
}
function runAsyncTask(taskFunction, priority) {
priority = (typeof priority === 'number') ? priority : 0;
// Default to highest priority execution if priority is not provided or invalid
let schedulingDelay = constants.COMMAND_SCHEDULING.P0_PRIORITY;
// If priority is a string, try to get the corresponding delay value
if (typeof priority === 'string' && constants.COMMAND_SCHEDULING[priority] !== undefined) {
schedulingDelay = constants.COMMAND_SCHEDULING[priority];
}
setTimeout(async () => {
try {
@@ -78,7 +90,7 @@ function runAsyncTask(taskFunction, priority) {
} catch (error) {
console.error('Async task error:', error);
}
}, constants.RUN_PRIORITY[priority]);
}, schedulingDelay);
}
// Helper Functions for UI and formatting
@@ -151,21 +163,12 @@ async function checkFakeIP() {
async function checkFakeIPCLI() {
try {
return new Promise((resolve) => {
safeExec('/usr/bin/podkop', ['get_sing_box_status'], 0, singboxStatusResult => {
const singboxStatus = JSON.parse(singboxStatusResult.stdout || '{"running":0,"dns_configured":0}');
if (!singboxStatus.running) {
resolve(createStatus('not_working', 'sing-box not running', 'ERROR'));
return;
safeExec('nslookup', ['-timeout=2', constants.FAKEIP_CHECK_DOMAIN, '127.0.0.42'], 'P0_PRIORITY', result => {
if (result.stdout && result.stdout.includes('198.18')) {
resolve(createStatus('working', 'working on router', 'SUCCESS'));
} else {
resolve(createStatus('not_working', 'not working on router', 'ERROR'));
}
safeExec('nslookup', ['-timeout=2', constants.FAKEIP_CHECK_DOMAIN, '127.0.0.42'], 0, result => {
if (result.stdout && result.stdout.includes('198.18')) {
resolve(createStatus('working', 'working on router', 'SUCCESS'));
} else {
resolve(createStatus('not_working', 'not working on router', 'ERROR'));
}
});
});
});
} catch (error) {
@@ -176,7 +179,7 @@ async function checkFakeIPCLI() {
function checkDNSAvailability() {
return new Promise(async (resolve) => {
try {
safeExec('/usr/bin/podkop', ['check_dns_available'], 0, dnsStatusResult => {
safeExec('/usr/bin/podkop', ['check_dns_available'], 'P0_PRIORITY', dnsStatusResult => {
if (!dnsStatusResult || !dnsStatusResult.stdout) {
return resolve({
remote: createStatus('error', 'DNS check timeout', 'WARNING'),
@@ -319,7 +322,7 @@ function showConfigModal(command, title) {
let formattedOutput = '';
if (command === 'global_check') {
safeExec('/usr/bin/podkop', [command], 0, res => {
safeExec('/usr/bin/podkop', [command], 'P0_PRIORITY', res => {
formattedOutput = formatDiagnosticOutput(res.stdout || _('No output'));
try {
@@ -381,7 +384,7 @@ function showConfigModal(command, title) {
}
});
} else {
safeExec('/usr/bin/podkop', [command], 0, res => {
safeExec('/usr/bin/podkop', [command], 'P0_PRIORITY', res => {
formattedOutput = formatDiagnosticOutput(res.stdout || _('No output'));
updateModalContent(formattedOutput);
});
@@ -405,7 +408,7 @@ const ButtonFactory = {
return this.createButton({
label: config.label,
additionalClass: `cbi-button-${config.type || ''}`,
onClick: () => safeExec('/usr/bin/podkop', [config.action])
onClick: () => safeExec('/usr/bin/podkop', [config.action], 'P0_PRIORITY')
.then(() => config.reload && location.reload()),
style: config.style
});
@@ -415,7 +418,7 @@ const ButtonFactory = {
return this.createButton({
label: config.label,
additionalClass: `cbi-button-${config.type || ''}`,
onClick: () => safeExec('/etc/init.d/podkop', [config.action])
onClick: () => safeExec('/etc/init.d/podkop', [config.action], 'P0_PRIORITY')
.then(() => config.reload && location.reload()),
style: config.style
});
@@ -620,7 +623,7 @@ function updateTextElement(elementId, content) {
async function updateDiagnostics() {
// Podkop Status check
safeExec('/usr/bin/podkop', ['get_status'], 0, result => {
safeExec('/usr/bin/podkop', ['get_status'], 'P0_PRIORITY', result => {
try {
const parsedPodkopStatus = JSON.parse(result.stdout || '{"enabled":0,"status":"error"}');
@@ -664,7 +667,7 @@ async function updateDiagnostics() {
});
// Sing-box Status check
safeExec('/usr/bin/podkop', ['get_sing_box_status'], 0, result => {
safeExec('/usr/bin/podkop', ['get_sing_box_status'], 'P0_PRIORITY', result => {
try {
const parsedSingboxStatus = JSON.parse(result.stdout || '{"running":0,"enabled":0,"status":"error"}');
@@ -686,25 +689,25 @@ async function updateDiagnostics() {
});
// Version Information checks
safeExec('/usr/bin/podkop', ['show_version'], 2, result => {
safeExec('/usr/bin/podkop', ['show_version'], 'P2_PRIORITY', result => {
updateTextElement('podkop-version',
document.createTextNode(result.stdout ? result.stdout.trim() : _('Unknown'))
);
});
safeExec('/usr/bin/podkop', ['show_luci_version'], 2, result => {
safeExec('/usr/bin/podkop', ['show_luci_version'], 'P2_PRIORITY', result => {
updateTextElement('luci-version',
document.createTextNode(result.stdout ? result.stdout.trim() : _('Unknown'))
);
});
safeExec('/usr/bin/podkop', ['show_sing_box_version'], 2, result => {
safeExec('/usr/bin/podkop', ['show_sing_box_version'], 'P2_PRIORITY', result => {
updateTextElement('singbox-version',
document.createTextNode(result.stdout ? result.stdout.trim() : _('Unknown'))
);
});
safeExec('/usr/bin/podkop', ['show_system_info'], 2, result => {
safeExec('/usr/bin/podkop', ['show_system_info'], 'P2_PRIORITY', result => {
if (result.stdout) {
updateTextElement('openwrt-version',
document.createTextNode(result.stdout.split('\n')[1].trim())
@@ -719,7 +722,7 @@ async function updateDiagnostics() {
});
// FakeIP and DNS status checks
runCheck(checkFakeIP, 3, result => {
runCheck(checkFakeIP, 'P3_PRIORITY', result => {
updateTextElement('fakeip-browser-status',
E('span', { style: `color: ${result.error ? constants.STATUS_COLORS.WARNING : result.color}` }, [
result.error ? '! ' : result.state === 'working' ? '✔ ' : result.state === 'not_working' ? '✘ ' : '! ',
@@ -728,7 +731,7 @@ async function updateDiagnostics() {
);
});
runCheck(checkFakeIPCLI, 3, result => {
runCheck(checkFakeIPCLI, 'P8_PRIORITY', result => {
updateTextElement('fakeip-router-status',
E('span', { style: `color: ${result.error ? constants.STATUS_COLORS.WARNING : result.color}` }, [
result.error ? '! ' : result.state === 'working' ? '✔ ' : result.state === 'not_working' ? '✘ ' : '! ',
@@ -737,7 +740,7 @@ async function updateDiagnostics() {
);
});
runCheck(checkDNSAvailability, 4, result => {
runCheck(checkDNSAvailability, 'P4_PRIORITY', result => {
if (result.error) {
updateTextElement('dns-remote-status',
E('span', { style: `color: ${constants.STATUS_COLORS.WARNING}` }, '! DNS check error')
@@ -762,14 +765,14 @@ async function updateDiagnostics() {
}
});
runCheck(checkBypass, 1, result => {
runCheck(checkBypass, 'P1_PRIORITY', result => {
updateTextElement('bypass-status',
E('span', { style: `color: ${result.error ? constants.STATUS_COLORS.WARNING : result.color}` }, [
result.error ? '! ' : result.state === 'working' ? '✔ ' : result.state === 'not_working' ? '✘ ' : '! ',
result.error ? 'check error' : result.message
])
);
});
}, 'P1_PRIORITY');
// Config name
runAsyncTask(async () => {
@@ -797,7 +800,7 @@ async function updateDiagnostics() {
} catch (e) {
console.error('Error getting config name from UCI:', e);
}
}, 1);
}, 'P1_PRIORITY');
}
function createDiagnosticsSection(mainSection) {

View File

@@ -16,7 +16,7 @@ let errorPollTimer = null;
// Helper function to fetch errors from the podkop command
async function getPodkopErrors() {
return new Promise(resolve => {
safeExec('/usr/bin/podkop', ['check_logs'], 0, result => {
safeExec('/usr/bin/podkop', ['check_logs'], 'P0_PRIORITY', result => {
if (!result || !result.stdout) return resolve([]);
const logs = result.stdout.split('\n');
@@ -40,7 +40,13 @@ function showErrorNotification(error, isMultiple = false) {
// Helper function for command execution with prioritization
function safeExec(command, args, priority, callback, timeout = constants.COMMAND_TIMEOUT) {
priority = (typeof priority === 'number') ? priority : 0;
// Default to highest priority execution if priority is not provided or invalid
let schedulingDelay = constants.COMMAND_SCHEDULING.P0_PRIORITY;
// If priority is a string, try to get the corresponding delay value
if (typeof priority === 'string' && constants.COMMAND_SCHEDULING[priority] !== undefined) {
schedulingDelay = constants.COMMAND_SCHEDULING[priority];
}
const executeCommand = async () => {
try {
@@ -76,7 +82,7 @@ function safeExec(command, args, priority, callback, timeout = constants.COMMAND
};
if (callback && typeof callback === 'function') {
setTimeout(executeCommand, constants.RUN_PRIORITY[priority]);
setTimeout(executeCommand, schedulingDelay);
return;
}
else {

View File

@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=podkop
PKG_VERSION:=0.4.1
PKG_VERSION:=0.4.4
PKG_RELEASE:=1
PKG_MAINTAINER:=ITDog <podkop@itdog.info>

View File

@@ -797,6 +797,7 @@ sing_box_dns() {
--arg fakeip "$FAKEIP" \
'.dns = {
"strategy": "ipv4_only",
"independent_cache": true,
"fakeip": {
"enabled": true,
"inet4_range": $fakeip