OpenClash: sync with upstream source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2021-03-08 13:06:49 +08:00
parent f15e17771e
commit 888958fee1
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
5 changed files with 285 additions and 197 deletions

View File

@ -33,17 +33,17 @@ define Build/Prepare
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
chmod 0755 $(PKG_BUILD_DIR)/root/etc/init.d/openclash
chmod -R 0755 $(PKG_BUILD_DIR)/root/usr/share/openclash/
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/config >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/rule_provider >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/backup >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/core >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/usr/share/openclash/backup >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/config/openclash" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules_2.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_hosts.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_fake_filter.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_domain_dns.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/config
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/rule_provider
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/backup
mkdir -p $(PKG_BUILD_DIR)/root/etc/openclash/core
mkdir -p $(PKG_BUILD_DIR)/root/usr/share/openclash/backup
cp -f "$(PKG_BUILD_DIR)/root/etc/config/openclash" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_rules_2.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_hosts.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_fake_filter.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_domain_dns.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
endef
define Build/Configure
@ -58,8 +58,8 @@ endef
define Package/$(PKG_NAME)/preinst
#!/bin/sh
if [ -f "/etc/config/openclash" ]; then
cp "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
cp -r "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1
cp -f "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
cp -rf "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1
fi
endef
@ -68,30 +68,30 @@ endef
define Package/$(PKG_NAME)/prerm
#!/bin/sh
uci set openclash.config.enable=0 >/dev/null 2>&1
uci commit openclash >/dev/null 2>&1
cp "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
cp -r "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1
uci -q set openclash.config.enable=0
uci -q commit openclash
cp -f "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
cp -rf "/etc/openclash" "/tmp/openclash" >/dev/null 2>&1
endef
define Package/$(PKG_NAME)/postrm
#!/bin/sh
rm -rf /etc/openclash >/dev/null 2>&1
rm -rf /tmp/openclash.log >/dev/null 2>&1
rm -rf /tmp/openclash_start.log >/dev/null 2>&1
rm -rf /tmp/openclash_last_version >/dev/null 2>&1
rm -rf /tmp/Proxy_Group >/dev/null 2>&1
rm -rf /tmp/rules_name >/dev/null 2>&1
rm -rf /tmp/rule_providers_name >/dev/null 2>&1
rm -rf /tmp/clash_last_version >/dev/null 2>&1
rm -rf /usr/share/openclash/backup >/dev/null 2>&1
rm -rf /tmp/openclash_fake_filter.list >/dev/null 2>&1
rm -rf /tmp/openclash_servers_fake_filter.conf >/dev/null 2>&1
uci delete firewall.openclash >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
uci delete ucitrack.@openclash[-1] >/dev/null 2>&1
uci commit ucitrack >/dev/null 2>&1
rm -rf /tmp/luci* >/dev/null 2>&1
rm -rf /etc/openclash
rm -rf /tmp/openclash.log
rm -rf /tmp/openclash_start.log
rm -rf /tmp/openclash_last_version
rm -rf /tmp/Proxy_Group
rm -rf /tmp/rules_name
rm -rf /tmp/rule_providers_name
rm -rf /tmp/clash_last_version
rm -rf /usr/share/openclash/backup
rm -rf /tmp/openclash_fake_filter.list
rm -rf /tmp/openclash_servers_fake_filter.conf
uci -q delete firewall.openclash
uci -q commit firewall
uci -q delete ucitrack.@openclash[-1]
uci -q commit ucitrack
rm -rf /tmp/luci-*
endef
define Package/$(PKG_NAME)/install
@ -101,4 +101,4 @@ define Package/$(PKG_NAME)/install
$(CP) $(PKG_BUILD_DIR)/luasrc/* $(1)/usr/lib/lua/luci/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -10,11 +10,11 @@ LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
CLASH="/etc/openclash/clash"
CLASH_CONFIG="/etc/openclash"
CRON_FILE="/etc/crontabs/root"
RAW_CONFIG_FILE=$(uci get openclash.config.config_path 2>/dev/null)
BACKUP_FILE="/etc/openclash/backup/$(uci get openclash.config.config_path 2>/dev/null |awk -F '/' '{print $5}' 2>/dev/null)"
RAW_CONFIG_FILE=$(uci -q get openclash.config.config_path)
BACKUP_FILE="/etc/openclash/backup/$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)"
LOG_FILE="/tmp/openclash.log"
START_LOG="/tmp/openclash_start.log"
CONFIG_FILE="/etc/openclash/$(uci get openclash.config.config_path 2>/dev/null |awk -F '/' '{print $5}' 2>/dev/null)"
CONFIG_FILE="/etc/openclash/$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)"
RULE_PROVIDER_FILE="/tmp/yaml_rule_provider.yaml"
DNS_FILE="/tmp/yaml_dns.yaml"
GAME_RULE_FILE="/tmp/yaml_game_rule.yaml"
@ -30,26 +30,26 @@ set_lock() {
del_lock() {
flock -u 888 2>/dev/null
rm -rf "$LOCK_FILE" 2>/dev/null
rm -rf "$LOCK_FILE"
}
add_cron()
{
[ "$(tail -n1 /etc/crontabs/root | wc -l)" -eq 0 ] && [ -n "$(cat /etc/crontabs/root 2>/dev/null)" ] && echo >> /etc/crontabs/root
[ -z "$(grep "openclash.sh" "$CRON_FILE" 2>/dev/null)" ] && {
[ "$(uci get openclash.config.auto_update 2>/dev/null)" -eq 1 ] && [ "$(uci get openclash.config.config_auto_update_mode 2>/dev/null)" -ne 1 ] && echo "0 $(uci get openclash.config.auto_update_time 2>/dev/null) * * $(uci get openclash.config.config_update_week_time 2>/dev/null) /usr/share/openclash/openclash.sh" >> $CRON_FILE
[ "$(uci -q get openclash.config.auto_update)" -eq 1 ] && [ "$(uci -q get openclash.config.config_auto_update_mode)" -ne 1 ] && echo "0 $(uci -q get openclash.config.auto_update_time) * * $(uci -q get openclash.config.config_update_week_time) /usr/share/openclash/openclash.sh" >> $CRON_FILE
}
[ -z "$(grep "openclash_rule.sh" "$CRON_FILE" 2>/dev/null)" ] && {
[ "$(uci get openclash.config.other_rule_auto_update 2>/dev/null)" -eq 1 ] && echo "0 $(uci get openclash.config.other_rule_update_day_time 2>/dev/null) * * $(uci get openclash.config.other_rule_update_week_time 2>/dev/null) /usr/share/openclash/openclash_rule.sh" >> $CRON_FILE
[ "$(uci -q get openclash.config.other_rule_auto_update)" -eq 1 ] && echo "0 $(uci -q get openclash.config.other_rule_update_day_time) * * $(uci -q get openclash.config.other_rule_update_week_time) /usr/share/openclash/openclash_rule.sh" >> $CRON_FILE
}
[ -z "$(grep "openclash_ipdb.sh" "$CRON_FILE" 2>/dev/null)" ] && {
[ "$(uci get openclash.config.geo_auto_update 2>/dev/null)" -eq 1 ] && echo "0 $(uci get openclash.config.geo_update_day_time 2>/dev/null) * * $(uci get openclash.config.geo_update_week_time 2>/dev/null) /usr/share/openclash/openclash_ipdb.sh" >> $CRON_FILE
[ "$(uci -q get openclash.config.geo_auto_update)" -eq 1 ] && echo "0 $(uci -q get openclash.config.geo_update_day_time) * * $(uci -q get openclash.config.geo_update_week_time) /usr/share/openclash/openclash_ipdb.sh" >> $CRON_FILE
}
[ -z "$(grep "openclash_chnroute.sh" "$CRON_FILE" 2>/dev/null)" ] && {
[ "$(uci get openclash.config.chnr_auto_update 2>/dev/null)" -eq 1 ] && echo "0 $(uci get openclash.config.chnr_update_day_time 2>/dev/null) * * $(uci get openclash.config.chnr_update_week_time 2>/dev/null) /usr/share/openclash/openclash_chnroute.sh" >> $CRON_FILE
[ "$(uci -q get openclash.config.chnr_auto_update)" -eq 1 ] && echo "0 $(uci -q get openclash.config.chnr_update_day_time) * * $(uci -q get openclash.config.chnr_update_week_time) /usr/share/openclash/openclash_chnroute.sh" >> $CRON_FILE
}
[ -z "$(grep "/etc/init.d/openclash" "$CRON_FILE" 2>/dev/null)" ] && {
[ "$(uci get openclash.config.auto_restart 2>/dev/null)" -eq 1 ] && echo "0 $(uci get openclash.config.auto_restart_day_time 2>/dev/null) * * $(uci get openclash.config.auto_restart_week_time 2>/dev/null) /etc/init.d/openclash restart 2>/dev/null" >> $CRON_FILE
[ "$(uci -q get openclash.config.auto_restart)" -eq 1 ] && echo "0 $(uci -q get openclash.config.auto_restart_day_time) * * $(uci -q get openclash.config.auto_restart_week_time) /etc/init.d/openclash restart 2>/dev/null" >> $CRON_FILE
}
crontab $CRON_FILE
nohup /usr/share/openclash/openclash_watchdog.sh &
@ -66,20 +66,20 @@ del_cron()
change_dns() {
if [ "$1" -eq 1 ]; 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 2>/dev/null
uci set dhcp.@dnsmasq[0].noresolv=1 2>/dev/null
uci set openclash.config.redirect_dns=1
uci -q del dhcp.@dnsmasq[-1].server
uci -q add_list dhcp.@dnsmasq[0].server=127.0.0.1#"$dns_port"
uci -q delete dhcp.@dnsmasq[0].resolvfile
uci -q set dhcp.@dnsmasq[0].noresolv=1
uci -q set openclash.config.redirect_dns=1
else
uci set openclash.config.redirect_dns=0 2>/dev/null
uci -q set openclash.config.redirect_dns=0
fi
if [ "$2" -eq 1 ]; then
uci set dhcp.@dnsmasq[0].cachesize=0 2>/dev/null
uci -q set dhcp.@dnsmasq[0].cachesize=0
fi
uci commit dhcp
uci commit openclash
uci -q commit dhcp
uci -q commit openclash
/usr/share/openclash/openclash_custom_domain_dns.sh >/dev/null 2>&1
}
@ -87,39 +87,39 @@ change_dns() {
revert_dns() {
[ "$1" -eq 1 ] && {
uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$3" >/dev/null 2>&1
uci -q del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$3"
}
[ "$1" -eq 1 ] && [ "$4" -eq 0 ] && {
uci set openclash.config.redirect_dns=0 2>/dev/nulls
uci -q set openclash.config.redirect_dns=0
}
[ "$(uci get dhcp.@dnsmasq[0].cachesize 2>/dev/null)" = "0" ] && {
uci delete dhcp.@dnsmasq[0].cachesize >/dev/null 2>&1
[ "$(uci -q get dhcp.@dnsmasq[0].cachesize)" = "0" ] && {
uci -q delete dhcp.@dnsmasq[0].cachesize
}
[ "$1" -eq 1 ] && {
if [ -s "/tmp/resolv.conf.d/resolv.conf.auto" ] && [ -n "$(grep "nameserver" /tmp/resolv.conf.d/resolv.conf.auto)" ]; then
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.d/resolv.conf.auto >/dev/null 2>&1
uci -q set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.d/resolv.conf.auto
elif [ -s "/tmp/resolv.conf.auto" ] && [ -n "$(grep "nameserver" /tmp/resolv.conf.auto)" ]; then
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto >/dev/null 2>&1
uci -q set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto
else
rm -rf /tmp/resolv.conf.auto 2>/dev/null
rm -rf /tmp/resolv.conf.auto
touch /tmp/resolv.conf.auto 2>/dev/null
cat >> "/tmp/resolv.conf.auto" <<-EOF
# Interface lan
nameserver 114.114.114.114
nameserver 119.29.29.29
EOF
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto >/dev/null 2>&1
uci -q set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto
fi
uci set dhcp.@dnsmasq[0].noresolv=0 >/dev/null 2>&1
uci -q set dhcp.@dnsmasq[0].noresolv=0
}
uci commit dhcp
uci commit openclash
rm -rf /tmp/dnsmasq.d/dnsmasq_openclash.conf >/dev/null 2>&1
rm -rf /tmp/dnsmasq.d/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1
uci -q commit dhcp
uci -q commit openclash
rm -rf /tmp/dnsmasq.d/dnsmasq_openclash.conf
rm -rf /tmp/dnsmasq.d/dnsmasq_openclash_custom_domain.conf
}
kill_clash()
@ -706,14 +706,49 @@ yml_custom_rule_provider()
fi
}
#获取订阅配置
sub_info_get()
{
local section="$1" address enabled name
config_get_bool "enabled" "$section" "enabled" "1"
config_get "address" "$section" "address" ""
config_get "name" "$section" "name" ""
if [ "$subscribe_enable" = "1" ]; then
return
fi
if [ "$enabled" -eq 0 ]; then
return
fi
if [ -z "$address" ]; then
return
fi
if [ -z "$name" ]; then
CONFIG_NAME="config"
RAW_CONFIG_FILE="/etc/openclash/config/config.yaml"
CONFIG_FILE="/etc/openclash/config.yaml"
else
CONFIG_NAME="$name"
RAW_CONFIG_FILE="/etc/openclash/config/$name.yaml"
CONFIG_FILE="/etc/openclash/$name.yaml"
fi
uci -q set openclash.config.config_path="$RAW_CONFIG_FILE"
uci -q commit openclash
subscribe_enable=1
}
#配置文件选择
config_choose()
{
if [ -z "$RAW_CONFIG_FILE" ] || [ ! -f "$RAW_CONFIG_FILE" ]; then
CONFIG_NAME=$(ls -lt /etc/openclash/config/ | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}')
if [ -n "$CONFIG_NAME" ]; then
uci set openclash.config.config_path="/etc/openclash/config/$CONFIG_NAME"
uci commit openclash
uci -q set openclash.config.config_path="/etc/openclash/config/$CONFIG_NAME"
uci -q commit openclash
RAW_CONFIG_FILE="/etc/openclash/config/$CONFIG_NAME"
CONFIG_FILE="/etc/openclash/$CONFIG_NAME"
fi
@ -721,8 +756,10 @@ fi 2>/dev/null
CONFIG_NAME=$(echo "$RAW_CONFIG_FILE" |awk -F '/' '{print $5}' 2>/dev/null)
if [ ! -f "$RAW_CONFIG_FILE" ]; then
subscribe_info=$(uci get openclash.@config_subscribe[0].address 2>/dev/null)
if [ -n "$subscribe_info" ]; then
config_load "openclash"
config_foreach sub_info_get "config_subscribe"
subscribe_auto_update=$(uci get openclash.config.auto_update 2>/dev/null)
if [ "$subscribe_enable" = "1" ] && [ "$subscribe_auto_update" -eq 1 ]; then
echo "配置文件不存在,您已设置订阅信息,准备开始下载..." >$START_LOG
sleep 3
nohup /usr/share/openclash/openclash.sh &
@ -745,7 +782,7 @@ begin
YAML.load_file('$RAW_CONFIG_FILE');
rescue Exception => e
puts '${LOGTIME} Error: Unable To Parse Config File ' + e.message
system 'rm -rf ${CONFIG_FILE} 2>/dev/null'
system 'rm -rf ${CONFIG_FILE}'
end
" 2>/dev/null >> $LOG_FILE
if [ $? -ne 0 ]; then
@ -781,7 +818,7 @@ yml_other_rules_get()
#运行模式处理
do_run_mode()
{
en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
en_mode=$(uci -q get openclash.config.en_mode)
if [ "$en_mode" = "fake-ip-tun" ]; then
en_mode_tun="1"
@ -823,16 +860,16 @@ do_run_file()
game_core_path="/etc/openclash/core/clash_game"
geoip_path="/etc/openclash/Country.mmdb"
chnr_path="/etc/openclash/china_ip_route.ipset"
rm -rf "/tmp/etc/openclash" 2>/dev/null
rm -rf "/tmp/etc/openclash"
else
dev_core_path="/tmp/etc/openclash/core/clash"
tun_core_path="/tmp/etc/openclash/core/clash_tun"
game_core_path="/tmp/etc/openclash/core/clash_game"
geoip_path="/tmp/etc/openclash/Country.mmdb"
chnr_path="/tmp/etc/openclash/china_ip_route.ipset"
rm -rf "/etc/openclash/Country.mmdb" 2>/dev/null
rm -rf "/etc/openclash/china_ip_route.ipset" 2>/dev/null
rm -rf "/etc/openclash/core" 2>/dev/null
rm -rf "/etc/openclash/Country.mmdb"
rm -rf "/etc/openclash/china_ip_route.ipset"
rm -rf "/etc/openclash/core"
fi
rm -rf "/etc/openclash/clash" 2>/dev/null
@ -856,7 +893,7 @@ do_run_file()
if [ "$proxy_mode" = "script" ] || [ "$rule_name" = "ConnersHua" ] || [ "$rule_name" = "lhie1" ] || [ -n "$(ruby_read "$CONFIG_FILE" "['rules'].grep(/^RULE-SET,/)")" ]; then
if [ "$en_mode_tun" != "2" ]; then
rm -rf "/etc/openclash/clash" 2>/dev/null
rm -rf "/etc/openclash/clash"
ln -s "$tun_core_path" /etc/openclash/clash 2>/dev/null
core_type="Tun"
core_start_log="检测到配置了【Tun】内核专属功能调用【Tun】内核启动..."
@ -903,7 +940,7 @@ do_run_file()
[ ! -f "$CLASH" ] && {
echo "检测到内核文件不存在,准备开始下载..." >$START_LOG
nofile=1
rm -rf "/tmp/clash_last_version" 2>/dev/null
rm -rf "/tmp/clash_last_version"
nohup /usr/share/openclash/openclash_core.sh "$core_type" &
}
@ -969,8 +1006,8 @@ start_run_core()
capabilties="cap_sys_resource,cap_dac_override,cap_net_raw,cap_net_bind_service,cap_net_admin"
capsh --caps="${capabilties}+eip" -- -c "capsh --user=nobody --addamb='${capabilties}' -- -c 'nohup $CLASH -d $CLASH_CONFIG -f \"$CONFIG_FILE\" >> $LOG_FILE 2>&1 &'" >> $LOG_FILE 2>&1
fi
uci set openclash.config.config_reload=1 2>/dev/null
uci commit openclash
uci -q set openclash.config.config_reload=1
uci -q commit openclash
}
check_core_status()
@ -1023,41 +1060,41 @@ raw_config_start()
if [ "$en_mode" = "redir-host" ]; then
case $en_mode_tun in
"1")
uci set openclash.config.en_mode=redir-host-tun
uci -q set openclash.config.en_mode=redir-host-tun
;;
"2")
uci set openclash.config.en_mode=redir-host-vpn
uci -q set openclash.config.en_mode=redir-host-vpn
;;
"3")
uci set openclash.config.en_mode=redir-host-mix
uci -q set openclash.config.en_mode=redir-host-mix
;;
*)
uci set openclash.config.en_mode=redir-host
uci -q set openclash.config.en_mode=redir-host
esac
elif [ "$en_mode" = "fake-ip" ]; then
case $en_mode_tun in
"1")
uci set openclash.config.en_mode=fake-ip-tun
uci -q set openclash.config.en_mode=fake-ip-tun
;;
"2")
uci set openclash.config.en_mode=fake-ip-vpn
uci -q set openclash.config.en_mode=fake-ip-vpn
;;
"3")
uci set openclash.config.en_mode=fake-ip-mix
uci -q set openclash.config.en_mode=fake-ip-mix
;;
*)
uci set openclash.config.en_mode=fake-ip
uci -q set openclash.config.en_mode=fake-ip
esac
fi
dase=$(ruby_read "$CONFIG_FILE" "['secret']")
uci set openclash.config.dashboard_password="$dase" 2>/dev/null
uci -q set openclash.config.dashboard_password="$dase"
cn_port=$(ruby_read "$CONFIG_FILE" "['external-controller'].split(':')[1]")
uci set openclash.config.cn_port="$cn_port" 2>/dev/null
uci -q set openclash.config.cn_port="$cn_port"
uci set openclash.config.proxy_port="$proxy_port"
uci set openclash.config.restricted_mode=1
uci -q set openclash.config.proxy_port="$proxy_port"
uci -q set openclash.config.restricted_mode=1
uci commit openclash
}
@ -1202,21 +1239,21 @@ if [ "$(iptables -t nat -nL PREROUTING --line-number | grep "redir port $DNSPORT
done
fi
if [ -z "$(uci get firewall.openclash 2>/dev/null)" ] || [ -z "$(uci get ucitrack.@openclash[-1].init 2>/dev/null)" ]; then
uci delete ucitrack.@openclash[-1] >/dev/null 2>&1
uci add ucitrack openclash >/dev/null 2>&1
uci set ucitrack.@openclash[-1].init=openclash >/dev/null 2>&1
uci commit ucitrack >/dev/null 2>&1
uci delete firewall.openclash >/dev/null 2>&1
uci set firewall.openclash=include >/dev/null 2>&1
uci set firewall.openclash.type=script >/dev/null 2>&1
uci set firewall.openclash.path=/var/etc/openclash.include >/dev/null 2>&1
uci set firewall.openclash.reload=1 >/dev/null 2>&1
if [ -z "$(uci -q get firewall.openclash)" ] || [ -z "$(uci -q get ucitrack.@openclash[-1].init)" ]; then
uci -q delete ucitrack.@openclash[-1]
uci -q add ucitrack openclash
uci -q set ucitrack.@openclash[-1].init=openclash
uci -q commit ucitrack
uci -q delete firewall.openclash
uci -q set firewall.openclash=include
uci -q set firewall.openclash.type=script
uci -q set firewall.openclash.path=/var/etc/openclash.include
uci -q set firewall.openclash.reload=1
fi
if [ "$(uci get firewall.@defaults[0].forward)" != "ACCEPT" ]; then
uci set firewall.@defaults[0].forward=ACCEPT >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
if [ "$(uci -q get firewall.@defaults[0].forward)" != "ACCEPT" ]; then
uci -q set firewall.@defaults[0].forward=ACCEPT
uci -q commit firewall
/etc/init.d/firewall reload >/dev/null 2>&1
fi
@ -1233,23 +1270,23 @@ fi
#lan_ac
if [ "$operation_mode" = "redir-host" ] && [ "$en_mode" = "redir-host" ]; then
if [ "$lan_ac_mode" = "0" ]; then
if [ -n "$(uci get openclash.config.lan_ac_black_ips 2>/dev/null)" ]; then
if [ -n "$(uci -q get openclash.config.lan_ac_black_ips)" ]; then
ipset create lan_ac_black_ips hash:net
config_load "openclash"
config_list_foreach "config" "lan_ac_black_ips" ac_add "lan_ac_black_ips"
fi
if [ -n "$(uci get openclash.config.lan_ac_black_macs 2>/dev/null)" ]; then
if [ -n "$(uci -q get openclash.config.lan_ac_black_macs)" ]; then
ipset create lan_ac_black_macs hash:mac
config_load "openclash"
config_list_foreach "config" "lan_ac_black_macs" ac_add "lan_ac_black_macs"
fi
elif [ "$lan_ac_mode" = "1" ]; then
if [ -n "$(uci get openclash.config.lan_ac_white_ips 2>/dev/null)" ]; then
if [ -n "$(uci -q get openclash.config.lan_ac_white_ips)" ]; then
ipset create lan_ac_white_ips hash:net
config_load "openclash"
config_list_foreach "config" "lan_ac_white_ips" ac_add "lan_ac_white_ips"
fi
if [ -n "$(uci get openclash.config.lan_ac_white_macs 2>/dev/null)" ]; then
if [ -n "$(uci -q get openclash.config.lan_ac_white_macs)" ]; then
ipset create lan_ac_white_macs hash:mac
config_load "openclash"
config_list_foreach "config" "lan_ac_white_macs" ac_add "lan_ac_white_macs"
@ -1258,7 +1295,7 @@ if [ "$operation_mode" = "redir-host" ] && [ "$en_mode" = "redir-host" ]; then
fi
#wan ac
if [ -n "$(uci get openclash.config.wan_ac_black_ips 2>/dev/null)" ]; then
if [ -n "$(uci -q get openclash.config.wan_ac_black_ips)" ]; then
ipset create wan_ac_black_ips hash:net
config_load "openclash"
config_list_foreach "config" "wan_ac_black_ips" ac_add "wan_ac_black_ips"
@ -1472,7 +1509,7 @@ config_foreach firewall_rule_exclude "rule"
revert_firewall()
{
rm -rf /var/etc/openclash.include 2>/dev/null
rm -rf /var/etc/openclash.include
#ipv4
@ -1565,42 +1602,42 @@ revert_firewall()
get_config()
{
rule_source=$(uci get openclash.config.rule_source 2>/dev/null)
enable_custom_dns=$(uci get openclash.config.enable_custom_dns 2>/dev/null)
enable_custom_clash_rules=$(uci get openclash.config.enable_custom_clash_rules 2>/dev/null)
da_password=$(uci get openclash.config.dashboard_password 2>/dev/null)
cn_port=$(uci get openclash.config.cn_port 2>/dev/null)
proxy_port=$(uci get openclash.config.proxy_port 2>/dev/null)
proxy_mode=$(uci get openclash.config.proxy_mode 2>/dev/null)
ipv6_enable=$(uci get openclash.config.ipv6_enable 2>/dev/null)
http_port=$(uci get openclash.config.http_port 2>/dev/null)
socks_port=$(uci get openclash.config.socks_port 2>/dev/null)
enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null)
lan_ip=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
rule_source=$(uci -q get openclash.config.rule_source)
enable_custom_dns=$(uci -q get openclash.config.enable_custom_dns)
enable_custom_clash_rules=$(uci -q get openclash.config.enable_custom_clash_rules)
da_password=$(uci -q get openclash.config.dashboard_password)
cn_port=$(uci -q get openclash.config.cn_port)
proxy_port=$(uci -q get openclash.config.proxy_port)
proxy_mode=$(uci -q get openclash.config.proxy_mode)
ipv6_enable=$(uci -q get openclash.config.ipv6_enable)
http_port=$(uci -q get openclash.config.http_port)
socks_port=$(uci -q get openclash.config.socks_port)
enable_redirect_dns=$(uci -q get openclash.config.enable_redirect_dns)
lan_ip=$(uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null)
wan_ip4=$(ifconfig | grep 'inet addr' | awk '{print $2}' | cut -d: -f2 2>/dev/null)
lan_ip6=$(ifconfig | grep 'inet6 addr' | awk '{print $3}' 2>/dev/null)
disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null)
log_level=$(uci get openclash.config.log_level 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)
operation_mode=$(uci get openclash.config.operation_mode 2>/dev/null)
lan_ac_mode=$(uci get openclash.config.lan_ac_mode 2>/dev/null)
enable_rule_proxy=$(uci get openclash.config.enable_rule_proxy 2>/dev/null)
stack_type=$(uci get openclash.config.stack_type 2>/dev/null)
china_ip_route=$(uci get openclash.config.china_ip_route 2>/dev/null)
small_flash_memory=$(uci get openclash.config.small_flash_memory 2>/dev/null)
mixed_port=$(uci get openclash.config.mixed_port 2>/dev/null)
interface_name=$(uci get openclash.config.interface_name 2>/dev/null)
common_ports=$(uci get openclash.config.common_ports 2>/dev/null)
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
[ -z "$dns_port" ] && dns_port=7874 && uci set openclash.config.dns_port=7874 2>/dev/null
uci set openclash.config.restricted_mode=0 && uci commit openclash
disable_masq_cache=$(uci -q get openclash.config.disable_masq_cache)
log_level=$(uci -q get openclash.config.log_level)
intranet_allowed=$(uci -q get openclash.config.intranet_allowed)
enable_udp_proxy=$(uci -q get openclash.config.enable_udp_proxy)
operation_mode=$(uci -q get openclash.config.operation_mode)
lan_ac_mode=$(uci -q get openclash.config.lan_ac_mode)
enable_rule_proxy=$(uci -q get openclash.config.enable_rule_proxy)
stack_type=$(uci -q get openclash.config.stack_type)
china_ip_route=$(uci -q get openclash.config.china_ip_route)
small_flash_memory=$(uci -q get openclash.config.small_flash_memory)
mixed_port=$(uci -q get openclash.config.mixed_port)
interface_name=$(uci -q get openclash.config.interface_name)
common_ports=$(uci -q get openclash.config.common_ports)
dns_port=$(uci -q get openclash.config.dns_port)
[ -z "$dns_port" ] && dns_port=7874 && uci -q set openclash.config.dns_port=7874
uci -q set openclash.config.restricted_mode=0 && uci -q commit openclash
}
start()
{
enable=$(uci get openclash.config.enable 2>/dev/null)
enable=$(uci -q get openclash.config.enable)
[ "$enable" != "1" ] && echo "${LOGTIME} Warning: OpenClash Now Disabled, Need Start From Luci Page, Exit..." >> $LOG_FILE && del_lock && exit 0
config_choose
@ -1655,29 +1692,29 @@ start()
echo "第十一步: 添加计划任务,启动进程守护程序..." >$START_LOG
add_cron
if [ -z "$(uci get dhcp.lan.dhcpv6 2>/dev/null)" ] && [ "$(uci get openclash.config.restricted_mode 2>/dev/null)" != "1" ]; then
if [ -z "$(uci -q get dhcp.lan.dhcpv6)" ] && [ "$(uci -q get openclash.config.restricted_mode)" != "1" ]; then
echo "OpenClash 启动成功,请等待服务器上线!" >$START_LOG
echo "${LOGTIME} OpenClash Start Successful" >> $LOG_FILE
sleep 5
elif [ -n "$(uci get dhcp.lan.dhcpv6 2>/dev/null)" ]; then
elif [ -n "$(uci -q get dhcp.lan.dhcpv6)" ]; then
echo "OpenClash 启动成功检测到您启用了IPV6的DHCP服务可能会造成连接异常" >$START_LOG
echo "${LOGTIME} Warning: OpenClash Start Successful, Please Note That Network May Abnormal With IPV6's DHCP Server" >> $LOG_FILE
sleep 5
fi
if [ "$(uci get openclash.config.restricted_mode 2>/dev/null)" = "1" ]; then
if [ "$(uci -q get openclash.config.restricted_mode)" = "1" ]; then
echo "OpenClash 使用原始配置文件启动成功,部分设置可能未生效!" >$START_LOG
echo "${LOGTIME} Warning: OpenClash Start Successful With Raw Config File, Please Note That It's Restricted Mode Now" >> $LOG_FILE
sleep 5
fi
echo "OpenClash Already Start"
echo "" >$START_LOG
rm -rf /tmp/yaml_* 2>/dev/null
rm -rf /tmp/yaml_*
}
stop()
{
enable=$(uci get openclash.config.enable 2>/dev/null)
enable=$(uci -q get openclash.config.enable)
echo "OpenClash 开始关闭..." >$START_LOG
echo "第一步: 备份当前节点状态..." >$START_LOG
@ -1698,32 +1735,32 @@ stop()
fi
echo "第五步: 重启 Dnsmasq 程序..." >$START_LOG
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
redirect_dns=$(uci get openclash.config.redirect_dns 2>/dev/null)
masq_cache=$(uci get openclash.config.masq_cache 2>/dev/null)
dns_port=$(uci -q get openclash.config.dns_port)
redirect_dns=$(uci -q get openclash.config.redirect_dns)
masq_cache=$(uci -q get openclash.config.masq_cache)
revert_dns "$redirect_dns" "$masq_cache" "$dns_port" "$enable"
/etc/init.d/dnsmasq restart >/dev/null 2>&1
echo "第六步:删除 OpenClash 残留文件..." >$START_LOG
if [ "$enable" != "1" ]; then
rm -rf $LOG_FILE 2>/dev/null
rm -rf /tmp/openclash_debug.log 2>/dev/null
rm -rf /www/luci-static/openclash 2>/dev/null
rm -rf /tmp/openclash_last_version 2>/dev/null
rm -rf /tmp/clash_last_version 2>/dev/null
rm -rf /tmp/Proxy_Group 2>/dev/null
rm -rf /tmp/rules_name 2>/dev/null
rm -rf /tmp/rule_providers_name 2>/dev/null
rm -rf /tmp/openclash_fake_filter.list 2>/dev/null
rm -rf /tmp/openclash_servers_fake_filter.conf 2>/dev/null
rm -rf $LOG_FILE
rm -rf /tmp/openclash_debug.log
rm -rf /www/luci-static/openclash
rm -rf /tmp/openclash_last_version
rm -rf /tmp/clash_last_version
rm -rf /tmp/Proxy_Group
rm -rf /tmp/rules_name
rm -rf /tmp/rule_providers_name
rm -rf /tmp/openclash_fake_filter.list
rm -rf /tmp/openclash_servers_fake_filter.conf
del_lock
echo "OpenClash 关闭成功!" >$START_LOG
sleep 5
fi
del_cron
rm -rf /tmp/yaml_* 2>/dev/null
rm -rf $START_LOG 2>/dev/null
rm -rf /tmp/yaml_*
rm -rf $START_LOG
echo "OpenClash Already Stop"
}

View File

@ -1,37 +1,37 @@
#!/bin/sh
uci delete ucitrack.@openclash[-1] >/dev/null 2>&1
uci add ucitrack openclash >/dev/null 2>&1
uci set ucitrack.@openclash[-1].init=openclash >/dev/null 2>&1
uci commit ucitrack >/dev/null 2>&1
uci delete firewall.openclash >/dev/null 2>&1
uci set firewall.openclash=include >/dev/null 2>&1
uci set firewall.openclash.type=script >/dev/null 2>&1
uci set firewall.openclash.path=/var/etc/openclash.include >/dev/null 2>&1
uci set firewall.openclash.reload=1 >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
uci -q delete ucitrack.@openclash[-1]
uci -q add ucitrack openclash
uci -q set ucitrack.@openclash[-1].init=openclash
uci -q commit ucitrack
uci -q delete firewall.openclash
uci -q set firewall.openclash=include
uci -q set firewall.openclash.type=script
uci -q set firewall.openclash.path=/var/etc/openclash.include
uci -q set firewall.openclash.reload=1
uci -q commit firewall
mkdir -p /etc/openclash/config >/dev/null 2>&1
mkdir -p /etc/openclash/proxy_provider >/dev/null 2>&1
mkdir -p /etc/openclash/backup >/dev/null 2>&1
mkdir -p /etc/openclash/core >/dev/null 2>&1
mkdir -p /etc/openclash/history >/dev/null 2>&1
mkdir -p /usr/share/openclash/backup >/dev/null 2>&1
mkdir -p /etc/openclash/config
mkdir -p /etc/openclash/proxy_provider
mkdir -p /etc/openclash/backup
mkdir -p /etc/openclash/core
mkdir -p /etc/openclash/history
mkdir -p /usr/share/openclash/backup
cp "/etc/config/openclash" "/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules.list" "/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_hosts.list" "/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_fake_filter.list" "/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp "/etc/openclash/custom/openclash_custom_domain_dns.list" "/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
cp -f "/etc/config/openclash" "/usr/share/openclash/backup/openclash" >/dev/null 2>&1
cp -f "/etc/openclash/custom/openclash_custom_rules.list" "/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1
cp -f "/etc/openclash/custom/openclash_custom_rules_2.list" "/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1
cp -f "/etc/openclash/custom/openclash_custom_hosts.list" "/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1
cp -f "/etc/openclash/custom/openclash_custom_fake_filter.list" "/usr/share/openclash/backup/openclash_custom_fake_filter.list" >/dev/null 2>&1
cp -f "/etc/openclash/custom/openclash_custom_domain_dns.list" "/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
mkdir -p /lib/upgrade/keep.d >/dev/null 2>&1
mkdir -p /lib/upgrade/keep.d
cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF
/etc/openclash/
EOF
if [ -f "/tmp/openclash.bak" ]; then
mv "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1
mv -f "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1
cp -rf "/tmp/openclash/." "/etc/openclash/" >/dev/null 2>&1
cp -rf "/tmp/openclash_config/." "/etc/openclash/config/" >/dev/null 2>&1
cp -rf "/tmp/openclash_core/." "/etc/openclash/core/" >/dev/null 2>&1
@ -39,19 +39,54 @@ if [ -f "/tmp/openclash.bak" ]; then
cp -rf "/tmp/openclash_proxy_provider/." "/etc/openclash/proxy_provider/" >/dev/null 2>&1
cp -rf "/tmp/openclash_rule_provider/." "/etc/openclash/rule_provider/" >/dev/null 2>&1
cp -rf "/tmp/openclash_game_rules/." "/etc/openclash/game_rules/" >/dev/null 2>&1
mv "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_fake_filter.list.bak" "/etc/openclash/custom/openclash_custom_fake_filter.list" >/dev/null 2>&1
mv "/tmp/openclash_custom_domain_dns.list.bak" "/etc/openclash/custom/openclash_custom_domain_dns.list" >/dev/null 2>&1
rm -rf "/etc/openclash/openclash" >/dev/null 2>&1
rm -rf "/etc/openclash/fake_filter.list" >/dev/null 2>&1
rm -rf "/etc/openclash/openclash_servers_fake_filter.conf" >/dev/null 2>&1
rm -rf /tmp/openclash* >/dev/null 2>&1
mv -f "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_fake_filter.list.bak" "/etc/openclash/custom/openclash_custom_fake_filter.list" >/dev/null 2>&1
mv -f "/tmp/openclash_custom_domain_dns.list.bak" "/etc/openclash/custom/openclash_custom_domain_dns.list" >/dev/null 2>&1
rm -rf "/etc/openclash/openclash"
rm -rf "/etc/openclash/fake_filter.list"
rm -rf "/etc/openclash/openclash_servers_fake_filter.conf"
rm -rf /tmp/openclash*
fi
uci set openclash.config.enable=0 >/dev/null 2>&1
uci commit openclash >/dev/null 2>&1
source "/etc/openwrt_release"
case "${DISTRIB_ARCH}" in
aarch64_*)
CORE_ARCH="linux-armv8"
;;
arm_*_neon-vfp*)
CORE_ARCH="linux-armv7"
;;
arm_*_neon|arm_*_vfp*)
CORE_ARCH="linux-armv6"
;;
arm*)
CORE_ARCH="linux-armv5"
;;
i386_*)
CORE_ARCH="linux-386"
;;
mips64_*)
CORE_ARCH="linux-mips64"
;;
mips_*)
CORE_ARCH="linux-mips-softfloat"
;;
mipsel_*)
CORE_ARCH="linux-mipsle-softfloat"
;;
x86_64)
CORE_ARCH="linux-amd64"
;;
*)
CORE_ARCH="0"
;;
esac
uci -q set openclash.config.core_version="${CORE_ARCH}"
uci -q set openclash.config.enable=0
uci -q commit openclash
rm -f /tmp/luci-indexcache
exit 0
exit 0

View File

@ -220,11 +220,13 @@ EOF
elif [ ! -f "$CFG_FILE" ]; then
echo "配置文件格式校验失败..." > $START_LOG
sleep 3
change_dns
config_error
elif ! "$(ruby_read "$CFG_FILE" ".key?('proxies')")" && ! "$(ruby_read "$CFG_FILE" ".key?('proxy-providers')")" ; then
echo "${LOGTIME} Error: Updated Config 【$name】 Has No Proxy Field, Update Exit..." >> $LOG_FILE
echo "配置文件节点部分校验失败..." > $START_LOG
sleep 3
change_dns
config_error
else
change_dns

View File

@ -67,17 +67,31 @@
sleep 3
exit 0
elif [ ! -f "/tmp/rules.yaml" ]; then
echo "$rule_name 规则文件格式校验失败,请稍后再试..." > $START_LOG
echo "错误:$rule_name 规则文件格式校验失败,请稍后再试..." > $START_LOG
rm -rf /tmp/rules.yaml >/dev/null 2>&1
sleep 3
exit 0
elif ! "$(ruby_read "/tmp/rules.yaml" ".key?('rules')")" ; then
echo "${LOGTIME} Error: Updated Others Rules 【$rule_name】 Has No Rules Field, Update Exit..." >> $LOG_FILE
echo "$rule_name 规则文件规则部分校验失败,请稍后再试..." > $START_LOG
echo "错误:$rule_name 规则文件规则部分校验失败,请稍后再试..." > $START_LOG
rm -rf /tmp/rules.yaml >/dev/null 2>&1
sleep 3
exit 0
#校验是否含有新策略组
elif ! "$(ruby -ryaml -E UTF-8 -e "
Value = YAML.load_file('/usr/share/openclash/res/${rule_name}.yaml');
Value_1 = YAML.load_file('/tmp/rules.yaml');
OLD_GROUP = Value['rules'].collect{|x| x.split(',')[2] or x.split(',')[1]}.uniq;
NEW_GROUP = Value_1['rules'].collect{|x| x.split(',')[2] or x.split(',')[1]}.uniq;
puts (OLD_GROUP | NEW_GROUP).eql?(OLD_GROUP)
")" ; then
echo "${LOGTIME} Error: Updated Others Rules 【$rule_name】 Has Incompatible Proxy-Group, Update Exit, Please Wait For OpenClash Update To Adapt..." >> $LOG_FILE
echo "错误:$rule_name 规则文件含有未支持的新策略组更新停止请等待OpenClash版本更新适配..." > $START_LOG
rm -rf /tmp/rules.yaml >/dev/null 2>&1
sleep 3
exit 0
fi
#取出规则部分
ruby_read "/tmp/rules.yaml" ".select {|x| 'rule-providers' == x or 'script' == x or 'rules' == x }.to_yaml" > "$OTHER_RULE_FILE"
#合并