OpenClash: bump to v0.36.9-beta

This commit is contained in:
CN_SZTL 2020-03-10 22:36:42 +08:00
parent d7bd677ad1
commit 48cfb8b7cb
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
25 changed files with 321 additions and 215 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-openclash
PKG_VERSION:=0.36.7
PKG_VERSION:=0.36.9
PKG_RELEASE:=beta
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>
@ -14,7 +14,7 @@ define Package/$(PKG_NAME)
SUBMENU:=3. Applications
TITLE:=LuCI support for clash
PKGARCH:=all
DEPENDS:=+iptables +dnsmasq-full +coreutils +coreutils-nohup +bash +curl +jsonfilter +ca-certificates
DEPENDS:=+iptables +dnsmasq-full +coreutils +coreutils-nohup +bash +curl +jsonfilter +ca-certificates +ipset +ip-full +iptables-mod-tproxy
MAINTAINER:=vernesong
endef

View File

@ -23,6 +23,7 @@ config openclash 'config'
option log_level 'silent'
option proxy_mode 'Rule'
option intranet_allowed '0'
option enable_udp_proxy '0'
config dns_servers
option group 'nameserver'

View File

@ -105,42 +105,58 @@ yml_check()
#检查关键字避免后续操作出错
#proxies
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$3" 2>/dev/null
sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$3" 2>/dev/null
[ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && {
sed -i "s/^\'proxies\':/Proxy:/" "$CFG_FILE" 2>/dev/null
sed -i 's/^\"proxies\":/Proxy:/' "$CFG_FILE" 2>/dev/null
sed -i "s/^proxies:/Proxy:/" "$CFG_FILE" 2>/dev/null
[ ! -z "$(grep "^ \{0,\}\'Proxy\':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}\"Proxy\":' "$3")" ] || [ ! -z "$(grep '^ \{1,\}Proxy:' "$3")" ] && {
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$3" 2>/dev/null
sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$3" 2>/dev/null
}
[ -z "$(grep "^Proxy:" "$3")" ] && {
sed -i "s/^\'proxies\':/Proxy:/" "$3" 2>/dev/null
sed -i 's/^\"proxies\":/Proxy:/' "$3" 2>/dev/null
sed -i "s/^proxies:/Proxy:/" "$3" 2>/dev/null
}
#proxy-providers
sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$3" 2>/dev/null
sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$3" 2>/dev/null
sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$3" 2>/dev/null
sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$3" 2>/dev/null
[ ! -z "$(grep "^ \{0,\}\'proxy-provider\':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}\"proxy-provider\":' "$3")" ] || [ ! -z "$(grep '^ \{1,\}proxy-provider:' "$3")" ] && {
sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$3" 2>/dev/null
sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$3" 2>/dev/null
}
[ -z "$(grep "^proxy-provider:" "$3")" ] && {
sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$3" 2>/dev/null
sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$3" 2>/dev/null
}
#proxy-groups
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$3" 2>/dev/null
sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$3" 2>/dev/null
sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$3" 2>/dev/null
sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$3" 2>/dev/null
[ ! -z "$(grep "^ \{0,\}\'Proxy Group\':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}\"Proxy Group\":' "$3")" ] || [ ! -z "$(grep '^ \{1,\}Proxy Group:' "$3")" ] && {
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$3" 2>/dev/null
sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$3" 2>/dev/null
}
[ -z "$(grep "^Proxy Group:" "$3")" ] && {
sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$3" 2>/dev/null
sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$3" 2>/dev/null
}
#rules
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$3" 2>/dev/null
sed -i "/^ \{1,\}Rule:/c\Rule:" "$3" 2>/dev/null
sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$3" 2>/dev/null
sed -i "/^ \{0,\}rules:/c\Rule:" "$3" 2>/dev/null
sed -i "/^ \{0,\}\'dns\':/c\dns:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$3" 2>/dev/null
sed -i "/^ \{1,\}dns:/c\dns:" "$3" 2>/dev/null
[ ! -z "$(grep "^ \{0,\}\'Rule\':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}\"Rule\":' "$3")" ] || [ ! -z "$(grep '^ \{1,\}Rule:' "$3")" ] && {
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$3" 2>/dev/null
sed -i "/^ \{1,\}Rule:/c\Rule:" "$3" 2>/dev/null
}
[ -z "$(grep "^Rule:" "$3")" ] && {
sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$3" 2>/dev/null
sed -i "/^ \{0,\}rules:/c\Rule:" "$3" 2>/dev/null
}
#dns
[ ! -z "$(grep "^ \{0,\}\'dns\':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}\"dns\":' "$3")" ] || [ ! -z "$(grep '^ \{1,\}dns:' "$3")" ] && {
sed -i "/^ \{0,\}\'dns\':/c\dns:" "$3" 2>/dev/null
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$3" 2>/dev/null
sed -i "/^ \{1,\}dns:/c\dns:" "$3" 2>/dev/null
}
#创建启动备份
cp "$3" "$5"
@ -687,6 +703,7 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
log_level=$(uci get openclash.config.log_level 2>/dev/null)
proxy_mode=$(uci get openclash.config.proxy_mode 2>/dev/null)
intranet_allowed=$(uci get openclash.config.intranet_allowed 2>/dev/null)
enable_udp_proxy=$(uci get openclash.config.enable_udp_proxy 2>/dev/null)
echo "第二步: 配置文件检查..." >$START_LOG
yml_check "$en_mode" "$enable_custom_dns" "$CONFIG_FILE" "$BACKUP_FILE" "$START_BACKUP"
@ -752,7 +769,6 @@ mkdir -p /var/etc
cat > "/var/etc/openclash.include" <<-EOF
/etc/init.d/openclash restart
EOF
iptables -t nat -I PREROUTING -p tcp --dport 53 -j ACCEPT
if [ -z "$en_mode_tun" ]; then
#tcp
@ -771,9 +787,12 @@ EOF
done
fi
iptables -t nat -A openclash -p tcp -j REDIRECT --to-ports "$proxy_port"
iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j REDIRECT --to-ports "$proxy_port"
iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j REDIRECT --to-ports "$proxy_port"
iptables -t nat -A PREROUTING -p tcp -j openclash
#udp
if [ "$enable_udp_proxy" -eq 1 ]; then
ip rule add fwmark 1 table 100
ip route add local default dev lo table 100
iptables -t mangle -N openclash
@ -793,26 +812,39 @@ EOF
iptables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark 1
iptables -t mangle -A PREROUTING -p udp -j openclash
fi
if [ "$en_mode" = "fake-ip" ]; then
iptables -t nat -A OUTPUT -p tcp -d 198.18.0.0/16 -j REDIRECT --to-ports "$proxy_port"
iptables -t mangle -A OUTPUT -p udp -d 198.18.0.0/16 -j MARK --set-mark 1
if [ "$enable_udp_proxy" -eq 1 ]; then
iptables -t mangle -A OUTPUT -p udp -d 198.18.0.0/16 -j MARK --set-mark 1
fi
fi
if [ "$ipv6_enable" -eq 1 ]; then
#tcp
ip6tables -t nat -N openclash
ip6tables -t mangle -N openclash
if [ ! -z "$lan_ip6" ]; then
for lan_ip6s in $lan_ip6; do
ip6tables -t nat -A openclash -d "$lan_ip6s" -j RETURN 2>/dev/null
ip6tables -t mangle -A openclash -d "$lan_ip6s" -j RETURN 2>/dev/null
done
fi
ip6tables -t nat -A openclash -p tcp -j REDIRECT --to-ports "$proxy_port"
ip6tables -t nat -A PREROUTING -p tcp -j openclash
ip6tables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark 1
ip6tables -t mangle -A PREROUTING -p udp -j openclash
#udp
if [ "$enable_udp_proxy" -eq 1 ]; then
ip6tables -t mangle -N openclash
if [ ! -z "$lan_ip6" ]; then
for lan_ip6s in $lan_ip6; do
if [ "$enable_udp_proxy" -eq 1 ]; then
ip6tables -t mangle -A openclash -d "$lan_ip6s" -j RETURN 2>/dev/null
fi
done
fi
ip6tables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark 1
ip6tables -t mangle -A PREROUTING -p udp -j openclash
fi
fi
else
#TUN模式
@ -853,6 +885,7 @@ EOF
fi
iptables -t mangle -I OUTPUT -j openclash
iptables -t mangle -I PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK"
iptables -t nat -I PREROUTING -p tcp --dport 53 -j ACCEPT
#ipv6
#if [ "$ipv6_enable" -eq 1 ]; then
#ip6tables -t mangle -I PREROUTING -j MARK --set-mark "$PROXY_FWMARK"
@ -966,6 +999,8 @@ stop()
ip rule del fwmark 1 table 100 >/dev/null 2>&1
ip route del local default dev lo table 100 >/dev/null 2>&1
iptables -t nat -D PREROUTING -p tcp --dport 53 -j ACCEPT >/dev/null 2>&1
iptables -t mangle -F openclash >/dev/null 2>&1
iptables -t mangle -D PREROUTING -p udp -j openclash >/dev/null 2>&1
@ -985,6 +1020,11 @@ stop()
iptables -t nat -D OUTPUT "$out_line" >/dev/null 2>&1
done
out_lines=$(iptables -nvL PREROUTING -t nat |sed 1,2d |sed -n '/8.8./=' 2>/dev/null |sort -rn)
for out_line in $out_lines; do
iptables -t nat -D PREROUTING "$out_line" >/dev/null 2>&1
done
#ipv6
ip6tables -t mangle -F openclash >/dev/null 2>&1
ip6tables -t mangle -D PREROUTING -p udp -j openclash >/dev/null 2>&1
@ -1002,7 +1042,6 @@ stop()
ip rule del fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" >/dev/null 2>&1
iptables -t mangle -D OUTPUT -j openclash >/dev/null 2>&1
iptables -t nat -D PREROUTING -p tcp --dport 53 -j ACCEPT >/dev/null 2>&1
iptables -t mangle -D PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK" >/dev/null 2>&1
ip6tables -t mangle -D PREROUTING -j MARK --set-mark "$PROXY_FWMARK" >/dev/null 2>&1
iptables -t mangle -F openclash >/dev/null 2>&1

File diff suppressed because one or more lines are too long

View File

@ -32,16 +32,6 @@ function index()
end
local fs = require "luci.openclash"
CONFIG_FILE=string.sub(luci.sys.exec("uci get openclash.config.config_path"), 1, -2)
if CONFIG_FILE == "" or not fs.isfile(CONFIG_FILE) then
CONFIG_FILE_FIRST=luci.sys.exec("ls -lt '/etc/openclash/config/' | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}'")
if CONFIG_FILE_FIRST ~= "" then
CONFIG_FILE="/etc/openclash/config/" .. string.sub(CONFIG_FILE_FIRST, 1, -2)
else
CONFIG_FILE = ""
end
end
local function is_running()
return luci.sys.call("pidof clash >/dev/null") == 0
@ -63,14 +53,6 @@ local function mode()
return luci.sys.exec("uci get openclash.config.en_mode 2>/dev/null")
end
local function config()
if CONFIG_FILE ~= "" then
return string.sub(CONFIG_FILE, 23, -1)
else
return "1"
end
end
local function ipdb()
return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/etc/openclash/Country.mmdb"))
end
@ -191,7 +173,6 @@ end
function action_state()
luci.http.prepare_content("application/json")
luci.http.write_json({
config = config(),
lhie1 = lhie1(),
ConnersHua = ConnersHua(),
ConnersHua_return = ConnersHua_return(),

View File

@ -36,7 +36,7 @@ function config_check(CONFIG_FILE)
end
proxy = luci.sys.call(string.format('egrep "^ {0,}Proxy:" "%s" >/dev/null 2>&1',CONFIG_FILE))
if (proxy ~= 0) then
proxy = luci.sys.call(string.format('egrep "^ {0,}proxies:" "%s" >/dev/null 2>&1',CONFIG_FILE))
proxy = luci.sys.call(string.format('egrep "^proxies:" "%s" >/dev/null 2>&1',CONFIG_FILE))
end
group = luci.sys.call(string.format('egrep "^ {0,}Proxy Group:" "%s" >/dev/null 2>&1',CONFIG_FILE))
if (group ~= 0) then
@ -87,7 +87,7 @@ e[t].name=fs.basename(o)
BACKUP_FILE="/etc/openclash/backup/".. e[t].name
CONFIG_FILE="/etc/openclash/config/".. e[t].name
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE)) or os.date("%Y-%m-%d %H:%M:%S",a.mtime)
if string.sub(luci.sys.exec("uci get openclash.config.config_path"), 23, -2) == e[t].name then
if string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 23, -2) == e[t].name then
e[t].state=translate("Enable")
else
e[t].state=translate("Disable")

View File

@ -34,7 +34,7 @@ function config_check(CONFIG_FILE)
end
proxy = luci.sys.call(string.format('egrep "^ {0,}Proxy:" "%s" >/dev/null 2>&1',CONFIG_FILE))
if (proxy ~= 0) then
proxy = luci.sys.call(string.format('egrep "^ {0,}proxies:" "%s" >/dev/null 2>&1',CONFIG_FILE))
proxy = luci.sys.call(string.format('egrep "^proxies:" "%s" >/dev/null 2>&1',CONFIG_FILE))
end
group = luci.sys.call(string.format('egrep "^ {0,}Proxy Group:" "%s" >/dev/null 2>&1',CONFIG_FILE))
if (group ~= 0) then
@ -163,7 +163,7 @@ e[t].name=fs.basename(o)
BACKUP_FILE="/etc/openclash/backup/".. e[t].name
CONFIG_FILE="/etc/openclash/config/".. e[t].name
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE)) or os.date("%Y-%m-%d %H:%M:%S",a.mtime)
if string.sub(luci.sys.exec("uci get openclash.config.config_path"), 23, -2) == e[t].name then
if string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 23, -2) == e[t].name then
e[t].state=translate("Enable")
else
e[t].state=translate("Disable")
@ -324,7 +324,7 @@ local tab = {
s = m:section(Table, tab)
local conf = string.sub(luci.sys.exec("uci get openclash.config.config_path"), 1, -2)
local conf = string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 1, -2)
local dconf = "/etc/openclash/default.yaml"
local conf_name = fs.basename(conf)
if not conf_name then conf_name = "config.yaml" end

View File

@ -11,14 +11,20 @@ local uci = require "luci.model.uci".cursor()
m = Map(openclash, translate("Game Rules and Groups"))
m.pageaction = false
m.description=translate("注意事项:<br/>游戏代理为测试功能,不保证可用性。其中游戏模式使用的内核由comzyh修改 \
<br/>https://github.com/comzyh/clash <br/>使 \
<br/>1使:FallBackUDP \
m.description=translate("注意事项:<br/>游戏代理为测试功能,不保证可用性。 \
<br/>\
<br/>1使:FallBackUDP \
<br/>2使 \
<br/>3 \
<br/>4https://github.com/Dreamacro/clash/releases/tag/TUN \
<br/>https://github.com/vernesong/OpenClash/releases/tag/TUN \
<br/>5--TUN模式")
<br/> \
<br/>使 \
<br/>1--UDP流量代理 \
<br/> \
<br/>TUN模式下使用 \
<br/>1https://github.com/Dreamacro/clash/releases/tag/TUN \
<br/>2https://github.com/vernesong/OpenClash/releases/tag/TUN \
<br/>3https://github.com/comzyh/clash \
<br/>4--TUN模式")
function IsRuleFile(e)

View File

@ -54,6 +54,14 @@ o:value("redir-host-vpn", translate("redir-host-vpn(game mode)"))
o:value("fake-ip-vpn", translate("fake-ip-vpn(game mode)"))
o.default = "redir-host"
o = s:taboption("settings", ListValue, "enable_udp_proxy", font_red..bold_on..translate("Proxy UDP Traffics")..bold_off..font_off)
o.description = translate("Select Mode For UDP Traffics, The Servers Must Support UDP while Choose Proxy")
o:depends("en_mode", "redir-host")
o:depends("en_mode", "fake-ip")
o:value("0", translate("Disable"))
o:value("1", translate("Enable"))
o.default = "0"
o = s:taboption("settings", ListValue, "proxy_mode", font_red..bold_on..translate("Proxy Mode")..bold_off..font_off)
o.description = translate("Select Proxy Mode")
o:value("Rule", translate("Rule Proxy Mode"))

View File

@ -26,71 +26,72 @@
var haishanh = document.getElementById('_haishanh');
var FQrabbit = document.getElementById('_FQrabbit');
var Fndroid = document.getElementById('_Fndroid');
Dreamacro.innerHTML = '<img src="https://avatars3.githubusercontent.com/u/8615343?s=460&v=4" style="border-radius:50%;" title="Dreamacro" alt="Dreamacro" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return Dreamacro_rediret()" />';
vernesong.innerHTML = '<img src="https://avatars2.githubusercontent.com/u/42875168?s=460&v=4" style="border-radius:50%;" title="vernesong" alt="vernesong" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return vernesong_rediret()" />';
frainzy1477.innerHTML = '<img src="https://avatars2.githubusercontent.com/u/49537471?s=460&v=4" style="border-radius:50%;" title="frainzy1477" alt="frainzy1477" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return frainzy1477_rediret()" />';
SukkaW.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/40715044?s=460&v=4" style="border-radius:50%;" title="SukkaW" alt="SukkaW" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return SukkaW_rediret()" />';
lhie1_dev.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/11873197?s=460&v=4" style="border-radius:50%;" title="lhie1" alt="lhie1" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return lhie1_rediret()" />';
ConnersHua_dev.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/11730838?s=460&v=4" style="border-radius:50%;" title="ConnersHua" alt="ConnersHua" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return ConnersHua_rediret()" />';
MaxMind.innerHTML = '<img src="https://avatars3.githubusercontent.com/u/1181834?s=200&v=4" style="border-radius:50%;" title="MaxMind" alt="MaxMind" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return MaxMind_rediret()" />';
haishanh.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/1166872?s=460&v=4" style="border-radius:50%;" title="haishanh" alt="haishanh" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return haishanh_rediret()" />';
FQrabbit.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/29931248?s=460&v=4" style="border-radius:50%;" title="FQrabbit" alt="FQrabbit" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return FQrabbit_rediret()" />';
Fndroid.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/16091562?s=400&v=4" style="border-radius:50%;" title="Fndroid" alt="Fndroid" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return Fndroid_rediret()" />';
Dreamacro.innerHTML = '<img src="https://avatars3.githubusercontent.com/u/8615343?s=460&v=4" loading="lazy" style="border-radius:50%;" title="Dreamacro" alt="Dreamacro" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return Dreamacro_rediret()" />';
vernesong.innerHTML = '<img src="https://avatars2.githubusercontent.com/u/42875168?s=460&v=4" loading="lazy" style="border-radius:50%;" title="vernesong" alt="vernesong" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return vernesong_rediret()" />';
frainzy1477.innerHTML = '<img src="https://avatars2.githubusercontent.com/u/49537471?s=460&v=4" loading="lazy" style="border-radius:50%;" title="frainzy1477" alt="frainzy1477" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return frainzy1477_rediret()" />';
SukkaW.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/40715044?s=460&v=4" loading="lazy" style="border-radius:50%;" title="SukkaW" alt="SukkaW" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return SukkaW_rediret()" />';
lhie1_dev.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/11873197?s=460&v=4" loading="lazy" style="border-radius:50%;" title="lhie1" alt="lhie1" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return lhie1_rediret()" />';
ConnersHua_dev.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/11730838?s=460&v=4" loading="lazy" style="border-radius:50%;" title="ConnersHua" alt="ConnersHua" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return ConnersHua_rediret()" />';
MaxMind.innerHTML = '<img src="https://avatars3.githubusercontent.com/u/1181834?s=200&v=4" loading="lazy" style="border-radius:50%;" title="MaxMind" alt="MaxMind" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return MaxMind_rediret()" />';
haishanh.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/1166872?s=460&v=4" loading="lazy" style="border-radius:50%;" title="haishanh" alt="haishanh" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return haishanh_rediret()" />';
FQrabbit.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/29931248?s=460&v=4" loading="lazy" style="border-radius:50%;" title="FQrabbit" alt="FQrabbit" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return FQrabbit_rediret()" />';
Fndroid.innerHTML = '<img src="https://avatars1.githubusercontent.com/u/16091562?s=400&v=4" loading="lazy" style="border-radius:50%;" title="Fndroid" alt="Fndroid" width="50" onerror="return imgerrorfun(this,this.src)" onclick="return Fndroid_rediret()" />';
function Dreamacro_rediret()
{
url1='https://github.com/Dreamacro';
window.open(url1);
}
};
function vernesong_rediret()
{
url2='https://github.com/vernesong';
window.open(url2);
}
};
function frainzy1477_rediret()
{
url3='https://github.com/frainzy1477';
window.open(url3);
}
};
function SukkaW_rediret()
{
url4='https://github.com/SukkaW';
window.open(url4);
}
};
function lhie1_rediret()
{
url5='https://github.com/lhie1';
window.open(url5);
}
};
function ConnersHua_rediret()
{
url6='https://github.com/ConnersHua';
window.open(url6);
}
};
function MaxMind_rediret()
{
url9='https://dev.maxmind.com/geoip/geoip2/geolite2/';
window.open(url9);
}
};
function haishanh_rediret()
{
url10='https://github.com/haishanh';
window.open(url10);
}
};
function Fndroid_rediret()
{
url11='https://github.com/Fndroid';
window.open(url11);
}
};
function FQrabbit_rediret()
{
url12='https://github.com/FQrabbit';
window.open(url12);
}
};
function imgerrorfun(imgobj,imgSrc){
setTimeout(function(){
imgobj.src=imgSrc;
},1000*10);
}
};
//]]></script>

View File

@ -11,15 +11,15 @@
</td></tr>
<tr><td colspan="4" width="100%">
<p align="center">
<img id="wiki" src="https://img.shields.io/badge/Tutorials--lightgrey?logo=Wikipedia&style=social" alt="Wiki" onerror="return imgerrorfuns(this,this.src)" onclick="return wikipage()" />
<img id="wiki" src="https://img.shields.io/badge/Tutorials--lightgrey?logo=Wikipedia&style=social" loading="lazy" alt="Wiki" width="75px" height="20px" onerror="return imgerrorfuns(this,this.src)" onclick="return wikipage()" />
&nbsp;&nbsp;&nbsp;
<img id="star" src="https://img.shields.io/badge/Star--lightgrey?logo=github&style=social" alt="star" onerror="return imgerrorfuns(this,this.src)" onclick="return homepage()" />
<img id="star" src="https://img.shields.io/badge/Star--lightgrey?logo=github&style=social" loading="lazy" alt="star" width="50px" height="20px" onerror="return imgerrorfuns(this,this.src)" onclick="return homepage()" />
&nbsp;&nbsp;&nbsp;
<!--
<img id="telegram" src="https://img.shields.io/badge/Telegram--lightgrey?logo=Telegram&style=social" alt="Telegram" onerror="return imgerrorfuns(this,this.src)" onclick="return telegrampage()" />
<img id="telegram" src="https://img.shields.io/badge/Telegram--lightgrey?logo=Telegram&style=social" loading="lazy" alt="Telegram" onerror="return imgerrorfuns(this,this.src)" onclick="return telegrampage()" />
&nbsp;&nbsp;&nbsp;
-->
<img id="sponsor" src="https://img.shields.io/badge/Sponsor--lightgrey?logo=ko-fi&style=social" alt="Sponsor" onerror="return imgerrorfuns(this,this.src)" onclick="return sponsorpage()" />
<img id="sponsor" src="https://img.shields.io/badge/Sponsor--lightgrey?logo=ko-fi&style=social" loading="lazy" alt="Sponsor" width="73px" height="20px" onerror="return imgerrorfuns(this,this.src)" onclick="return sponsorpage()" />
</p>
</td></tr>
<tr><td width="100%" colspan="4">
@ -163,7 +163,7 @@
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "currentversion")%>', status.currentversion, function(x, status) {
if ( x && x.status == 200 ) {
clashversion.innerHTML = '<img id="currenntver" src="'+status.currentversion+'" alt="currentversion" width="181px" onload="return clashversion_check()" onclick="return go_update()">';
clashversion.innerHTML = '<img id="currenntver" src="'+status.currentversion+'" loading="lazy" alt="currentversion" width="181px" onload="return clashversion_check()" onclick="return go_update()">';
}
});
@ -173,7 +173,7 @@
if ( x && x.status == 200 ) {
if ( status.lastversion != "\n" && status.lastversion != "" )
{
clashversion.innerHTML = '<img id="lastver" src="'+status.lastversion+'" alt="lastversion" onerror="return clashversion_error()" onclick="return go_update()">';
clashversion.innerHTML = '<img id="lastver" src="'+status.lastversion+'" loading="lazy" alt="lastversion" width="161px" onerror="return clashversion_error()" onclick="return go_update()">';
}
}
});
@ -183,7 +183,7 @@
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "currentversion")%>', status.currentversion, function(x, status) {
if ( x && x.status == 200 ) {
clashversion.innerHTML = '<img id="currenntver" src="'+status.currentversion+'" alt="currentversion" width="181px" onclick="return go_update()">';
clashversion.innerHTML = '<img id="currenntver" src="'+status.currentversion+'" loading="lazy" alt="currentversion" width="181px" onclick="return go_update()">';
}
});
}

View File

@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png" />
<title>Clash</title>
<link href="main.f302eae39f433a9c3fa1.css" rel="stylesheet"></head>
<link href="main.f42e08fe49cdc3329278.css" rel="stylesheet"></head>
<body>
<div id="root"></div>
<script type="text/javascript" src="js/1.bundle.f302eae39f433a9c3fa1.min.js"></script><script type="text/javascript" src="js/bundle.f302eae39f433a9c3fa1.min.js"></script></body>
<script type="text/javascript" src="js/1.bundle.f42e08fe49cdc3329278.min.js"></script><script type="text/javascript" src="js/bundle.f42e08fe49cdc3329278.min.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -10,22 +10,7 @@ object-assign
http://jedwatson.github.io/classnames
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/** @license React v0.18.0
/** @license React v0.19.0
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
@ -34,7 +19,7 @@ and limitations under the License.
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.12.0
/** @license React v16.13.0
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
@ -43,7 +28,7 @@ and limitations under the License.
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.12.0
/** @license React v16.13.0
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,7 @@ status=$(ps|grep -c /usr/share/openclash/openclash.sh)
START_LOG="/tmp/openclash_start.log"
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
LOG_FILE="/tmp/openclash.log"
CFG_FILE="/tmp/config.yaml"
CONFIG_PATH=$(uci get openclash.config.config_path 2>/dev/null)
servers_update=$(uci get openclash.config.servers_update 2>/dev/null)
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
@ -16,12 +17,12 @@ config_download()
{
if [ "$URL_TYPE" == "v2rayn" ]; then
subscribe_url=`echo $subscribe_url |sed 's/{/%7B/g;s/}/%7D/g;s/:/%3A/g;s/\"/%22/g;s/,/%2C/g;s/?/%3F/g;s/=/%3D/g;s/&/%26/g;s/\//%2F/g'`
curl -sL --connect-timeout 10 --retry 2 https://tgbot.lbyczf.com/v2rayn2clash?url="$subscribe_url" -o /tmp/config.yaml >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 https://tgbot.lbyczf.com/v2rayn2clash?url="$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1
elif [ "$URL_TYPE" == "surge" ]; then
subscribe_url=`echo $subscribe_url |sed 's/{/%7B/g;s/}/%7D/g;s/:/%3A/g;s/\"/%22/g;s/,/%2C/g;s/?/%3F/g;s/=/%3D/g;s/&/%26/g;s/\//%2F/g'`
curl -sL --connect-timeout 10 --retry 2 https://tgbot.lbyczf.com/surge2clash?url="$subscribe_url" -o /tmp/config.yaml >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 https://tgbot.lbyczf.com/surge2clash?url="$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 --user-agent "clash" "$subscribe_url" -o /tmp/config.yaml >/dev/null 2>&1
curl -sL --connect-timeout 10 --retry 2 --user-agent "clash" "$subscribe_url" -o "$CFG_FILE" >/dev/null 2>&1
fi
}
@ -62,33 +63,82 @@ config_su_check()
{
echo "配置文件下载成功,检查是否有更新..." >$START_LOG
if [ -f "$CONFIG_FILE" ]; then
cmp -s "$BACKPACK_FILE" /tmp/config.yaml
cmp -s "$BACKPACK_FILE" "$CFG_FILE"
if [ "$?" -ne "0" ]; then
echo "配置文件【$name】有更新,开始替换..." >$START_LOG
mv /tmp/config.yaml "$CONFIG_FILE" 2>/dev/null
mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null
cp "$CONFIG_FILE" "$BACKPACK_FILE"
config_cus_up
else
echo "配置文件【$name】没有任何更新,停止继续操作..." >$START_LOG
rm -rf /tmp/config.yaml
change_dns
rm -rf "$CFG_FILE"
echo "${LOGTIME} Updated Config【$name】 No Change, Do Nothing" >>$LOG_FILE
sleep 5
echo "" >$START_LOG
fi
else
echo "配置文件下载成功,本地没有配置文件,开始创建 ..." >$START_LOG
mv /tmp/config.yaml "$CONFIG_FILE" 2>/dev/null
mv "$CFG_FILE" "$CONFIG_FILE" 2>/dev/null
cp "$CONFIG_FILE" "$BACKPACK_FILE"
config_cus_up
fi
}
config_encode()
{
#proxies
[ ! -z "$(grep "^ \{0,\}\'Proxy\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"Proxy\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}Proxy:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$CFG_FILE" 2>/dev/null
}
[ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && {
sed -i "s/^\'proxies\':/Proxy:/" "$CFG_FILE" 2>/dev/null
sed -i 's/^\"proxies\":/Proxy:/' "$CFG_FILE" 2>/dev/null
sed -i "s/^proxies:/Proxy:/" "$CFG_FILE" 2>/dev/null
}
#proxy-providers
[ ! -z "$(grep "^ \{0,\}\'proxy-provider\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"proxy-provider\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}proxy-provider:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
}
[ -z "$(grep "^proxy-provider:" "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
}
#proxy-groups
[ ! -z "$(grep "^ \{0,\}\'Proxy Group\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"Proxy Group\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}Proxy Group:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
}
[ -z "$(grep "^Proxy Group:" "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
}
#rules
[ ! -z "$(grep "^ \{0,\}\'Rule\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"Rule\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}Rule:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Rule:/c\Rule:" "$CFG_FILE" 2>/dev/null
}
[ -z "$(grep "^Rule:" "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}rules:/c\Rule:" "$CFG_FILE" 2>/dev/null
}
}
config_error()
{
echo "配置文件【$name】下载失败,请检查网络或稍后再试!" >$START_LOG
echo "${LOGTIME} Config 【$name】Update Error" >>$LOG_FILE
rm -rf /tmp/config.yaml 2>/dev/null
rm -rf "$CFG_FILE" 2>/dev/null
sleep 5
echo "" >$START_LOG
}
@ -98,11 +148,11 @@ change_dns()
if pidof clash >/dev/null; then
if [ "$enable_redirect_dns" -ne "0" ]; then
uci del dhcp.@dnsmasq[-1].server >/dev/null 2>&1
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port"
uci delete dhcp.@dnsmasq[0].resolvfile
uci set dhcp.@dnsmasq[0].noresolv=1
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].resolvfile >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].noresolv=1 >/dev/null 2>&1
[ "$disable_masq_cache" -eq "1" ] && {
uci set dhcp.@dnsmasq[0].cachesize=0
uci set dhcp.@dnsmasq[0].cachesize=0 >/dev/null 2>&1
}
uci commit dhcp
/etc/init.d/dnsmasq restart >/dev/null 2>&1
@ -111,6 +161,38 @@ change_dns()
fi
}
config_download_direct()
{
if pidof clash >/dev/null; then
echo "配置文件【$name】下载失败,尝试不使用代理下载配置文件..." >$START_LOG
watchdog_pids=$(ps |grep openclash_watchdog.sh |grep -v grep |awk '{print $1}' 2>/dev/null)
for watchdog_pid in $watchdog_pids; do
kill -9 "$watchdog_pid" >/dev/null 2>&1
done
uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].noresolv=0 >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].cachesize >/dev/null 2>&1
uci commit dhcp
/etc/init.d/dnsmasq restart >/dev/null 2>&1
sleep 3
config_download
if [ "$?" -eq "0" ] && [ -s "$CFG_FILE" ]; then
change_dns
config_su_check
else
change_dns
config_error
fi
else
config_error
fi
}
sub_info_get()
{
local section="$1"
@ -145,44 +227,27 @@ sub_info_get()
config_download
if [ "$?" -eq "0" ] && [ -s "/tmp/config.yaml" ]; then
config_su_check
else
if pidof clash >/dev/null; then
echo "配置文件【$name】下载失败,尝试不使用代理下载配置文件..." >$START_LOG
watchdog_pids=$(ps |grep openclash_watchdog.sh |grep -v grep |awk '{print $1}' 2>/dev/null)
for watchdog_pid in $watchdog_pids; do
kill -9 "$watchdog_pid" >/dev/null 2>&1
done
uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port" >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto
uci set dhcp.@dnsmasq[0].noresolv=0
uci delete dhcp.@dnsmasq[0].cachesize
uci commit dhcp
/etc/init.d/dnsmasq restart >/dev/null 2>&1
sleep 3
config_download
if [ "$?" -eq "0" ] && [ -s "/tmp/config.yaml" ]; then
if [ "$?" -eq "0" ] && [ -s "$CFG_FILE" ]; then
config_encode
grep "^ \{0,\}Proxy Group:" "$CFG_FILE" >/dev/null 2>&1 && grep "^ \{0,\}Rule:" "$CFG_FILE" >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
grep "^ \{0,\}Proxy:" "$CFG_FILE" >/dev/null 2>&1 || grep "^ \{0,\}proxy-provider:" "$CFG_FILE" >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
config_su_check
else
change_dns
config_error
config_download_direct
fi
else
config_error
config_download_direct
fi
else
config_download_direct
fi
}
#分别获取订阅信息进行处理
config_load "openclash"
config_foreach sub_info_get "config_subscribe"
uci delete openclash.config.config_update_path
uci delete openclash.config.config_update_path >/dev/null 2>&1
uci commit openclash
[ "$if_restart" == "1" ] && /etc/init.d/openclash restart >/dev/null 2>&1

View File

@ -20,18 +20,14 @@
else
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/Pro.yaml -o /tmp/rules.yaml >/dev/null 2>&1
fi
sed -i -n '/^Rule:/,$p' /tmp/rules.yaml 2>/dev/null
sed -i -n '/^rules:/,$p' /tmp/rules.yaml 2>/dev/null
sed -i "/^rules:/c\^Rule:" /tmp/rules.yaml 2>/dev/null
sed -i "/^rules:/c\^Rule:" /tmp/rules.yaml 2>/dev/null && sed -i -n '/^Rule:/,$p' /tmp/rules.yaml 2>/dev/null
elif [ "$RUlE_SOURCE" = "ConnersHua_return" ]; then
if pidof clash >/dev/null; then
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/BacktoCN.yaml -o /tmp/rules.yaml >/dev/null 2>&1
else
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/BacktoCN.yaml -o /tmp/rules.yaml >/dev/null 2>&1
fi
sed -i -n '/^Rule:/,$p' /tmp/rules.yaml 2>/dev/null
sed -i -n '/^rules:/,$p' /tmp/rules.yaml 2>/dev/null
sed -i "/^rules:/c\^Rule:" /tmp/rules.yaml 2>/dev/null
sed -i "/^rules:/c\^Rule:" /tmp/rules.yaml 2>/dev/null && sed -i -n '/^Rule:/,$p' /tmp/rules.yaml 2>/dev/null
fi
if [ "$?" -eq "0" ] && [ "$RUlE_SOURCE" != 0 ] && [ -s "/tmp/rules.yaml" ]; then
echo "下载成功,开始预处理规则文件..." >$START_LOG

View File

@ -38,7 +38,7 @@ fi
echo "开始更新【$CONFIG_NAME】的策略组配置..." >$START_LOG
/usr/share/openclash/yml_groups_name_get.sh
[ ! -z "$(grep "读取错误" /tmp/Proxy_Group)"] && {
[ ! -z "$(grep "读取错误" /tmp/Proxy_Group)" ] && {
echo "读取错误,配置文件【$CONFIG_NAME】异常!" >$START_LOG
uci commit openclash
sleep 5
@ -46,9 +46,14 @@ echo "开始更新【$CONFIG_NAME】的策略组配置..." >$START_LOG
exit 0
}
cp /tmp/Proxy_Group /tmp/yaml_group.yaml
sed -i '/DIRECT/d' /tmp/yaml_group.yaml 2>/dev/null
sed -i '/REJECT/d' /tmp/yaml_group.yaml 2>/dev/null
#判断各个区位置
group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$CONFIG_FILE" 2>/dev/null)
provider_len=$(sed -n '/^ \{0,\}proxy-provider:/=' "$CONFIG_FILE" 2>/dev/null)
if [ "$provider_len" -ge "$group_len" ]; then
awk '/Proxy Group:/,/proxy-provider:/{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
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
if [ "$servers_update" -ne "1" ] || [ "$servers_if_update" != "1" ] || [ -z "$(grep "config groups" "$CFG_FILE")" ]; then
echo "正在删除旧配置..." >$START_LOG

View File

@ -14,43 +14,59 @@ fi
if [ -f "$CFG_FILE" ]; then
#检查关键字避免后续操作出错
#proxies
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$CFG_FILE" 2>/dev/null
[ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && {
sed -i "s/^\'proxies\':/Proxy:/" "$CFG_FILE" 2>/dev/null
sed -i 's/^\"proxies\":/Proxy:/' "$CFG_FILE" 2>/dev/null
sed -i "s/^proxies:/Proxy:/" "$CFG_FILE" 2>/dev/null
[ ! -z "$(grep "^ \{0,\}\'Proxy\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"Proxy\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}Proxy:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$CFG_FILE" 2>/dev/null
}
[ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && {
sed -i "s/^\'proxies\':/Proxy:/" "$CFG_FILE" 2>/dev/null
sed -i 's/^\"proxies\":/Proxy:/' "$CFG_FILE" 2>/dev/null
sed -i "s/^proxies:/Proxy:/" "$CFG_FILE" 2>/dev/null
}
#proxy-providers
sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
[ ! -z "$(grep "^ \{0,\}\'proxy-provider\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"proxy-provider\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}proxy-provider:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
}
[ -z "$(grep "^proxy-provider:" "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
}
#proxy-groups
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
[ ! -z "$(grep "^ \{0,\}\'Proxy Group\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"Proxy Group\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}Proxy Group:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
}
[ -z "$(grep "^Proxy Group:" "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
}
#rules
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Rule:/c\Rule:" "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}rules:/c\Rule:" "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}\'dns\':/c\dns:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}dns:/c\dns:" "$CFG_FILE" 2>/dev/null
[ ! -z "$(grep "^ \{0,\}\'Rule\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"Rule\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}Rule:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}Rule:/c\Rule:" "$CFG_FILE" 2>/dev/null
}
[ -z "$(grep "^Rule:" "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{0,\}rules:/c\Rule:" "$CFG_FILE" 2>/dev/null
}
#dns
[ ! -z "$(grep "^ \{0,\}\'dns\':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}\"dns\":' "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{1,\}dns:' "$CFG_FILE")" ] && {
sed -i "/^ \{0,\}\'dns\':/c\dns:" "$CFG_FILE" 2>/dev/null
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$CFG_FILE" 2>/dev/null
sed -i "/^ \{1,\}dns:/c\dns:" "$CFG_FILE" 2>/dev/null
}
#判断各个区位置
group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$CONFIG_FILE" 2>/dev/null)
provider_len=$(sed -n '/^ \{0,\}proxy-provider:/=' "$CONFIG_FILE" 2>/dev/null)

View File

@ -60,22 +60,22 @@ single_provider_gen="/tmp/provider_gen.yaml"
single_provider_che="/tmp/provider_che.yaml"
match_servers="/tmp/match_servers.list"
match_provider="/tmp/match_provider.list"
group_num=$(grep -c "name:" /tmp/yaml_group.yaml)
group_num=$(grep -c "name:" /tmp/yaml_group.yaml 2>/dev/null)
servers_update=$(uci get openclash.config.servers_update 2>/dev/null)
servers_if_update=$(uci get openclash.config.servers_if_update 2>/dev/null)
new_servers_group=$(uci get openclash.config.new_servers_group 2>/dev/null)
#proxy
line=$(sed -n '/^ \{0,\}-/=' $server_file)
num=$(grep -c "^ \{0,\}-" $server_file)
line=$(sed -n '/^ \{0,\}-/=' $server_file 2>/dev/null)
num=$(grep -c "^ \{0,\}-" $server_file 2>/dev/null)
count=1
#provider
sed -i '/^ *$/d' $provider_file 2>/dev/null
sed -i '/^ \{0,\}#/d' $provider_file 2>/dev/null
sed -i 's/\t/ /g' $provider_file 2>/dev/null
provider_line=$(awk '{print $0"#*#"FNR}' $provider_file |grep -v '^ \{0,\}proxy-provider:\|^ \{0,\}Proxy:\|^ \{0,\}Proxy Group:\|^ \{0,\}Rule:\|^ \{0,\}type:\|^ \{0,\}path:\|^ \{0,\}url:\|^ \{0,\}interval:\|^ \{0,\}health-check:\|^ \{0,\}enable:' |awk -F '#*#' '{print $3}')
provider_num=$(grep -c "^ \{0,\}type:" $provider_file)
provider_line=$(awk '{print $0"#*#"FNR}' $provider_file 2>/dev/null |grep -v '^ \{0,\}proxy-provider:\|^ \{0,\}Proxy:\|^ \{0,\}Proxy Group:\|^ \{0,\}Rule:\|^ \{0,\}type:\|^ \{0,\}path:\|^ \{0,\}url:\|^ \{0,\}interval:\|^ \{0,\}health-check:\|^ \{0,\}enable:' |awk -F '#*#' '{print $3}')
provider_num=$(grep -c "^ \{0,\}type:" $provider_file 2>/dev/null)
provider_count=1
cfg_get()

View File

@ -505,8 +505,8 @@ cat >> "$SERVER_FILE" <<-EOF
- name: Steam
type: select
proxies:
- Proxy
- DIRECT
- Proxy
EOF
cat /tmp/Proxy_Server >> $SERVER_FILE 2>/dev/null
if [ -f "/tmp/Proxy_Provider" ]; then

View File

@ -777,5 +777,8 @@ msgstr "序号"
msgid "Game Rules Manage"
msgstr "管理游戏规则"
msgid "Proxy UDP Traffics"
msgstr "*代理UDP流量"
msgid "Select Mode For UDP Traffics, The Servers Must Support UDP while Choose Proxy"
msgstr "启用时服务器必须支持UDP转发"