diff --git a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash b/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash
index f580662776..a6ba8c93a7 100755
--- a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash
+++ b/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash
@@ -954,7 +954,7 @@ EOF
echo "" >$START_LOG
else
if [ "$rule_source" != 0 ] || [ "$enable_custom_clash_rules" != 0 ]; then
- echo "错误: OpenClash 启动失败,尝试还原规则并重新启动 Clash 主程序..." >$START_LOG
+ echo "错误: OpenClash 启动失败,尝试还原第三方规则并重新启动 Clash 主程序..." >$START_LOG
echo "${LOGTIME} OpenClash Can Not Start, Try Use Backup Rules Start Again" >> $LOG_FILE
mv "$START_BACKUP" /etc/openclash/configrules.bak
sed -i -n '/^Rule:/,$p' /etc/openclash/configrules.bak
diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/game-rules-manage.lua b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/game-rules-manage.lua
index 9c84eb9995..58d3f59eff 100644
--- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/game-rules-manage.lua
+++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/game-rules-manage.lua
@@ -68,6 +68,7 @@ form.submit=false
tb=form:section(Table,e)
nu=tb:option(DummyValue,"num",translate("Order Number"))
st=tb:option(DummyValue,"exist",translate("State"))
+st.template="openclash/cfg_check"
nm=tb:option(DummyValue,"name",translate("Rule Name"))
fm=tb:option(DummyValue,"filename",translate("File Name"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/servers-config.lua b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/servers-config.lua
index 81022fe010..27af4fef39 100644
--- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/servers-config.lua
+++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/servers-config.lua
@@ -166,32 +166,6 @@ o:value("websocket", translate("websocket (ws)"))
o:value("http", translate("http"))
o:depends("type", "vmess")
--- [[ skip-cert-verify ]]--
-o = s:option(ListValue, "skip_cert_verify", translate("skip-cert-verify"))
-o.rmempty = true
-o.default = "false"
-o:value("true")
-o:value("false")
-o:depends("obfs", "websocket")
-o:depends("obfs_vmess", "none")
-o:depends("obfs_vmess", "websocket")
-o:depends("type", "socks5")
-o:depends("type", "http")
-o:depends("type", "trojan")
-
--- [[ TLS ]]--
-o = s:option(ListValue, "tls", translate("TLS"))
-o.rmempty = true
-o.default = "false"
-o:value("true")
-o:value("false")
-o:depends("obfs", "websocket")
-o:depends("obfs_vmess", "none")
-o:depends("obfs_vmess", "websocket")
-o:depends("obfs_vmess", "http")
-o:depends("type", "socks5")
-o:depends("type", "http")
-
o = s:option(Value, "host", translate("obfs-hosts"))
o.datatype = "host"
o.rmempty = true
@@ -218,6 +192,32 @@ o.rmempty = true
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "websocket")
+-- [[ skip-cert-verify ]]--
+o = s:option(ListValue, "skip_cert_verify", translate("skip-cert-verify"))
+o.rmempty = true
+o.default = "false"
+o:value("true")
+o:value("false")
+o:depends("obfs", "websocket")
+o:depends("obfs_vmess", "none")
+o:depends("obfs_vmess", "websocket")
+o:depends("type", "socks5")
+o:depends("type", "http")
+o:depends("type", "trojan")
+
+-- [[ TLS ]]--
+o = s:option(ListValue, "tls", translate("TLS"))
+o.rmempty = true
+o.default = "false"
+o:value("true")
+o:value("false")
+o:depends("obfs", "websocket")
+o:depends("obfs_vmess", "none")
+o:depends("obfs_vmess", "websocket")
+o:depends("obfs_vmess", "http")
+o:depends("type", "socks5")
+o:depends("type", "http")
+
o = s:option(Value, "keep_alive", translate("keep-alive"))
o.rmempty = true
o.default = "true"
diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/cfg_check.htm b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/cfg_check.htm
index c4852695a9..504f125d4b 100644
--- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/cfg_check.htm
+++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/cfg_check.htm
@@ -2,7 +2,7 @@
<%
local val = self:cfgvalue(section)
- if val == "启用" or val == "Enable" or val == "检查通过" or val == "Config Normal" then
+ if val == "启用" or val == "Enable" or val == "检查通过" or val == "Config Normal" or val == "Exist" or val == "已下载" then
%>
<%
diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh
index e1a169055b..479a6410fc 100755
--- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh
+++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh
@@ -60,6 +60,7 @@ config_cus_up()
sleep 3
echo "" >$START_LOG
fi
+ rm -rf /tmp/Proxy_Group 2>/dev/null
}
config_su_check()
diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_get.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_get.sh
index 680ebbb0c5..a63d086436 100755
--- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_get.sh
+++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_get.sh
@@ -55,8 +55,28 @@ else
awk '/Proxy Group:/,/Rule:/{print}' "$CONFIG_FILE" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\t/ /g' 2>/dev/null >/tmp/yaml_group.yaml 2>&1
fi 2>/dev/null
-if [ "$servers_update" -ne "1" ] || [ "$servers_if_update" != "1" ] || [ -z "$(grep "config groups" "$CFG_FILE" 2>/dev/null)" ]; then
-echo "正在删除旧配置..." >$START_LOG
+#判断当前配置文件是否已经有策略组信息
+cfg_group_name()
+{
+ local section="$1"
+ config_get "config" "$section" "config" ""
+
+ if [ -z "$config" ]; then
+ return
+ fi
+
+ [ "$config" = "$CONFIG_NAME" ] && {
+ config_group_exist="1"
+ }
+}
+
+config_load "openclash"
+config_foreach cfg_group_name "groups"
+
+#删除不必要的配置
+cfg_delete()
+{
+ echo "正在删除旧配置..." >$START_LOG
#删除策略组
group_num=$(grep "config groups" "$CFG_FILE" |wc -l)
for ((i=$group_num;i>=0;i--))
@@ -66,7 +86,7 @@ echo "正在删除旧配置..." >$START_LOG
uci commit openclash
fi
done
-#删除启用节点
+#删除启用的节点
server_num=$(grep "config servers" "$CFG_FILE" |wc -l)
for ((i=$server_num;i>=0;i--))
do
@@ -77,7 +97,7 @@ echo "正在删除旧配置..." >$START_LOG
fi
fi
done
-#删除启用代理集
+#删除启用的代理集
provider_num=$(grep "config proxy-provider" "$CFG_FILE" 2>/dev/null |wc -l)
for ((i=$provider_num;i>=0;i--))
do
@@ -88,6 +108,10 @@ echo "正在删除旧配置..." >$START_LOG
fi
fi
done
+}
+
+if [ "$servers_update" -ne "1" ] || [ "$servers_if_update" != "1" ] || [ -z "$config_group_exist" ]; then
+ cfg_delete
else
/usr/share/openclash/yml_proxys_get.sh
exit 0
diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh
index b3df04e8b4..b0c7e0c542 100755
--- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh
+++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh
@@ -93,6 +93,43 @@ cfg_get_dynamic()
echo "$(grep "^ \{0,\}$1" "$2" 2>/dev/null |grep -v "^ \{0,\}- name:" |grep -v "^ \{0,\}- keep-alive" |awk -v tag=$1 'BEGIN{FS=tag} {print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/\}.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null)"
}
+cfg_new_servers_groups_check()
+{
+ if [ -z "$1" ]; then
+ return
+ fi
+
+ [ "$1" = "$2" ] && {
+ config_group_exist="1"
+ }
+}
+
+cfg_group_name()
+{
+ local section="$1"
+ config_get "name" "$section" "name" ""
+ config_get "config" "$section" "config" ""
+
+ if [ -z "$config" ]; then
+ return
+ fi
+
+ if [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then
+ return
+ fi
+
+ if [ -z "$name" ]; then
+ return
+ fi
+
+ config_list_foreach "config" "new_servers_group" cfg_new_servers_groups_check "$name"
+
+}
+
+#判断当前配置文件策略组信息是否包含指定策略组
+config_load "openclash"
+config_foreach cfg_group_name "groups"
+
echo "开始更新【$CONFIG_NAME】的代理集配置..." >$START_LOG
yml_provider_name_get()
@@ -218,7 +255,7 @@ do
#加入策略组
- if [ "$servers_if_update" = "1" ] && [ ! -z "$new_servers_group" ] && [ ! -z "$(grep "config groups" "$CFG_FILE")" ]; then
+ if [ "$servers_if_update" = "1" ] && [ ! -z "$new_servers_group" ] && [ ! -z "$config_group_exist" ]; then
#新代理集且设置默认策略组时加入指定策略组
config_load "openclash"
config_list_foreach "config" "new_servers_group" cfg_new_provider_groups_get
@@ -381,7 +418,7 @@ cfg_new_servers_groups_get()
${uci_add}groups="${1}"
}
-
+
echo "开始更新【$CONFIG_NAME】的服务器节点配置..." >$START_LOG
[ "$servers_update" -eq "1" ] && {
@@ -643,7 +680,7 @@ do
fi
#加入策略组
- if [ "$servers_if_update" = "1" ] && [ ! -z "$new_servers_group" ] && [ ! -z "$(grep "config groups" "$CFG_FILE")" ]; then
+ if [ "$servers_if_update" = "1" ] && [ ! -z "$new_servers_group" ] && [ ! -z "$config_group_exist" ]; then
#新节点且设置默认策略组时加入指定策略组
config_load "openclash"
config_list_foreach "config" "new_servers_group" cfg_new_servers_groups_get
diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_rules_change.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_rules_change.sh
index 9e87e92678..95f32cfeb4 100755
--- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_rules_change.sh
+++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_rules_change.sh
@@ -157,20 +157,6 @@ fi
sed -i '/- DOMAIN-KEYWORD,announce,DIRECT/d' "$4" 2>/dev/null
sed -i '/- DOMAIN-KEYWORD,torrent,DIRECT/d' "$4" 2>/dev/null
- if [ "$3" = 1 ]; then
- sed -i '/^Rule:/a\##Custom Rules End##' "$4" 2>/dev/null
- sed -i '/^Rule:/a\##Custom Rules##' "$4" 2>/dev/null
- sed -i '/^##Custom Rules##/r/etc/openclash/custom/openclash_custom_rules.list' "$4" 2>/dev/null
- sed -i '/^ \{0,\}- MATCH,/i\##Custom Rules 2##' "$4" 2>/dev/null
- sed -i '/^##Custom Rules 2##/a\##Custom Rules 2 End##' "$4" 2>/dev/null
- sed -i '/^##Custom Rules 2##/r/etc/openclash/custom/openclash_custom_rules_2.list' "$4" 2>/dev/null
- fi
-
- if [ "$5" = 1 ] || [ "$3" = 1 ] || [ "$7" = 1 ] || [ -z "$(grep '- IP-CIDR,198.18.0.1/16,REJECT,no-resolve' "$4")" ]; then
- sed -i "s/^ \{0,\}-/-/" "$4" 2>/dev/null #修改参数空格
- sed -i "s/^\t\{0,\}-/-/" "$4" 2>/dev/null #修改参数tab
- fi
-
if [ -z "$(grep '- IP-CIDR,198.18.0.1/16,REJECT,no-resolve' "$4")" ] && [ "$6" = "fake-ip" ]; then
if [ ! -z "$(grep "^ \{0,\}- IP-CIDR,198.18.0.1/16" "$4")" ]; then
sed -i "/^ \{0,\}- IP-CIDR,198.18.0.1\/16/c\- IP-CIDR,198.18.0.1\/16,REJECT,no-resolve" "$4"
@@ -196,4 +182,18 @@ fi
sed -i "s/###- MATCH,/- MATCH,/" "$4" 2>/dev/null
sed -i "s/###- FINAL,/- FINAL,/" "$4" 2>/dev/null
fi
+ fi
+
+ if [ "$3" = 1 ]; then
+ sed -i '/^Rule:/a\##Custom Rules End##' "$4" 2>/dev/null
+ sed -i '/^Rule:/a\##Custom Rules##' "$4" 2>/dev/null
+ sed -i '/^##Custom Rules##/r/etc/openclash/custom/openclash_custom_rules.list' "$4" 2>/dev/null
+ sed -i '/^ \{0,\}- MATCH,/i\##Custom Rules 2##' "$4" 2>/dev/null
+ sed -i '/^##Custom Rules 2##/a\##Custom Rules 2 End##' "$4" 2>/dev/null
+ sed -i '/^##Custom Rules 2##/r/etc/openclash/custom/openclash_custom_rules_2.list' "$4" 2>/dev/null
+ fi
+
+ if [ "$5" = 1 ] || [ "$3" = 1 ] || [ "$7" = 1 ] || [ -z "$(grep '- IP-CIDR,198.18.0.1/16,REJECT,no-resolve' "$4")" ]; then
+ sed -i "s/^ \{0,\}-/-/" "$4" 2>/dev/null #修改参数空格
+ sed -i "s/^\t\{0,\}-/-/" "$4" 2>/dev/null #修改参数tab
fi
\ No newline at end of file
diff --git a/package/ctcgfw/luci-app-openclash/i18n/zh-cn/openclash.zh-cn.po b/package/ctcgfw/luci-app-openclash/i18n/zh-cn/openclash.zh-cn.po
index fc15b89e26..4091877db5 100644
--- a/package/ctcgfw/luci-app-openclash/i18n/zh-cn/openclash.zh-cn.po
+++ b/package/ctcgfw/luci-app-openclash/i18n/zh-cn/openclash.zh-cn.po
@@ -6,7 +6,7 @@ msgid "OpenClash"
msgstr "OpenClash"
msgid "A Clash Client For OpenWrt"
-msgstr "一个运行在OpenWrt上的Clash客户端,兼容Shadowsocks、Vmess、trojan、Snell等协议,根据灵活的规则配置实现策略代理"
+msgstr "一个运行在OpenWrt上的Clash客户端,兼容Shadowsocks、Vmess、Trojan、Snell等协议,根据灵活的规则配置实现策略代理"
msgid "Global Settings(Will Modify The Config File Or Subscribe According To The Settings On This Page)"
msgstr "全局设置(将按照本页设置自动修改配置文件和获取订阅)"