From 253317ffd7f17d0e9e0287c3d20470f939efcf80 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:25:11 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Sync=202024-09-24=2022:25:11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luci-static/resources/view/wifidogx.js | 71 +++++++++++++++---- .../po/zh_Hans/apfree-wifidog.po | 55 +++++++++++++- luci-app-nekoclash/Makefile | 2 +- luci-app-nekoclash/htdocs/nekoclash/index.php | 38 +++++++++- 4 files changed, 146 insertions(+), 20 deletions(-) diff --git a/luci-app-apfree-wifidog/htdocs/luci-static/resources/view/wifidogx.js b/luci-app-apfree-wifidog/htdocs/luci-static/resources/view/wifidogx.js index a27493ad5..0c0a2f33e 100644 --- a/luci-app-apfree-wifidog/htdocs/luci-static/resources/view/wifidogx.js +++ b/luci-app-apfree-wifidog/htdocs/luci-static/resources/view/wifidogx.js @@ -61,58 +61,62 @@ return view.extend({ o = s.taboption('basic', form.Flag, 'enabled', _('Enable'), _('Enable apfree-wifidog service.')); o.rmempty = false; - o = s.taboption('basic', form.Flag, 'no_auth_server', _('No Auth Server'), _('Do not use authentication server.')); - o.rmempty = false; + o = s.taboption('basic', form.ListValue, 'auth_server_mode', _('Auth Server Mode'), + _('The mode of the authentication server.')); + o.value('cloud', _('Cloud Auth')); + o.value('local', _('Local Auth')); + o.defaulValue = 'cloud'; + o.optional = false; o = s.taboption('basic', form.Value, 'device_id', _('Device ID'), _('The ID of the device.')); - o.depends('no_auth_server', '0'); o.rmempty = false; o.datatype = 'string'; o.optional = false; + o.depends('auth_server_mode', 'cloud'); o = s.taboption('basic', form.Value, 'auth_server_hostname', _('Auth Server Hostname'), _('The domain or IP address of the authentication server.')); - o.depends('no_auth_server', '0'); o.rmempty = false; o.datatype = 'or(host,ip4addr)'; o.optional = false; + o.depends('auth_server_mode', 'cloud'); o = s.taboption('basic', form.Value, 'auth_server_port', _('Auth Server Port'), _('The port of the authentication server.')); - o.depends('no_auth_server', '0'); o.rmempty = false; o.datatype = 'port'; o.optional = false; + o.depends('auth_server_mode', 'cloud'); o = s.taboption('basic', form.Value, 'auth_server_path', _('Auth Server URI path'), _('The URI path of the authentication server.')); - o.depends('no_auth_server', '0'); o.rmempty = false; o.datatype = 'string'; o.optional = false; + o.depends('auth_server_mode', 'cloud'); o = s.taboption('basic', form.FileUpload, 'auth_server_offline_page', _('Upload offline Page'), _('The offline page of the authentication server.')); - o.depends('no_auth_server', '1'); o.rmempty = false; o.optional = true o.datatype = 'file'; o.root_directory = '/etc/wifidogx'; + o.depends('auth_server_mode', 'local'); o = s.taboption('basic', form.Value, 'auth_server_offline_file', _('Offline Page Full Path'), _('The full path of the uploaded offline page.')); - o.depends('no_auth_server', '1'); o.rmempty = false; o.datatype = 'string'; o.optional = true; o.placeholder = '/etc/wifidogx/'; + o.depends('auth_server_mode', 'local'); o = s.taboption('basic', form.Value, 'local_portal', _('Local Portal'), _('The local portal url.')); - o.depends('no_auth_server', '1'); o.rmempty = false; o.datatype = 'string'; o.optional = true; + o.depends('auth_server_mode', 'local'); o = s.taboption('basic', form.ListValue, 'log_level', _('Log Level'), _('The log level of the apfree-wifidog.')); @@ -157,31 +161,68 @@ return view.extend({ // advanced settings - o = s.taboption('advanced', form.Flag, 'enable_websocket', _('Enable WebSocket'), - _('Enable websocket support.')); + o = s.taboption('advanced', form.ListValue, 'long_conn_mode', _('Persistent Connection Mode'), + _('The persistent connection mode of the device to auth server.')); + o.value('ws', _('WebSocket Connection Mode')); + o.value('wss', _('WebSocket Secure Connection Mode')); + o.value('mqtt', _('MQTT Connection Mode')); + o.value('none', _('None')); o.rmempty = false; - o.defaulValue = true; + o.defaulValue = 'ws'; + o.optional = false; o = s.taboption('advanced', form.Value, 'ws_server_hostname', _('WebSocket Hostname'), _('The hostname of the websocket, if the field is left empty, automatically use the same hostname as the auth server.')); o.datatype = 'or(host,ip4addr)'; o.rmempty = true; o.optional = true; - o.depends('enable_websocket', '1'); + o.depends('long_conn_mode', 'ws'); + o.depends('long_conn_mode', 'wss'); o = s.taboption('advanced', form.Value, 'ws_server_port', _('WebSocket Port'), _('The port of the websocket, if the field is left empty, automatically use the same port as the auth server.')); o.datatype = 'port'; o.rmempty = true; - o.depends('enable_websocket', '1'); o.optional = true; + o.depends('long_conn_mode', 'ws'); + o.depends('long_conn_mode', 'wss'); o = s.taboption('advanced', form.Value, 'ws_server_path', _('WebSocket URI path'), _('The URI path of the websocket.')); o.datatype = 'string'; o.rmempty = true; - o.depends('enable_websocket', '1'); o.optional = true; + o.depends('long_conn_mode', 'ws'); + o.depends('long_conn_mode', 'wss'); + + o = s.taboption('advanced', form.Value, 'mqtt_server_hostname', _('MQTT Hostname'), + _('The hostname of the mqtt.')); + o.datatype = 'or(host,ip4addr)'; + o.rmempty = true; + o.optional = true; + o.depends('long_conn_mode', 'mqtt'); + + o = s.taboption('advanced', form.Value, 'mqtt_server_port', _('MQTT Port'), + _('The port of the mqtt.')); + o.datatype = 'port'; + o.rmempty = false; + o.optional = false; + o.depends('long_conn_mode', 'mqtt'); + o.defaulValue = 1883; + + o = s.taboption('advanced', form.Value, 'mqtt_username', _('MQTT Username'), + _('The username of the mqtt.')); + o.datatype = 'string'; + o.rmempty = true; + o.optional = true; + o.depends('long_conn_mode', 'mqtt'); + + o = s.taboption('advanced', form.Value, 'mqtt_password', _('MQTT Password'), + _('The password of the mqtt.')); + o.datatype = 'string'; + o.rmempty = true; + o.optional = true; + o.depends('long_conn_mode', 'mqtt'); o = s.taboption('advanced', form.Flag, 'enable_dns_forward', _('Enable Wildcard Domain'), _('Enable wildcard domain support.')); diff --git a/luci-app-apfree-wifidog/po/zh_Hans/apfree-wifidog.po b/luci-app-apfree-wifidog/po/zh_Hans/apfree-wifidog.po index 8c9e23e10..d93232491 100644 --- a/luci-app-apfree-wifidog/po/zh_Hans/apfree-wifidog.po +++ b/luci-app-apfree-wifidog/po/zh_Hans/apfree-wifidog.po @@ -262,4 +262,57 @@ msgid "WebSocket URI path" msgstr "Websocket URI 路径" msgid "The URI path of the websocket." -msgstr "Websocket 的 URI 路径" \ No newline at end of file +msgstr "Websocket 的 URI 路径" + +msgid "Auth Server Mode" +msgstr "认证服务器模式" + +msgid "The mode of the authentication server." +msgstr "认证服务器是云认证还是本地认证" + +msgid "Cloud Auth" +msgstr "云认证" + +msgid "Local Auth" +msgstr "本地认证" + +msgid "Persistent Connection Mode" +msgstr "持久连接模式" + +msgid "The persistent connection mode of the device to auth server." +msgstr "设备到认证服务器的持久连接模式" + +msgid "WebSocket Connection Mode" +msgstr "Websocket 连接模式" + +msgid "WebSocket Secure Connection Mode" +msgstr "Websocket 安全连接模式" + +msgid "MQTT Connection Mode" +msgstr "MQTT 连接模式" + +msgid "MQTT Hostname" +msgstr "MQTT 主机名" + +msgid "The hostname of the mqtt." +msgstr "mqtt 的主机名" + +msgid "MQTT Port" +msgstr "MQTT 端口" + +msgid "The port of the mqtt." +msgstr "mqtt 的端口" + +msgid "MQTT Username" +msgstr "MQTT 用户名" + +msgid "The username of the mqtt." +msgstr "mqtt 的用户名" + +msgid "MQTT Password" +msgstr "MQTT 密码" + +msgid "The password of the mqtt." +msgstr "mqtt 的密码" + + diff --git a/luci-app-nekoclash/Makefile b/luci-app-nekoclash/Makefile index 6314e22bb..39c44219d 100644 --- a/luci-app-nekoclash/Makefile +++ b/luci-app-nekoclash/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_MAINTAINER:=Thaolga PKG_NAME:=luci-app-nekoclash PKG_VERSION:=1.3.5 -PKG_RELEASE:=47 +PKG_RELEASE:=48 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) diff --git a/luci-app-nekoclash/htdocs/nekoclash/index.php b/luci-app-nekoclash/htdocs/nekoclash/index.php index f82512365..d82f12f60 100644 --- a/luci-app-nekoclash/htdocs/nekoclash/index.php +++ b/luci-app-nekoclash/htdocs/nekoclash/index.php @@ -313,6 +313,7 @@ $lang = $_GET['lang'] ?? 'en'; > /etc/neko/tmp/log.txt +else + echo "[\$(date '+%H:%M:%S')] Firewall restart failed." >> /etc/neko/tmp/log.txt +fi +EOF; + + $result = file_put_contents($scriptPath, $scriptContent); + if ($result === false) { + error_log("Failed to create script at $scriptPath"); + } else { + chmod($scriptPath, 0755); + } +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (isset($_POST['singbox'])) { + if ($_POST['singbox'] === 'start') { + createRestartFirewallScript(); + } + } +} + function rotateLogFile($filePath) { $backupPath = $filePath . '-' . date('Y-m-d-H-i-s') . '.bak'; rename($filePath, $backupPath); @@ -558,19 +588,20 @@ function stopSingbox() { if ($returnVar !== 0) { exec("kill -9 $pid", $output, $returnVar); } - exec("service firewall restart", $output, $returnVar); + exec('/etc/neko/core/restart_firewall.sh', $output, $returnVar); if ($returnVar === 0) { - logToFile('/etc/neko/tmp/log.txt', "防火墙重启成功。"); + logToFile('/etc/neko/tmp/log.txt', "Restarting Firewall."); return true; } else { - logToFile('/etc/neko/tmp/log.txt', "防火墙重启失败。"); + logToFile('/etc/neko/tmp/log.txt', "Firewall restart failed."); error_log("Failed to stop Sing-box with PID $pid"); } } return false; } + function logToFile($filePath, $message) { $timestamp = date('H:i:s'); file_put_contents($filePath, "[$timestamp] $message\n", FILE_APPEND); @@ -619,6 +650,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { applyFirewallRules(); createStartScript($configFile); exec("/etc/neko/core/start.sh > $singBoxLogFile 2>&1 &", $output, $returnVar); + exec('/etc/neko/core/restart_firewall.sh', $output, $returnVar); $version = getSingboxVersion(); $pid = getSingboxPID(); $logMessage = $returnVar === 0