From b389c2afef6bd6ea5f57f2733ce38288592c507e Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Sun, 5 Jan 2025 20:35:50 +0800 Subject: [PATCH] update 2025-01-05 20:35:50 --- .../resources/view/fchomo/global.js | 19 +++++++++++ luci-app-fchomo/po/templates/fchomo.pot | 17 ++++++++++ luci-app-fchomo/po/zh_Hans/fchomo.po | 17 ++++++++++ luci-app-fchomo/po/zh_Hant/fchomo.po | 19 ++++++++++- .../root/etc/fchomo/scripts/firewall_post.ut | 33 ++++++++++++++++++- .../etc/fchomo/scripts/generate_client.uc | 2 ++ .../resources/view/nekobox/configs.js | 18 ++++++++++ luci-app-nekobox/htdocs/nekobox/configs.php | 6 ---- luci-app-nekobox/htdocs/nekobox/dashboard.php | 1 - luci-app-nekobox/htdocs/nekobox/index.php | 25 +++++++------- luci-app-nekobox/htdocs/nekobox/settings.php | 1 - .../share/luci/menu.d/luci-app-nekobox.json | 13 ++++++-- 12 files changed, 148 insertions(+), 23 deletions(-) create mode 100644 luci-app-nekobox/htdocs/luci-static/resources/view/nekobox/configs.js diff --git a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/global.js b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/global.js index d6d60a875..8de0022dd 100644 --- a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/global.js +++ b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/global.js @@ -758,6 +758,25 @@ return view.extend({ so.depends('routing_mode', 'bypass_cn'); so.depends('routing_mode', 'routing_gfw'); + so = ss.taboption('routing_control', form.ListValue, 'routing_dscp_mode', _('Routing DSCP')); + so.value('', _('All allowed')); + so.value('bypass_dscp', _('Bypass DSCP')); + so.value('routing_dscp', _('Routing DSCP')); + + so = ss.taboption('routing_control', form.Value, 'routing_dscp_list', _('DSCP list')); + so.placeholder = '0,10,12,14,63'; + so.validate = function(section_id, value) { + if (!value) + return true; + else if (value.match('^(6[0-3]|[1-5]?[0-9])(,(6[0-3]|[1-5]?[0-9]))*$') === null) + return _('Expecting: %s').format(_('One or more numbers in the range 0-63 separated by commas')); + + return true; + } + so.rmempty = false; + so.depends('routing_dscp_mode', 'bypass_dscp'); + so.depends('routing_dscp_mode', 'routing_dscp'); + /* Custom Direct list */ ss.tab('direct_list', _('Custom Direct List')); diff --git a/luci-app-fchomo/po/templates/fchomo.pot b/luci-app-fchomo/po/templates/fchomo.pot index d2e1ff5d8..af8230179 100644 --- a/luci-app-fchomo/po/templates/fchomo.pot +++ b/luci-app-fchomo/po/templates/fchomo.pot @@ -250,6 +250,10 @@ msgstr "" msgid "Bypass CN" msgstr "" +#: htdocs/luci-static/resources/view/fchomo/global.js:763 +msgid "Bypass DSCP" +msgstr "" + #: htdocs/luci-static/resources/view/fchomo/global.js:552 msgid "CORS Allow origins" msgstr "" @@ -432,6 +436,10 @@ msgstr "" msgid "DNS settings" msgstr "" +#: htdocs/luci-static/resources/view/fchomo/global.js:766 +msgid "DSCP list" +msgstr "" + #: htdocs/luci-static/resources/view/fchomo/global.js:314 msgid "Dashboard version" msgstr "" @@ -1437,6 +1445,10 @@ msgstr "" msgid "Obfuscate type" msgstr "" +#: htdocs/luci-static/resources/view/fchomo/global.js:772 +msgid "One or more numbers in the range 0-63 separated by commas" +msgstr "" + #: htdocs/luci-static/resources/view/fchomo/global.js:658 msgid "Only process traffic from specific interfaces. Leave empty for all." msgstr "" @@ -1799,6 +1811,11 @@ msgstr "" msgid "Routing Control" msgstr "" +#: htdocs/luci-static/resources/view/fchomo/global.js:761 +#: htdocs/luci-static/resources/view/fchomo/global.js:764 +msgid "Routing DSCP" +msgstr "" + #: htdocs/luci-static/resources/view/fchomo/global.js:747 msgid "Routing GFW" msgstr "" diff --git a/luci-app-fchomo/po/zh_Hans/fchomo.po b/luci-app-fchomo/po/zh_Hans/fchomo.po index ee5035cdd..09305c70a 100644 --- a/luci-app-fchomo/po/zh_Hans/fchomo.po +++ b/luci-app-fchomo/po/zh_Hans/fchomo.po @@ -258,6 +258,10 @@ msgstr "启动 DNS 服务器 (节点)" msgid "Bypass CN" msgstr "绕过 CN 流量" +#: htdocs/luci-static/resources/view/fchomo/global.js:763 +msgid "Bypass DSCP" +msgstr "绕过 DSCP" + #: htdocs/luci-static/resources/view/fchomo/global.js:552 msgid "CORS Allow origins" msgstr "CORS 允许的来源" @@ -440,6 +444,10 @@ msgstr "DNS 服务器" msgid "DNS settings" msgstr "DNS 设置" +#: htdocs/luci-static/resources/view/fchomo/global.js:766 +msgid "DSCP list" +msgstr "DSCP 列表" + #: htdocs/luci-static/resources/view/fchomo/global.js:314 msgid "Dashboard version" msgstr "面板版本" @@ -1459,6 +1467,10 @@ msgstr "混淆密码" msgid "Obfuscate type" msgstr "混淆类型" +#: htdocs/luci-static/resources/view/fchomo/global.js:772 +msgid "One or more numbers in the range 0-63 separated by commas" +msgstr "0-63 范围内的一个或多个数字,以逗号分隔" + #: htdocs/luci-static/resources/view/fchomo/global.js:658 msgid "Only process traffic from specific interfaces. Leave empty for all." msgstr "只处理来自指定接口的流量。留空表示全部。" @@ -1822,6 +1834,11 @@ msgstr "Restls 剧本" msgid "Routing Control" msgstr "路由控制" +#: htdocs/luci-static/resources/view/fchomo/global.js:761 +#: htdocs/luci-static/resources/view/fchomo/global.js:764 +msgid "Routing DSCP" +msgstr "路由 DSCP" + #: htdocs/luci-static/resources/view/fchomo/global.js:747 msgid "Routing GFW" msgstr "路由 GFW 流量" diff --git a/luci-app-fchomo/po/zh_Hant/fchomo.po b/luci-app-fchomo/po/zh_Hant/fchomo.po index 7fef86cd1..a8ff15a30 100644 --- a/luci-app-fchomo/po/zh_Hant/fchomo.po +++ b/luci-app-fchomo/po/zh_Hant/fchomo.po @@ -258,6 +258,10 @@ msgstr "啟動 DNS 伺服器 (節點)" msgid "Bypass CN" msgstr "繞過 CN 流量" +#: htdocs/luci-static/resources/view/fchomo/global.js:763 +msgid "Bypass DSCP" +msgstr "繞過 DSCP" + #: htdocs/luci-static/resources/view/fchomo/global.js:552 msgid "CORS Allow origins" msgstr "CORS 允許的來源" @@ -440,6 +444,10 @@ msgstr "DNS 伺服器" msgid "DNS settings" msgstr "DNS 設定" +#: htdocs/luci-static/resources/view/fchomo/global.js:766 +msgid "DSCP list" +msgstr "DSCP 清單" + #: htdocs/luci-static/resources/view/fchomo/global.js:314 msgid "Dashboard version" msgstr "面板版本" @@ -1195,7 +1203,7 @@ msgstr "有時效能較好。" #: htdocs/luci-static/resources/view/fchomo/node.js:532 #: htdocs/luci-static/resources/view/fchomo/server.js:332 msgid "List of supported application level protocols, in order of preference." -msgstr "支援的應用層協議協商列表,依序排列。" +msgstr "支援的應用層協議協商清單,依序排列。" #: htdocs/luci-static/resources/view/fchomo/server.js:118 msgid "Listen address" @@ -1459,6 +1467,10 @@ msgstr "混淆密碼" msgid "Obfuscate type" msgstr "混淆類型" +#: htdocs/luci-static/resources/view/fchomo/global.js:772 +msgid "One or more numbers in the range 0-63 separated by commas" +msgstr "0-63 範圍內的一個或多個數字,以逗號分隔" + #: htdocs/luci-static/resources/view/fchomo/global.js:658 msgid "Only process traffic from specific interfaces. Leave empty for all." msgstr "只處理來自指定介面的流量。留空表示全部。" @@ -1822,6 +1834,11 @@ msgstr "Restls 劇本" msgid "Routing Control" msgstr "路由控制" +#: htdocs/luci-static/resources/view/fchomo/global.js:761 +#: htdocs/luci-static/resources/view/fchomo/global.js:764 +msgid "Routing DSCP" +msgstr "路由 DSCP" + #: htdocs/luci-static/resources/view/fchomo/global.js:747 msgid "Routing GFW" msgstr "路由 GFW 流量" diff --git a/luci-app-fchomo/root/etc/fchomo/scripts/firewall_post.ut b/luci-app-fchomo/root/etc/fchomo/scripts/firewall_post.ut index bc6e78d1f..0bc5e370a 100755 --- a/luci-app-fchomo/root/etc/fchomo/scripts/firewall_post.ut +++ b/luci-app-fchomo/root/etc/fchomo/scripts/firewall_post.ut @@ -77,12 +77,14 @@ const dnsmasq_hijacked = uci.get('dhcp', '@dnsmasq[0]', 'dns_redirect') || '0', dnsmasq_port = uci.get('dhcp', '@dnsmasq[0]', 'port') || '53'; - let client_enabled, routing_tcpport, routing_udpport, routing_mode, routing_domain; + let client_enabled, routing_tcpport, routing_udpport, routing_mode, routing_domain, routing_dscp_mode, routing_dscp_list; client_enabled = uci.get(cfgname, 'routing', 'client_enabled') || '0', routing_tcpport = uci.get(cfgname, 'routing', 'routing_tcpport') || null; routing_udpport = uci.get(cfgname, 'routing', 'routing_udpport') || null; routing_mode = uci.get(cfgname, 'routing', 'routing_mode') || null; routing_domain = uci.get(cfgname, 'routing', 'routing_domain') || '0'; + routing_dscp_mode = uci.get(cfgname, 'routing', 'routing_dscp_mode') || null; + routing_dscp_list = uci.get(cfgname, 'routing', 'routing_dscp_list') || null; if (routing_tcpport === 'common') routing_tcpport = common_tcpport; @@ -184,6 +186,18 @@ chain {{ inchain }} { {% endif %} {% endif /* routing_mode */ %} + {% if (routing_dscp_mode === 'routing_dscp'): %} + ip dscp != @routing_dscp_list counter return + {% if (global_ipv6 === '1'): %} + ip6 dscp != @routing_dscp_list counter return + {% endif %} + {% elif (routing_dscp_mode === 'bypass_dscp'): %} + ip dscp @bypass_dscp_list counter return + {% if (global_ipv6 === '1'): %} + ip6 dscp @bypass_dscp_list counter return + {% endif %} + {% endif /* routing_dscp_mode */ %} + counter goto {{ outchain }} } {% endfunction %} @@ -329,6 +343,23 @@ table inet fchomo { {% endif %} {% endif /* routing_mode */ %} + {#- Routing DSCP #} + {% if (match(routing_dscp_mode, /bypass_dscp/)): %} + set bypass_dscp_list { + type dscp + flags interval + auto-merge + elements = { {{ join(', ', split(routing_dscp_list, ',')) }} } + } + {% elif (match(routing_dscp_mode, /routing_dscp/)): %} + set routing_dscp_list { + type dscp + flags interval + auto-merge + elements = { {{ join(', ', split(routing_dscp_list, ',')) }} } + } + {% endif /* routing_dscp_mode */ %} + {#- Routing port #} {% if (routing_tcpport): %} set tcp_routing_port { diff --git a/luci-app-fchomo/root/etc/fchomo/scripts/generate_client.uc b/luci-app-fchomo/root/etc/fchomo/scripts/generate_client.uc index 5083ac811..f4299b5b0 100755 --- a/luci-app-fchomo/root/etc/fchomo/scripts/generate_client.uc +++ b/luci-app-fchomo/root/etc/fchomo/scripts/generate_client.uc @@ -76,6 +76,8 @@ const listen_interfaces = uci.get(uciconf, uciroute, 'listen_interfaces') || nul routing_udpport = uci.get(uciconf, uciroute, 'routing_udpport') || null, routing_mode = uci.get(uciconf, uciroute, 'routing_mode') || null, routing_domain = strToBool(uci.get(uciconf, uciroute, 'routing_domain')), + routing_dscp_mode = uci.get(uciconf, uciroute, 'routing_dscp_mode') || null, + routing_dscp_list = uci.get(uciconf, uciroute, 'routing_dscp_list') || null, tposh = 'c2luZ2JveA'; /* WAN DNS server array */ diff --git a/luci-app-nekobox/htdocs/luci-static/resources/view/nekobox/configs.js b/luci-app-nekobox/htdocs/luci-static/resources/view/nekobox/configs.js new file mode 100644 index 000000000..249befde8 --- /dev/null +++ b/luci-app-nekobox/htdocs/luci-static/resources/view/nekobox/configs.js @@ -0,0 +1,18 @@ +'use strict'; +'require view'; +'require uci'; + +return view.extend({ + load: function() { + return uci.load('neko'); + }, + render: function() { + return E('iframe', { + src: window.location.protocol + "//" + window.location.hostname + '/nekobox/configs.php', + style: 'width: 100%; min-height: 95vh; border: none; border-radius: 5px; resize: vertical;' + }); + }, + handleSaveApply: null, + handleSave: null, + handleReset: null +}); \ No newline at end of file diff --git a/luci-app-nekobox/htdocs/nekobox/configs.php b/luci-app-nekobox/htdocs/nekobox/configs.php index 7556e0a02..b6c2f6610 100644 --- a/luci-app-nekobox/htdocs/nekobox/configs.php +++ b/luci-app-nekobox/htdocs/nekobox/configs.php @@ -44,16 +44,10 @@ include './cfg.php'; -
- 🏠 首页 - 📊 面板 - ⚙️ 配置 - 📦 订阅 - 🛠️ 设定
diff --git a/luci-app-nekobox/htdocs/nekobox/dashboard.php b/luci-app-nekobox/htdocs/nekobox/dashboard.php index 7815a62e2..55ba5ea3e 100644 --- a/luci-app-nekobox/htdocs/nekobox/dashboard.php +++ b/luci-app-nekobox/htdocs/nekobox/dashboard.php @@ -75,7 +75,6 @@ $dash_link = $neko_cfg['ctrl_host'] . ':' . $neko_cfg['ctrl_port'] . '/ui/dashbo diff --git a/luci-app-nekobox/htdocs/nekobox/index.php b/luci-app-nekobox/htdocs/nekobox/index.php index f267a9daa..d91731a46 100644 --- a/luci-app-nekobox/htdocs/nekobox/index.php +++ b/luci-app-nekobox/htdocs/nekobox/index.php @@ -238,31 +238,35 @@ MAX_SIZE=$max_size crontab -l | grep -v "/etc/neko/core/set_cron.sh" | crontab - (crontab -l 2>/dev/null; echo "$cron_schedule") | crontab - +timestamp() { + date "+%Y-%m-%d %H:%M:%S" +} + if [ -f "\$LOG_FILE" ] && [ \$(stat -c %s "\$LOG_FILE") -gt \$MAX_SIZE ]; then - echo "Log file (\$LOG_FILE) size exceeds \$MAX_SIZE bytes. Clearing logs..." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Log file (\$LOG_FILE) size exceeds \$MAX_SIZE bytes. Clearing logs..." >> /var/log/cron_debug.log 2>&1 > "\$LOG_FILE" - echo "Log file (\$LOG_FILE) cleared." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Log file (\$LOG_FILE) cleared." >> /var/log/cron_debug.log 2>&1 else - echo "Log file (\$LOG_FILE) is within the size limit, no action needed." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Log file (\$LOG_FILE) is within the size limit, no action needed." >> /var/log/cron_debug.log 2>&1 fi if [ -f "\$TMP_LOG_FILE" ] && [ \$(stat -c %s "\$TMP_LOG_FILE") -gt \$MAX_SIZE ]; then - echo "Temp log file (\$TMP_LOG_FILE) size exceeds \$MAX_SIZE bytes. Clearing logs..." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Temp log file (\$TMP_LOG_FILE) size exceeds \$MAX_SIZE bytes. Clearing logs..." >> /var/log/cron_debug.log 2>&1 > "\$TMP_LOG_FILE" - echo "Temp log file (\$TMP_LOG_FILE) cleared." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Temp log file (\$TMP_LOG_FILE) cleared." >> /var/log/cron_debug.log 2>&1 else - echo "Temp log file (\$TMP_LOG_FILE) is within the size limit, no action needed." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Temp log file (\$TMP_LOG_FILE) is within the size limit, no action needed." >> /var/log/cron_debug.log 2>&1 fi if [ -f "\$ADDITIONAL_LOG_FILE" ] && [ \$(stat -c %s "\$ADDITIONAL_LOG_FILE") -gt \$MAX_SIZE ]; then - echo "Additional log file (\$ADDITIONAL_LOG_FILE) size exceeds \$MAX_SIZE bytes. Clearing logs..." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Additional log file (\$ADDITIONAL_LOG_FILE) size exceeds \$MAX_SIZE bytes. Clearing logs..." >> /var/log/cron_debug.log 2>&1 > "\$ADDITIONAL_LOG_FILE" - echo "Additional log file (\$ADDITIONAL_LOG_FILE) cleared." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Additional log file (\$ADDITIONAL_LOG_FILE) cleared." >> /var/log/cron_debug.log 2>&1 else - echo "Additional log file (\$ADDITIONAL_LOG_FILE) is within the size limit, no action needed." >> /var/log/cron_debug.log 2>&1 + echo "\$(timestamp) Additional log file (\$ADDITIONAL_LOG_FILE) is within the size limit, no action needed." >> /var/log/cron_debug.log 2>&1 fi -echo "Log rotation completed." >> /var/log/cron_debug.log 2>&1 +echo "\$(timestamp) Log rotation completed." >> /var/log/cron_debug.log 2>&1 EOL; $cronScriptPath = '/etc/neko/core/set_cron.sh'; @@ -701,7 +705,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['selected_config'])) {
🏠 首页 📊 面板 - ⚙️ 配置 📦 订阅 🛠️ 设定
diff --git a/luci-app-nekobox/htdocs/nekobox/settings.php b/luci-app-nekobox/htdocs/nekobox/settings.php index c52680781..adcb70f6b 100644 --- a/luci-app-nekobox/htdocs/nekobox/settings.php +++ b/luci-app-nekobox/htdocs/nekobox/settings.php @@ -183,7 +183,6 @@ $razordVersion = getRazordVersion();
🏠 首页 📊 面板 - ⚙️ 配置 📦 订阅 🛠️ 设定
diff --git a/luci-app-nekobox/root/usr/share/luci/menu.d/luci-app-nekobox.json b/luci-app-nekobox/root/usr/share/luci/menu.d/luci-app-nekobox.json index 7713f56a1..35744f027 100644 --- a/luci-app-nekobox/root/usr/share/luci/menu.d/luci-app-nekobox.json +++ b/luci-app-nekobox/root/usr/share/luci/menu.d/luci-app-nekobox.json @@ -35,10 +35,19 @@ "path": "nekobox/yacd" } }, + + "admin/services/nekobox/configs": { + "title": "配置", + "order": 4, + "action": { + "type": "view", + "path": "nekobox/configs" + } + }, "admin/services/nekobox/video": { "title": "播放器", - "order": 4, + "order": 5, "action": { "type": "view", "path": "nekobox/video" @@ -47,7 +56,7 @@ "admin/services/nekobox/filekit": { "title": "文件助手", - "order": 5, + "order": 6, "action": { "type": "view", "path": "nekobox/filekit"