From 1bdfedba565f8d4f4cf0ad820ef1c290f9fea2a2 Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Fri, 2 Aug 2019 23:44:54 +0800 Subject: [PATCH] luci-app-clash: sync source --- package/jsda/luci-app-clash/Makefile | 13 +- .../luasrc/model/cbi/clash/client.lua | 39 ++++-- .../luasrc/model/cbi/clash/config.lua | 2 +- .../luasrc/model/cbi/clash/dns.lua | 1 + .../luasrc/model/cbi/clash/log.lua | 1 + .../luasrc/model/cbi/clash/port.lua | 2 +- package/jsda/luci-app-clash/po/zh-cn/clash.po | 16 ++- .../jsda/luci-app-clash/root/etc/config/clash | 2 +- .../jsda/luci-app-clash/root/etc/init.d/clash | 120 +++++++++--------- .../root/usr/share/clash/clash.sh | 40 ++++-- .../root/usr/share/clash/clash_version | 2 +- 11 files changed, 141 insertions(+), 97 deletions(-) diff --git a/package/jsda/luci-app-clash/Makefile b/package/jsda/luci-app-clash/Makefile index 9810bef4c1..2ad45f06c6 100644 --- a/package/jsda/luci-app-clash/Makefile +++ b/package/jsda/luci-app-clash/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-clash -PKG_VERSION:=0.30.0 +PKG_VERSION:=0.31.0 PKG_RELEASE:=1 PKG_MAINTAINER:=frainzy1477 @@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/package.mk define Package/luci-app-clash SECTION:=luci CATEGORY:=LuCI - SUBMENU:=3. Applications + SUBMENU:=2. Services TITLE:=LuCI app for clash DEPENDS:=+bash +coreutils-nohup +wget PKGARCH:=all @@ -38,18 +38,14 @@ define Build/Compile endef define Package/$(PKG_NAME)/install - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash $(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/clash $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n - $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/clash - $(INSTALL_DIR) $(1)/www - $(INSTALL_DIR) $(1)/usr/share/clash $(INSTALL_DIR) $(1)/usr/share/clash/web $(INSTALL_DIR) $(1)/usr/share/clash/dashboard @@ -68,8 +64,8 @@ define Package/$(PKG_NAME)/install $(INSTALL_BIN) ./root/usr/share/clash/clash_version $(1)/usr/share/clash/ $(INSTALL_BIN) ./root/usr/share/clash/check_version.sh $(1)/usr/share/clash/ - $(INSTALL_BIN) ./root/usr/share/clash/web/* $(1)/usr/share/clash/web + $(INSTALL_BIN) ./root/usr/share/clash/web/* $(1)/usr/share/clash/web $(INSTALL_BIN) ./root/usr/share/clash/dashboard/index.html $(1)/usr/share/clash/dashboard/ $(INSTALL_BIN) ./root/usr/share/clash/dashboard/main.d32d2df9dcc55f57282d.css $(1)/usr/share/clash/dashboard/ $(INSTALL_BIN) ./root/usr/share/clash/dashboard/img/33343e6117c37aaef8886179007ba6b5.png $(1)/usr/share/clash/dashboard/img/ @@ -78,11 +74,8 @@ define Package/$(PKG_NAME)/install $(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/bundle.d32d2df9dcc55f57282d.min.js $(1)/usr/share/clash/dashboard/js/ $(INSTALL_DATA) ./luasrc/controller/*.lua $(1)/usr/lib/lua/luci/controller/ - $(INSTALL_DATA) ./luasrc/model/cbi/clash/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/ - $(INSTALL_DATA) ./luasrc/view/clash/* $(1)/usr/lib/lua/luci/view/clash/ - $(INSTALL_DATA) ./po/zh-cn/clash.zh-cn.lmo $(1)/usr/lib/lua/luci/i18n/ endef diff --git a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/client.lua b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/client.lua index 3dd26112c3..dfe08073c7 100644 --- a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/client.lua +++ b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/client.lua @@ -3,20 +3,17 @@ local SYS = require "luci.sys" local HTTP = require "luci.http" local DISP = require "luci.dispatcher" local UTIL = require "luci.util" +local uci = require("luci.model.uci").cursor() +ful = Form("upload", nil) +ful.reset = false +ful.submit = false m = Map("clash") s = m:section(TypedSection, "clash") s.anonymous = true -o = s:option( Flag, "enable") -o.title = translate("Enable") -o.default = 0 -o.rmempty = false -o.description = translate("Enable Client") - - o = s:option(Flag, "auto_update", translate("Auto Update")) o.rmempty = false o.description = translate("Auto Update Server subscription") @@ -46,8 +43,11 @@ o.rmempty = true o = s:option(Button,"update") o.title = translate("Update Subcription") o.inputtitle = translate("Update") +o.description = translate("Update Config") o.inputstyle = "reload" o.write = function() + os.execute("sed -i '/enable/d' /etc/config/clash") + uci:commit("clash") os.execute("mv /etc/clash/config.yaml /etc/clash/config.bak") os.execute("rm -rf /tmp/clash.log") SYS.call("bash /usr/share/clash/clash.sh >>/tmp/clash.log 2>&1 &") @@ -55,11 +55,28 @@ o.write = function() end -local apply = luci.http.formvalue("cbi.apply") -if apply then - SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &") +o = s:option(Button,"enable") +o.title = translate("Start Client") +o.inputtitle = translate("Start Client") +o.description = translate("Enable/Start/Restart Client") +o.inputstyle = "apply" +o.write = function() + uci:set("clash", "config", "enable", 1) + uci:commit("clash") + SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &") end -return m +o = s:option(Button,"disable") +o.title = translate("Stop Client") +o.inputtitle = translate("Stop Client") +o.description = translate("Disable/Stop Client") +o.inputstyle = "reset" +o.write = function() + uci:set("clash", "config", "enable", 0) + uci:commit("clash") + SYS.call("/etc/init.d/clash stop >/dev/null 2>&1 &") +end + +return m, ful diff --git a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/config.lua b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/config.lua index 27cd3c8060..ddf3d0f317 100644 --- a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/config.lua +++ b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/config.lua @@ -4,7 +4,7 @@ local SYS = require "luci.sys" local HTTP = require "luci.http" local DISP = require "luci.dispatcher" local UTIL = require "luci.util" - +local uci = require("luci.model.uci").cursor() local http = luci.http diff --git a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/dns.lua b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/dns.lua index 4ba33ef6ca..5b8012b7c1 100644 --- a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/dns.lua +++ b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/dns.lua @@ -4,6 +4,7 @@ local SYS = require "luci.sys" local HTTP = require "luci.http" local DISP = require "luci.dispatcher" local UTIL = require "luci.util" +local uci = require("luci.model.uci").cursor() m = Map("clash") s = m:section(TypedSection, "clash") diff --git a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/log.lua b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/log.lua index 5bbe9c0c16..a9514f5e47 100644 --- a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/log.lua +++ b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/log.lua @@ -4,6 +4,7 @@ local SYS = require "luci.sys" local HTTP = require "luci.http" local DISP = require "luci.dispatcher" local UTIL = require "luci.util" +local uci = require("luci.model.uci").cursor() ful = Form("upload", nil) ful.reset = false diff --git a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/port.lua b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/port.lua index 2e412fe7b9..441569cf05 100644 --- a/package/jsda/luci-app-clash/luasrc/model/cbi/clash/port.lua +++ b/package/jsda/luci-app-clash/luasrc/model/cbi/clash/port.lua @@ -3,7 +3,7 @@ local SYS = require "luci.sys" local HTTP = require "luci.http" local DISP = require "luci.dispatcher" local UTIL = require "luci.util" - +local uci = require("luci.model.uci").cursor() m = Map("clash") s = m:section(TypedSection, "clash") diff --git a/package/jsda/luci-app-clash/po/zh-cn/clash.po b/package/jsda/luci-app-clash/po/zh-cn/clash.po index 8c7e85a53e..9b8479d354 100644 --- a/package/jsda/luci-app-clash/po/zh-cn/clash.po +++ b/package/jsda/luci-app-clash/po/zh-cn/clash.po @@ -1,3 +1,17 @@ +msgid "Update Config" +msgstr "更新配置" + +msgid "Enable/Start/Restart Client" +msgstr "启用/启动/重新启动客户端" + +msgid "Disable/Stop Client" +msgstr "禁用/停止客户端" + +msgid "Stop Client" +msgstr "停用客户端" + +msgid "Start Client" +msgstr "启用客户端" msgid "enabled" msgstr "启用" @@ -231,4 +245,4 @@ msgid "Server Subscription Address" msgstr "服务器订阅地址" msgid "Changes to config file must be made from source" -msgstr "必须从源文件更改配置文件" \ No newline at end of file +msgstr "必须从源文件更改配置文件" diff --git a/package/jsda/luci-app-clash/root/etc/config/clash b/package/jsda/luci-app-clash/root/etc/config/clash index 1caf617b19..d8d4148e2f 100644 --- a/package/jsda/luci-app-clash/root/etc/config/clash +++ b/package/jsda/luci-app-clash/root/etc/config/clash @@ -2,8 +2,8 @@ config clash 'config' option redir_port '7892' option http_port '7890' option socks_port '7891' - option enable '0' option mode '0' + option enable '0' option dash_port '9191' option dash_pass '123456' option auto_update '0' diff --git a/package/jsda/luci-app-clash/root/etc/init.d/clash b/package/jsda/luci-app-clash/root/etc/init.d/clash index ef47bb26c6..10b30e15cd 100755 --- a/package/jsda/luci-app-clash/root/etc/init.d/clash +++ b/package/jsda/luci-app-clash/root/etc/init.d/clash @@ -3,9 +3,13 @@ START=99 STOP=15 + CLASH="/etc/clash/clash" CLASH_CONFIG="/etc/clash" CRON_FILE="/etc/crontabs/root" +CONFIG_YAML="/etc/clash/config.yaml" +CONFIG_YAML_OLD="/etc/clash/config.yml" + revert_dns() { #=========================================================================================================================== @@ -27,7 +31,6 @@ add_cron(){ auto=$(uci get clash.config.auto_update 2>/dev/null) if [ $auto -eq 1 ]; then [ -z "$(grep -w "/usr/share/clash/clash.sh" $CRON_FILE)" ] && echo "0 $(uci get clash.config.auto_update_time 2>/dev/null) * * * /usr/share/clash/clash.sh" >> $CRON_FILE - [ -z "$(grep -w "/etc/init.d/clash" $CRON_FILE)" ] && echo "05 0 * * * /etc/init.d/clash restart" >> $CRON_FILE fi crontab $CRON_FILE #=========================================================================================================================== @@ -54,52 +57,52 @@ yml_change(){ subtype=$(uci get clash.config.subcri 2>/dev/null) if [ $mode -eq 1 ]; then - sed -i "/Proxy:/i\#clash-openwrt" /etc/clash/config.yaml - sed -i "/#clash-openwrt/a\#=============" /etc/clash/config.yaml - sed -i "/#=============/a\ " /etc/clash/config.yaml - sed -i '1,/#clash-openwrt/d' /etc/clash/config.yaml + sed -i "/Proxy:/i\#clash-openwrt" $CONFIG_YAML + sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML + sed -i "/#=============/a\ " $CONFIG_YAML + sed -i '1,/#clash-openwrt/d' $CONFIG_YAML mv /etc/clash/config.yaml /etc/clash/dns.yaml - cat /usr/share/clash/dns.yaml /etc/clash/dns.yaml > /etc/clash/config.yaml + cat /usr/share/clash/dns.yaml /etc/clash/dns.yaml > $CONFIG_YAML rm -rf /etc/clash/dns.yaml - sed -i "1i\port: ${http_port}" /etc/clash/config.yaml - sed -i "2i\socks-port: ${socks_port}" /etc/clash/config.yaml - sed -i "3i\redir-port: ${redir_port}" /etc/clash/config.yaml - sed -i "4i\allow-lan: true" /etc/clash/config.yaml - sed -i "5i\mode: Rule" /etc/clash/config.yaml - sed -i "6i\log-level: ${log_level}" /etc/clash/config.yaml - sed -i "7i\external-controller: 0.0.0.0:${dash_port}" /etc/clash/config.yaml - sed -i "8i\secret: '${da_password}'" /etc/clash/config.yaml - sed -i "9i\external-ui: "/usr/share/clash/dashboard"" /etc/clash/config.yaml - sed -i "10i\ " /etc/clash/config.yaml - sed -i "11i\ " /etc/clash/config.yaml - sed -i '/#=============/ d' /etc/clash/config.yaml + sed -i "1i\port: ${http_port}" $CONFIG_YAML + sed -i "2i\socks-port: ${socks_port}" $CONFIG_YAML + sed -i "3i\redir-port: ${redir_port}" $CONFIG_YAML + sed -i "4i\allow-lan: true" $CONFIG_YAML + sed -i "5i\mode: Rule" $CONFIG_YAML + sed -i "6i\log-level: ${log_level}" $CONFIG_YAML + sed -i "7i\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML + sed -i "8i\secret: '${da_password}'" $CONFIG_YAML + sed -i "9i\external-ui: "/usr/share/clash/dashboard"" $CONFIG_YAML + sed -i "10i\ " $CONFIG_YAML + sed -i "11i\ " $CONFIG_YAML + sed -i '/#=============/ d' $CONFIG_YAML else - if [ $subtype=="v2rayn2clash" ] || [ $subtype=="surge2clash" ];then - sed -i "/Proxy:/i\#clash-openwrt" /etc/clash/config.yaml - sed -i "/#clash-openwrt/a\#=============" /etc/clash/config.yaml - sed -i "/#=============/a\ " /etc/clash/config.yaml - sed -i '1,/#clash-openwrt/d' /etc/clash/config.yaml - mv /etc/clash/config.yaml /etc/clash/dns.yaml - cat /usr/share/clash/dns.yaml /etc/clash/dns.yaml > /etc/clash/config.yaml + if [ $subtype == "v2rayn2clash" ];then + sed -i "/Proxy:/i\#clash-openwrt" $CONFIG_YAML + sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML + sed -i "/#=============/a\ " $CONFIG_YAML + sed -i '1,/#clash-openwrt/d' $CONFIG_YAML + mv $CONFIG_YAML /etc/clash/dns.yaml + cat /usr/share/clash/dns.yaml /etc/clash/dns.yaml > $CONFIG_YAML rm -rf /etc/clash/dns.yaml else - sed -i "/dns:/i\#clash-openwrt" /etc/clash/config.yaml - sed -i "/#clash-openwrt/a\#=============" /etc/clash/config.yaml - sed -i '1,/#clash-openwrt/d' /etc/clash/config.yaml + sed -i "/dns:/i\#clash-openwrt" $CONFIG_YAML + sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML + sed -i '1,/#clash-openwrt/d' $CONFIG_YAML fi - sed -i "1i\port: ${http_port}" /etc/clash/config.yaml - sed -i "2i\socks-port: ${socks_port}" /etc/clash/config.yaml - sed -i "3i\redir-port: ${redir_port}" /etc/clash/config.yaml - sed -i "4i\allow-lan: true" /etc/clash/config.yaml - sed -i "5i\mode: Rule" /etc/clash/config.yaml - sed -i "6i\log-level: ${log_level}" /etc/clash/config.yaml - sed -i "7i\external-controller: 0.0.0.0:${dash_port}" /etc/clash/config.yaml - sed -i "8i\secret: '${da_password}'" /etc/clash/config.yaml - sed -i "9i\external-ui: "/usr/share/clash/dashboard"" /etc/clash/config.yaml - sed -i "10i\ " /etc/clash/config.yaml - sed -i "11i\ " /etc/clash/config.yaml - sed -i '/#=============/ d' /etc/clash/config.yaml + sed -i "1i\port: ${http_port}" $CONFIG_YAML + sed -i "2i\socks-port: ${socks_port}" $CONFIG_YAML + sed -i "3i\redir-port: ${redir_port}" $CONFIG_YAML + sed -i "4i\allow-lan: true" $CONFIG_YAML + sed -i "5i\mode: Rule" $CONFIG_YAML + sed -i "6i\log-level: ${log_level}" $CONFIG_YAML + sed -i "7i\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML + sed -i "8i\secret: '${da_password}'" $CONFIG_YAML + sed -i "9i\external-ui: "/usr/share/clash/dashboard"" $CONFIG_YAML + sed -i "10i\ " $CONFIG_YAML + sed -i "11i\ " $CONFIG_YAML + sed -i '/#=============/ d' $CONFIG_YAML fi #=========================================================================================================================== @@ -110,12 +113,12 @@ fi yml_dns_change(){ #=========================================================================================================================== - dns_port=$(grep listen: /etc/clash/config.yaml |awk -F ':' '{print $3}' |tr -cd "[0-9]") + dns_port=$(grep listen: $CONFIG_YAML |awk -F ':' '{print $3}' |tr -cd "[0-9]") dnsforwader=$(uci get clash.config.dnsforwader 2>/dev/null) if [ $dns_port -eq 53 ]; then - sed -i '/listen:/ d' /etc/clash/config.yaml - sed -i "/nameserver:/i\ listen: 0.0.0.0:5300" /etc/clash/config.yaml + sed -i '/listen:/ d' $CONFIG_YAML + sed -i "/nameserver:/i\ listen: 0.0.0.0:5300" $CONFIG_YAML fi if [ $dnsforwader -eq 1 ]; then @@ -171,7 +174,7 @@ rules(){ lan_ip=$(uci get network.lan.ipaddr 2>/dev/null) lanac=$(uci get clash.config.rejectlan 2>/dev/null) lan=$(uci get clash.config.proxylan 2>/dev/null) - dns_port=$(grep listen: /etc/clash/config.yaml |awk -F ':' '{print $3}' |tr -cd "[0-9]") + dns_port=$(grep listen: $CONFIG_YAML |awk -F ':' '{print $3}' |tr -cd "[0-9]") redir_port=$(uci get clash.config.redir_port 2>/dev/null) iptables -t nat -N clash_tcp @@ -185,8 +188,11 @@ rules(){ iptables -t nat -A clash_tcp -d 224.0.0.0/4 -j RETURN iptables -t nat -A clash_tcp -d 240.0.0.0/4 -j RETURN iptables -t nat -A clash_tcp -d $lan_ip -j RETURN + iptables -t nat -A clash_tcp -p tcp --dport 22 -j ACCEPT - iptables -t nat -A clash_udp -p udp -j REDIRECT --to-ports $dns_port + + iptables -t nat -A clash_udp -p udp -j REDIRECT --to-ports $dns_port + if [ $lanac -eq 1 ]; then iptables -t nat -A clash_tcp -p tcp -m set --match-set clash_lan src -j RETURN iptables -t nat -A clash_tcp -p tcp -j REDIRECT --to-ports $redir_port @@ -195,7 +201,9 @@ rules(){ else iptables -t nat -A clash_tcp -p tcp -j REDIRECT --to-ports $redir_port fi + iptables -t nat -I PREROUTING 1 -p udp --dport 53 -j clash_udp + iptables -t nat -A PREROUTING -p tcp -j clash_tcp @@ -206,10 +214,10 @@ rules(){ yml_yaml(){ #=========================================================================================================================== subscribe_url=$(uci get clash.config.subscribe_url 2>/dev/null) -size=$(ls -l /etc/clash/config.yaml|awk '{print $5}') -if [ -f /etc/clash/config.yml ] && [ ! -f /etc/clash/config.yaml ] || [ -f /etc/clash/config.yml ] && [ -f /etc/clash/config.yaml ] && [ $size -eq 0 ];then - mv /etc/clash/config.yml /etc/clash/config.yaml -elif [ ! -f /etc/clash/config.yaml ] && [ $subscribe_url ];then +size=$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}') +if [ -f $CONFIG_YAML_OLD ] && [ ! -f $CONFIG_YAML ] || [ -f $CONFIG_YAML_OLD ] && [ -f $CONFIG_YAML ] && [ $size -eq 0 ];then + mv $CONFIG_YAML_OLD $CONFIG_YAML +elif [ ! -f $CONFIG_YAML ] && [ $subscribe_url ];then sh /usr/share/clash/clash.sh >>/tmp/clash.log >/dev/null 2>&1 fi #=========================================================================================================================== @@ -222,7 +230,7 @@ if pidof clash >/dev/null; then fi enable=$(uci get clash.config.enable 2>/dev/null) yml_yaml -size=$(ls -l /etc/clash/config.yaml|awk '{print $5}') +size=$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}') lan=$(uci get clash.config.proxylan 2>/dev/null) lanac=$(uci get clash.config.rejectlan 2>/dev/null) @@ -269,10 +277,8 @@ else fi -else - echo "===============================$(date "+%Y-%m-%d %H:%M:%S") CLIENT IS DISABLED =====================================" >> /tmp/clash.log -fi +fi #=========================================================================================================================== } @@ -306,10 +312,11 @@ stop(){ rm -rf /www/clash 2> /dev/null del_cron - + rm -rf /tmp/clash.log - + echo "===============================$(date "+%Y-%m-%d %H:%M:%S") CLIENT IS DISABLED =====================================" >> /tmp/clash.log + #=========================================================================================================================== } @@ -318,8 +325,7 @@ restart(){ #=========================================================================================================================== if pidof clash >/dev/null; then - stop - sleep 2 + stop start else start diff --git a/package/jsda/luci-app-clash/root/usr/share/clash/clash.sh b/package/jsda/luci-app-clash/root/usr/share/clash/clash.sh index f404559cbe..c22c2b1ddd 100755 --- a/package/jsda/luci-app-clash/root/usr/share/clash/clash.sh +++ b/package/jsda/luci-app-clash/root/usr/share/clash/clash.sh @@ -3,28 +3,40 @@ subscribe_url=$(uci get clash.config.subscribe_url 2>/dev/null) subtype=$(uci get clash.config.subcri 2>/dev/null) urlv2ray=$(uci get clash.config.v2ray 2>/dev/null) urlsurge=$(uci get clash.config.surge 2>/dev/null) -enable=$(uci get clash.config.enable 2>/dev/null) +CONFIG_YAML="/etc/clash/config.yaml" +CONFIG_YAML_TEMP="/etc/clash/server.yaml" +CONFIG_YAML_RULE="/usr/share/clash/rule.yaml" if pidof clash >/dev/null; then /etc/init.d/clash stop 2>/dev/null -fi rm -rf /etc/clash/config.bak 2> /dev/null if [ $subtype == "clash" ];then -wget-ssl --user-agent="User-Agent: Mozilla" $subscribe_url -O 2>&1 >1 /etc/clash/config.yaml +wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $subscribe_url -O 2>&1 >1 $CONFIG_YAML elif [ $subtype == "v2rayn2clash" ];then -wget-ssl --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 /etc/clash/server.yaml -if [ -f /etc/clash/server.yaml ];then -sed -i '/Rule:/,$d' /etc/clash/server.yaml -cat /etc/clash/server.yaml /usr/share/clash/rule.yaml > /etc/clash/config.yaml +wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML_TEMP +if [ -f $CONFIG_YAML_TEMP ];then +sed -i '/Rule:/,$d' $CONFIG_YAML_TEMP +cat $CONFIG_YAML_TEMP $CONFIG_YAML_RULE > $CONFIG_YAML fi elif [ $subtype == "surge2clash" ];then -wget-ssl --user-agent="User-Agent: Mozilla" $urlsurge.$subscribe_url -O 2>&1 >1 /etc/clash/server.yaml -if [ -f /etc/clash/server.yaml ];then -sed -i '/Rule:/,$d' /etc/clash/server.yaml -cat /etc/clash/server.yaml /usr/share/clash/rule.yaml > /etc/clash/config.yaml +wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML fi +rm -rf $CONFIG_YAML_TEMP 2> /dev/null +uci set clash.config.enable=1 2> /dev/null +uci commit clash 2> /dev/null +/etc/init.d/clash restart 2>/dev/null +else +rm -rf /etc/clash/config.bak 2> /dev/null +if [ $subtype == "clash" ];then +wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $subscribe_url -O 2>&1 >1 $CONFIG_YAML +elif [ $subtype == "v2rayn2clash" ];then +wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML_TEMP +if [ -f $CONFIG_YAML_TEMP ];then +sed -i '/Rule:/,$d' $CONFIG_YAML_TEMP +cat $CONFIG_YAML_TEMP $CONFIG_YAML_RULE > $CONFIG_YAML fi -rm -rf /etc/clash/server.yaml 2> /dev/null -if [ $enable -eq 1 ]; then -[ "$?" -eq "0" ] && /etc/init.d/clash restart 2>/dev/null +elif [ $subtype == "surge2clash" ];then +wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML +fi +rm -rf $CONFIG_YAML_TEMP 2> /dev/null fi diff --git a/package/jsda/luci-app-clash/root/usr/share/clash/clash_version b/package/jsda/luci-app-clash/root/usr/share/clash/clash_version index c25c8e5b74..26bea73e81 100644 --- a/package/jsda/luci-app-clash/root/usr/share/clash/clash_version +++ b/package/jsda/luci-app-clash/root/usr/share/clash/clash_version @@ -1 +1 @@ -0.30.0 +0.31.0