diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js
index d4affbf..ac7d235 100644
--- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js
+++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js
@@ -7,10 +7,28 @@
return view.extend({
async render() {
+ document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', `
+
+
+
+ `);
+
var m, s, o;
m = new form.Map('podkop', _('Podkop configuration'), null, ['main', 'second']);
+ m = new form.Map('podkop', _('Podkop'), null, ['main', 'second']);
+ L.uci.load('podkop').then(() => {
+ const version = L.uci.get('podkop', 'main', 'version') || '';
+ if (version) {
+ m.title = _('Podkop') + ' v' + version;
+ if (!window.location.search.includes('v=')) {
+ const newUrl = window.location.pathname + '?v=' + version;
+ window.history.replaceState(null, '', newUrl);
+ }
+ }
+ });
+
s = m.section(form.TypedSection, 'main');
s.anonymous = true;
@@ -552,6 +570,50 @@ return view.extend({
});
};
+ o = s.taboption('diagnostics', form.Button, '_show_config');
+ o.title = _('Show Config');
+ o.description = _('Show current podkop configuration with masked sensitive data');
+ o.inputtitle = _('Show Config');
+ o.inputstyle = 'apply';
+ o.onclick = function () {
+ return fs.exec('/etc/init.d/podkop', ['show_config'])
+ .then(function (res) {
+ const formattedOutput = formatDiagnosticOutput(res.stdout || _('No output'));
+
+ const modalElement = ui.showModal(_('Podkop Configuration'), [
+ E('div', { class: 'cbi-section' }, [
+ E('pre', { class: 'cbi-value-field' }, formattedOutput)
+ ]),
+ E('div', { style: 'display: flex; justify-content: space-between; margin-top: 1em;' }, [
+ E('button', {
+ 'class': 'btn cbi-button-save',
+ 'click': function () {
+ const textarea = document.createElement('textarea');
+ textarea.value = '```\n' + formattedOutput + '\n```';
+ document.body.appendChild(textarea);
+ textarea.select();
+ try {
+ document.execCommand('copy');
+ ui.hideModal();
+ } catch (err) {
+ ui.addNotification(null, E('p', {}, _('Failed to copy: ') + err.message));
+ }
+ document.body.removeChild(textarea);
+ }
+ }, _('Copy to Clipboard')),
+ E('button', {
+ 'class': 'btn cbi-button-neutral',
+ 'click': ui.hideModal
+ }, _('Close'))
+ ])
+ ], 'large');
+
+ if (modalElement && modalElement.parentElement) {
+ modalElement.parentElement.classList.add('modal-overlay-large');
+ }
+ });
+ };
+
o = s.taboption('diagnostics', form.Button, '_list_update');
o.title = _('Update lists');
o.description = _('Update all lists in config');
diff --git a/podkop/files/etc/config/podkop b/podkop/files/etc/config/podkop
index 0976aa8..8c86dfe 100644
--- a/podkop/files/etc/config/podkop
+++ b/podkop/files/etc/config/podkop
@@ -1,4 +1,5 @@
config main 'main'
+ option version '0.3.3'
option mode 'proxy'
#option interface ''
option proxy_config_type ''
diff --git a/podkop/files/etc/init.d/podkop b/podkop/files/etc/init.d/podkop
index 2aefab0..b73b9fe 100755
--- a/podkop/files/etc/init.d/podkop
+++ b/podkop/files/etc/init.d/podkop
@@ -7,7 +7,7 @@ script=$(readlink "$initscript")
NAME="$(basename ${script:-$initscript})"
config_load "$NAME"
-EXTRA_COMMANDS="list_update check_proxy check_nft check_github check_logs check_all check_three main"
+EXTRA_COMMANDS="list_update check_proxy check_nft check_github check_logs check_all check_three main show_config"
EXTRA_HELP=" list_update Updating domain and subnet lists
sing_box_config_vless For test vless string
check_proxy Check if sing-box proxy works correctly
@@ -16,7 +16,8 @@ EXTRA_HELP=" list_update Updating domain and subnet lists
check_logs Show podkop logs from system journal
check_all Run all checks
check_three Run check_proxy, check_nft and check_github
- main Main function"
+ main Main function
+ show_config Show current configuration with masked sensitive data"
[ ! -L /usr/sbin/podkop ] && ln -s /etc/init.d/podkop /usr/sbin/podkop
@@ -767,7 +768,7 @@ sing_box_config_vless() {
get_param() {
local param="$1"
local value=$(echo "$STRING" | sed -n "s/.*[?&]$param=\([^&?#]*\).*/\1/p")
- value=$(echo "$value" | sed 's/%2F/\//g; s/%2C/,/g; s/%3D/=/g; s/%2B/+/g; s/%20/ /g' | tr -d '\n' | tr -d '\r')
+ value=$(uhttpd -d "$value" | tr -d '\n' | tr -d '\r')
echo "$value"
}
@@ -1309,18 +1310,31 @@ check_proxy() {
nolog "Checking proxy connection..."
- for attempt in `seq 1 5`; do
- response=$(sing-box tools fetch ifconfig.me -D /etc/sing-box 2>/dev/null)
- if ! echo "$response" | grep -q "403 Forbidden"; then
- nolog "Proxy check completed successfully"
- #echo "$response" | sed 's/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/XXX.\2.\3.\4/'
- echo "$response" | sed -n 's/^[0-9]\+\.[0-9]\+\.[0-9]\+\.\([0-9]\+\)$/X.X.X.\1/p'
- return 0
- fi
- done
- nolog "Failed to get a non-403 response after 5 attempts"
- return 1
+ for attempt in `seq 1 5`; do
+ response=$(sing-box tools fetch ifconfig.me -D /etc/sing-box 2>/dev/null)
+ if echo "$response" | grep -q "^ "$tmp_config"
+
+ cat "$tmp_config"
+ rm -f "$tmp_config"
+}