From 996e6727ff7620f68bfaf6bdcf472955b5da1ce5 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Sat, 10 Aug 2024 04:20:22 +0800 Subject: [PATCH] update 2024-08-10 04:20:22 --- .../resources/view/wizard/initsetup.js | 4 +- luci-app-wizard/po/zh_Hans/wizard.po | 3 ++ luci-app-wizard/root/etc/init.d/wizard | 41 ++++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/luci-app-wizard/htdocs/luci-static/resources/view/wizard/initsetup.js b/luci-app-wizard/htdocs/luci-static/resources/view/wizard/initsetup.js index 539a64f8f..1e4bb7236 100644 --- a/luci-app-wizard/htdocs/luci-static/resources/view/wizard/initsetup.js +++ b/luci-app-wizard/htdocs/luci-static/resources/view/wizard/initsetup.js @@ -99,7 +99,9 @@ return view.extend({ o = s.taboption('firmware', form.Flag, 'cookie_p', _('Persistent cookies'), _('Keep the background login state to avoid the need to log in again every time the browser is closed')); o.default = o.enabled; - + + o = s.taboption('firmware', form.Flag, 'https', _('Force the use of HTTPS in the backend.')); + if (data.istorex || data.routerdog){ o = s.taboption('firmware', form.ListValue, 'landing_page', _('主题模式')); o.value('default', _('默认')); diff --git a/luci-app-wizard/po/zh_Hans/wizard.po b/luci-app-wizard/po/zh_Hans/wizard.po index 319f0281b..470760bfc 100644 --- a/luci-app-wizard/po/zh_Hans/wizard.po +++ b/luci-app-wizard/po/zh_Hans/wizard.po @@ -70,3 +70,6 @@ msgstr "目标URL" msgid "Please enter a valid URL starting with http:// or https://" msgstr "URL需以http:// 或 https://开头" +msgid "Force the use of HTTPS in the backend." +msgstr "后台强制使用https" + diff --git a/luci-app-wizard/root/etc/init.d/wizard b/luci-app-wizard/root/etc/init.d/wizard index 8c5360876..040b53ca6 100644 --- a/luci-app-wizard/root/etc/init.d/wizard +++ b/luci-app-wizard/root/etc/init.d/wizard @@ -136,7 +136,9 @@ add_wizard() { uci commit wireless } fi - + + sethttps + uci commit wizard uci commit dhcp uci commit firewall @@ -165,6 +167,43 @@ uci -q set wizard.default.lan_dns="$(uci -q get network.lan.dns)" uci commit wizard } +sethttps() { + config_get https "$cfg" https + if [ -n "$(command -v nginx)" ]; then + if [ -z "`uci -q get nginx._redirect2ssl`" ]; then + uci -q set nginx._redirect2ssl=server + uci -q set nginx._redirect2ssl.server_name='_redirect2ssl' + uci -q set nginx._redirect2ssl.return='302 https://$host$request_uri' + uci -q set nginx._redirect2ssl.access_log='off; # logd openwrt' + fi + if [ "x${https}" = "x1" ] ; then + uci -q del nginx.default_server.listen + uci -q add_list nginx.default_server.listen='80' + uci -q add_list nginx.default_server.listen='[::]:80' + uci -q del nginx._redirect2ssl.listen + uci -q add_list nginx._redirect2ssl.listen='80 default_server' + uci -q add_list nginx._redirect2ssl.listen='[::]:80 default_server' + else + uci -q del nginx._redirect2ssl.listen + uci -q add_list nginx._redirect2ssl.listen='80' + uci -q add_list nginx._redirect2ssl.listen='[::]:80' + uci -q del nginx.default_server.listen + uci -q add_list nginx.default_server.listen='80 default_server' + uci -q add_list nginx.default_server.listen='[::]:80 default_server' + fi + uci commit nginx + /etc/init.d/nginx reload + else + if [ "x${https}" = "x1" ] ; then + uci -q set uhttpd.main.redirect_https='1' + else + uci -q set uhttpd.main.redirect_https='0' + fi + uci commit uhttpd + /etc/init.d/uhttpd reload + fi +} + process_shortcut() { local shortcut to_url comments lanaddr local cfg="$1"