OpenClash: bump to v0.38.4-beta
This commit is contained in:
parent
248c551d79
commit
e26d19a495
@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-openclash
|
||||
PKG_VERSION:=0.38.1
|
||||
PKG_VERSION:=0.38.4
|
||||
PKG_RELEASE:=beta
|
||||
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>
|
||||
|
||||
@ -33,6 +33,7 @@ define Build/Prepare
|
||||
chmod -R 0755 $(PKG_BUILD_DIR)/files/usr/share/openclash/
|
||||
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/config >/dev/null 2>&1
|
||||
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/proxy_provider >/dev/null 2>&1
|
||||
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/rule_provider >/dev/null 2>&1
|
||||
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/backup >/dev/null 2>&1
|
||||
mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/core >/dev/null 2>&1
|
||||
mkdir -p $(PKG_BUILD_DIR)/files/usr/share/openclash/backup >/dev/null 2>&1
|
||||
@ -57,7 +58,7 @@ if [ -f "/etc/config/openclash" ]; then
|
||||
cp "/etc/config/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1
|
||||
cp "/etc/config/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1
|
||||
cp "/etc/config/openclash_custom_fake_filter.list" "/tmp/openclash_custom_fake_filter.list.bak" >/dev/null 2>&1
|
||||
cp "/etc/openclash/history" "/tmp/openclash_history.bak" >/dev/null 2>&1
|
||||
cp -r "/etc/openclash/history" "/tmp/openclash_history" >/dev/null 2>&1
|
||||
fi
|
||||
if [ -f "/etc/openclash/custom/openclash_custom_rules.list" ]; then
|
||||
cp "/etc/openclash/custom/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1
|
||||
@ -81,8 +82,10 @@ uci set firewall.openclash.reload=1 >/dev/null 2>&1
|
||||
uci commit firewall >/dev/null 2>&1
|
||||
mkdir -p /etc/openclash/config >/dev/null 2>&1
|
||||
mkdir -p /etc/openclash/proxy_provider >/dev/null 2>&1
|
||||
mkdir -p /etc/openclash/rule_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
|
||||
|
||||
cp "/etc/config/openclash" "/usr/share/openclash/backup/openclash" >/dev/null 2>&1
|
||||
@ -97,7 +100,10 @@ if [ -f "/tmp/openclash.bak" ]; then
|
||||
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_history.bak" "/etc/openclash/history" >/dev/null 2>&1
|
||||
if [ -d "/tmp/openclash_history/" ]; then
|
||||
rm -rf "/etc/openclash/history" >/dev/null 2>&1
|
||||
mv "/tmp/openclash_history" "/etc/openclash/history" >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ -f "/tmp/config.yaml" ]; then
|
||||
mv "/tmp/config.yaml" "/etc/openclash/config/config.yaml" >/dev/null 2>&1
|
||||
@ -111,6 +117,10 @@ if [ -d "/tmp/openclash_proxy_provider/" ]; then
|
||||
rm -rf "/etc/openclash/proxy_provider" >/dev/null 2>&1
|
||||
mv "/tmp/openclash_proxy_provider" "/etc/openclash/proxy_provider" >/dev/null 2>&1
|
||||
fi
|
||||
if [ -d "/tmp/openclash_rule_provider/" ]; then
|
||||
rm -rf "/etc/openclash/rule_provider" >/dev/null 2>&1
|
||||
mv "/tmp/openclash_rule_provider" "/etc/openclash/rule_provider" >/dev/null 2>&1
|
||||
fi
|
||||
if [ -d "/tmp/openclash_game_rules/" ]; then
|
||||
rm -rf "/etc/openclash/game_rules" >/dev/null 2>&1
|
||||
mv "/tmp/openclash_game_rules" "/etc/openclash/game_rules" >/dev/null 2>&1
|
||||
@ -132,6 +142,7 @@ cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF
|
||||
/etc/openclash/config/
|
||||
/etc/openclash/game_rules/
|
||||
/etc/openclash/proxy_provider/
|
||||
/etc/openclash/rule_provider/
|
||||
EOF
|
||||
uci set openclash.config.enable=0 >/dev/null 2>&1
|
||||
uci commit openclash >/dev/null 2>&1
|
||||
@ -142,12 +153,15 @@ 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
|
||||
mv "/etc/openclash/core" "/tmp/openclash_core" >/dev/null 2>&1
|
||||
mv "/etc/openclash/config.yaml" "/tmp/config.yaml" >/dev/null 2>&1
|
||||
mv "/etc/openclash/config" "/tmp/openclash_config" >/dev/null 2>&1
|
||||
mv "/etc/openclash/proxy_provider" "/tmp/openclash_proxy_provider" >/dev/null 2>&1
|
||||
mv "/etc/openclash/rule_provider" "/tmp/openclash_rule_provider" >/dev/null 2>&1
|
||||
mv "/etc/openclash/game_rules" "/tmp/openclash_game_rules" >/dev/null 2>&1
|
||||
mv "/etc/openclash/history" "/tmp/openclash_history.bak" >/dev/null 2>&1
|
||||
mv "/etc/openclash/history" "/tmp/openclash_history" >/dev/null 2>&1
|
||||
cp "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1
|
||||
cp "/etc/config/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1
|
||||
cp "/etc/config/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1
|
||||
@ -164,6 +178,7 @@ if [ -f "/tmp/openclash_update.sh" ]; then
|
||||
rm -rf /etc/openclash/config >/dev/null 2>&1
|
||||
rm -rf /etc/openclash/backup >/dev/null 2>&1
|
||||
rm -rf /etc/openclash/proxy_provider >/dev/null 2>&1
|
||||
rm -rf /etc/openclash/rule_provider >/dev/null 2>&1
|
||||
rm -rf /etc/openclash/game_rules >/dev/null 2>&1
|
||||
rm -rf /etc/openclash/history >/dev/null 2>&1
|
||||
else
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#!/bin/bash /etc/rc.common
|
||||
# Copyright (c) 2019 vernesong
|
||||
|
||||
START=99
|
||||
@ -14,6 +14,8 @@ START_LOG="/tmp/openclash_start.log"
|
||||
BACKUP_FILE="/etc/openclash/backup/$(uci get openclash.config.config_path 2>/dev/null |awk -F '/' '{print $5}' 2>/dev/null)"
|
||||
START_BACKUP="/tmp/config.sbak"
|
||||
CHANGE_FILE="/tmp/yaml_change.yaml"
|
||||
SCRIPT_FILE="/tmp/yaml_script.yaml"
|
||||
RULE_PROVIDER_FILE="/tmp/yaml_rule_provider.yaml"
|
||||
RULE_FILE="/tmp/yaml_rules.yaml"
|
||||
DNS_FILE="/tmp/yaml_dns.yaml"
|
||||
PROXY_FILE="/tmp/yaml_proxy.yaml"
|
||||
@ -84,6 +86,50 @@ revert_dns() {
|
||||
rm -rf /tmp/dnsmasq.d/dnsmasq_openclash.conf >/dev/null 2>&1
|
||||
}
|
||||
|
||||
kill_clash()
|
||||
{
|
||||
clash_pids=$(pidof clash|sed 's/$//g')
|
||||
for clash_pid in $clash_pids; do
|
||||
kill -9 "$clash_pid" 2>/dev/null
|
||||
done
|
||||
sleep 1
|
||||
}
|
||||
|
||||
field_cut()
|
||||
{
|
||||
local i lines end_len
|
||||
proxy_len=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null |sed -n 1p)
|
||||
provider_len=$(sed -n '/^proxy-providers:/=' "$3" 2>/dev/null)
|
||||
group_len=$(sed -n '/^proxy-groups:/=' "$3" 2>/dev/null)
|
||||
rule_len=$(sed -n '/^rules:/=' "$3" 2>/dev/null)
|
||||
rule_provider_len=$(sed -n '/^rule-providers:/=' "$3" 2>/dev/null)
|
||||
script_len=$(sed -n '/^script:/=' "$3" 2>/dev/null)
|
||||
lines="$proxy_len $provider_len $group_len $rule_len $rule_provider_len $script_len"
|
||||
|
||||
for i in $lines
|
||||
do
|
||||
if [ -z "$1" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
if [ "$1" -ge "$i" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$end_len" -gt "$i" ] || [ -z "$end_len" ]; then
|
||||
end_len="$i"
|
||||
fi
|
||||
done 2>/dev/null
|
||||
|
||||
if [ -n "$1" ] && [ -z "$end_len" ]; then
|
||||
end_len=$(sed -n '$=' "$3")
|
||||
elif [ -n "$end_len" ]; then
|
||||
end_len=$(expr "$end_len" - 1)
|
||||
fi
|
||||
sed -n "${1},${end_len}p" "$3" > "$2" 2>/dev/null
|
||||
sed -i "${1},${end_len}d" "$3" 2>/dev/null
|
||||
}
|
||||
|
||||
yml_check()
|
||||
{
|
||||
#格式替换
|
||||
@ -107,20 +153,24 @@ yml_check()
|
||||
fi
|
||||
|
||||
#位置检查
|
||||
proxy_len=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^proxy-provider:/=' "$3" 2>/dev/null)
|
||||
group_len=$(sed -n '/^Proxy Group:/=' "$3" 2>/dev/null)
|
||||
proxy_len=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null |sed -n 1p)
|
||||
provider_len=$(sed -n '/^proxy-providers:/=' "$3" 2>/dev/null)
|
||||
group_len=$(sed -n '/^proxy-groups:/=' "$3" 2>/dev/null)
|
||||
dns_len=$(sed -n '/^dns:/=' "$3" 2>/dev/null)
|
||||
rule_len=$(sed -n '/^Rule:/=' "$3" 2>/dev/null)
|
||||
rule_len=$(sed -n '/^rules:/=' "$3" 2>/dev/null)
|
||||
|
||||
if [ "$dns_len" -ge "$proxy_len" ] || [ "$dns_len" -ge "$rule_len" ] || [ "$dns_len" -ge "$group_len" ]; then
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: 不支持的配置文件, General 设置部分应位于开头,请根据模板修改后重试!" > $START_LOG
|
||||
echo "${LOGTIME} Unsupported Config, Please Check The General Setting's location And Try-again!" >> $LOG_FILE
|
||||
mv "$START_BACKUP" "$CONFIG_FILE"
|
||||
exit 0
|
||||
fi 2>/dev/null
|
||||
|
||||
if [ "$proxy_len" -ge "$rule_len" ] || [ "$provider_len" -ge "$rule_len" ]; then
|
||||
if [ "$proxy_len" -ge "$rule_len" ]; then
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: 不支持的配置文件,服务器节点设置部分应位于规则之前,请根据模板修改后重试!" > $START_LOG
|
||||
echo "${LOGTIME} Unsupported Config, Please Check The Proxy Setting's location And Try-again!" >> $LOG_FILE
|
||||
mv "$START_BACKUP" "$CONFIG_FILE"
|
||||
@ -128,59 +178,48 @@ yml_check()
|
||||
fi 2>/dev/null
|
||||
|
||||
if [ "$group_len" -ge "$rule_len" ] || [ "$proxy_len" -ge "$group_len" ]; then
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: 不支持的配置文件,策略组设置部分应位于规则之前、节点之后,请根据模板修改后重试!" > $START_LOG
|
||||
echo "${LOGTIME} Unsupported Config, Please Check The Group Setting's location And Try-again!" >> $LOG_FILE
|
||||
mv "$START_BACKUP" "$CONFIG_FILE"
|
||||
exit 0
|
||||
fi 2>/dev/null
|
||||
|
||||
#处理provider位置
|
||||
if [ ! -z "$provider_len" ]; then
|
||||
if [ "$provider_len" -ge "$proxy_len" ] && [ "$provider_len" -le "$group_len" ]; then
|
||||
awk '/^proxy-provider:/,/^Proxy Group:/{print}' "$3" | sed '/^Proxy Group:/d' >/tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/^Proxy Group:/i\proxy-provider-tag' "$3" 2>/dev/null
|
||||
sed -i '/^proxy-provider:/,/proxy-provider-tag/d' "$3" 2>/dev/null
|
||||
sed -i '/^Proxy:/i\proxy-provider:' "$3" 2>/dev/null
|
||||
sed -i 's/^proxy-provider://g' /tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/^ *$/d' /tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/proxy-provider:/r/tmp/backprovider.yaml' "$3" 2>/dev/null
|
||||
rm -rf /tmp/backprovider.yaml 2>/dev/null
|
||||
elif [ "$provider_len" -ge "$group_len" ] && [ "$provider_len" -le "$rule_len" ]; then
|
||||
awk '/^proxy-provider:/,/^Rule:/{print}' "$3" | sed '/^Rule:/d' >/tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/^Rule:/i\proxy-provider-tag' "$3" 2>/dev/null
|
||||
sed -i '/^proxy-provider:/,/proxy-provider-tag/d' "$3" 2>/dev/null
|
||||
if [ ! -z "$proxy_len" ]; then
|
||||
sed -i '/^Proxy:/i\proxy-provider:' "$3" 2>/dev/null
|
||||
else
|
||||
sed -i '/^Proxy Group:/i\proxy-provider:' "$3" 2>/dev/null
|
||||
fi
|
||||
sed -i 's/^proxy-provider://g' /tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/^ *$/d' /tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/proxy-provider:/r/tmp/backprovider.yaml' "$3" 2>/dev/null
|
||||
rm -rf /tmp/backprovider.yaml 2>/dev/null
|
||||
elif [ "$provider_len" -ge "$rule_len" ]; then
|
||||
sed -n '/^ \{0,\}proxy-provider:/,$p' "$3" >/tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-provider:/,$d' "$3" 2>/dev/null
|
||||
if [ ! -z "$proxy_len" ]; then
|
||||
sed -i '/^Proxy:/i\proxy-provider:' "$3" 2>/dev/null
|
||||
else
|
||||
sed -i '/^Proxy Group:/i\proxy-provider:' "$3" 2>/dev/null
|
||||
fi
|
||||
sed -i 's/^proxy-provider://g' /tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/^ *$/d' /tmp/backprovider.yaml 2>/dev/null
|
||||
sed -i '/proxy-provider:/r/tmp/backprovider.yaml' "$3" 2>/dev/null
|
||||
rm -rf /tmp/backprovider.yaml 2>/dev/null
|
||||
fi 2>/dev/null
|
||||
fi
|
||||
#处理proxy_provider位置
|
||||
if [ "$provider_len" -ge "$proxy_len" ] || [ "$provider_len" -ge "$group_len" ]; then
|
||||
field_cut "$provider_len" "$PROXY_PROVIDER_FILE" "$3"
|
||||
if [ -n "$proxy_len" ]; then
|
||||
sed -i '/^Proxy:/i\proxy-provider-tag' "$3" 2>/dev/null
|
||||
sed -i '/proxy-provider-tag/r/tmp/yaml_proxy_provider.yaml' "$3" 2>/dev/null
|
||||
sed -i '/proxy-provider-tag/d' "$3" 2>/dev/null
|
||||
elif [ -n "$group_len" ]; then
|
||||
sed -i '/^proxy-groups:/i\proxy-provider-tag' "$3" 2>/dev/null
|
||||
sed -i '/proxy-provider-tag/r/tmp/yaml_proxy_provider.yaml' "$3" 2>/dev/null
|
||||
sed -i '/proxy-provider-tag/d' "$3" 2>/dev/null
|
||||
fi
|
||||
fi 2>/dev/null
|
||||
|
||||
if [ ! -z "$provider_len" ]; then
|
||||
#处理rule_provider位置
|
||||
rule_provider_len=$(sed -n '/^rule-providers:/=' "$3" 2>/dev/null)
|
||||
if [ -n "$rule_provider_len" ]; then
|
||||
field_cut "$rule_provider_len" "$RULE_PROVIDER_FILE" "$3"
|
||||
fi 2>/dev/null
|
||||
|
||||
#处理script位置
|
||||
script_len=$(sed -n '/^script:/=' "$3" 2>/dev/null)
|
||||
if [ -n "$script_len" ]; then
|
||||
field_cut "$script_len" "$SCRIPT_FILE" "$3"
|
||||
fi 2>/dev/null
|
||||
|
||||
if [ -n "$provider_len" ]; then
|
||||
proxy_provider_mode=1
|
||||
fi
|
||||
|
||||
#自定义DNS还原
|
||||
if [ "$(grep -c '##Custom DNS##' "$3")" -gt 0 ] && [ "$2" = 0 ] && [ -f "$4" ]; then
|
||||
if [ "$proxy_provider_mode" -eq 1 ]; then
|
||||
awk '/^ {0,}nameserver:/,/proxy-provider:/{print}' "$4" | sed '/^proxy-provider:/d' >/tmp/backdns.config 2>/dev/null
|
||||
awk '/^ {0,}nameserver:/,/proxy-providers:/{print}' "$4" | sed '/^proxy-providers:/d' >/tmp/backdns.config 2>/dev/null
|
||||
else
|
||||
awk '/^ {0,}nameserver:/,/Proxy:/{print}' "$4" | sed '/^Proxy:/d' >/tmp/backdns.config 2>/dev/null
|
||||
fi
|
||||
@ -192,7 +231,7 @@ yml_check()
|
||||
|
||||
yml_dns_check
|
||||
|
||||
if [ ! -z "$(grep "^ \{1,\}port:" "$3")" ] || [ ! -z "$(grep "^ \{1,\}mode:" "$3")" ] || [ ! -z "$(grep "^ \{1,\}log-level:" "$3")" ]; then
|
||||
if [ -n "$(grep "^ \{1,\}port:" "$3")" ] || [ -n "$(grep "^ \{1,\}mode:" "$3")" ] || [ -n "$(grep "^ \{1,\}log-level:" "$3")" ]; then
|
||||
cp "$3" /tmp/config.check 2>/dev/null
|
||||
sed -i '/^dns:/,$d' /tmp/config.check 2>/dev/null
|
||||
sed -i 's/^[ \t]*//' /tmp/config.check 2>/dev/null
|
||||
@ -203,10 +242,10 @@ yml_check()
|
||||
#添加标识
|
||||
sed -i '/OpenClash-General/d' "$3" 2>/dev/null
|
||||
if [ "$proxy_provider_mode" -eq 1 ]; then
|
||||
sed -i '/^proxy-provider:/i\#===================== OpenClash-General-Settings =====================#' "$3" 2>/dev/null
|
||||
sed -i '/^proxy-providers:/i\#===================== OpenClash-General-Settings =====================#' "$3" 2>/dev/null
|
||||
else
|
||||
sed -i '/^Proxy:/i\#===================== OpenClash-General-Settings =====================#' "$3" 2>/dev/null
|
||||
fi
|
||||
fi 2>/dev/null
|
||||
}
|
||||
|
||||
#检查DNS设置
|
||||
@ -215,18 +254,18 @@ yml_dns_check()
|
||||
|
||||
if [ -z "$(grep '^dns:' "$CONFIG_FILE")" ]; then
|
||||
if [ "$proxy_provider_mode" -eq 1 ]; then
|
||||
sed -i '/^proxy-provider:/i\dns:' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^proxy-providers:/i\dns:' "$CONFIG_FILE" 2>/dev/null
|
||||
else
|
||||
sed -i '/^Proxy:/i\dns:' "$CONFIG_FILE" 2>/dev/null
|
||||
fi
|
||||
fi 2>/dev/null
|
||||
fi
|
||||
|
||||
if [ -z "$(grep '^ \{0,\}nameserver:' "$CONFIG_FILE")" ]; then
|
||||
if [ "$proxy_provider_mode" -eq 1 ]; then
|
||||
sed -i '/^proxy-provider:/i\ nameserver:' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^proxy-providers:/i\ nameserver:' "$CONFIG_FILE" 2>/dev/null
|
||||
else
|
||||
sed -i '/^Proxy:/i\ nameserver:' "$CONFIG_FILE" 2>/dev/null
|
||||
fi
|
||||
fi 2>/dev/null
|
||||
sed -i "/^ \{0,\}nameserver:/a\ - tls://8.8.8.8:853" "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{0,\}nameserver:/a\ fallback:" "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{0,\}nameserver:/a\ - 114.114.114.114" "$CONFIG_FILE" 2>/dev/null
|
||||
@ -237,7 +276,7 @@ yml_dns_check()
|
||||
dns_port=7874
|
||||
fi
|
||||
|
||||
if [ ! -z "$(grep "^ \{0,\}listen:" "$CONFIG_FILE")" ]; then
|
||||
if [ -n "$(grep "^ \{0,\}listen:" "$CONFIG_FILE")" ]; then
|
||||
if [ "$ipv6_enable" != "1" ]; then
|
||||
sed -i "/^ \{0,\}listen:/c\ listen: 127.0.0.1:${dns_port}" "$CONFIG_FILE" 2>/dev/null
|
||||
else
|
||||
@ -255,66 +294,85 @@ yml_dns_check()
|
||||
|
||||
}
|
||||
|
||||
#修改代理集路径
|
||||
#修改集路径
|
||||
yml_provider_path()
|
||||
{
|
||||
sed -i "s/\'//g" "$1" 2>/dev/null
|
||||
sed -i 's/\"//g' "$1" 2>/dev/null
|
||||
proxy_provider_path_line=$(sed -n '/^ \{0,\}path:/=' "$1" 2>/dev/null)
|
||||
if [ ! -z "$proxy_provider_path_line" ]; then
|
||||
for n in $proxy_provider_path_line
|
||||
provider_path_line=$(sed -n '/^ \{0,\}path:/=' "$1" 2>/dev/null)
|
||||
if [ -n "$provider_path_line" ]; then
|
||||
for n in $provider_path_line
|
||||
do
|
||||
provider_path=$(sed -n "${n}p" "$1" |awk -F 'path:' '{print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null)
|
||||
if [ -z "$(echo "$provider_path" |grep "proxy_provider")" ]; then
|
||||
if [ -z "$(echo "$provider_path" |grep "$2")" ]; then
|
||||
provider_name=$(echo "$provider_path" |awk -F '/' '{print $NF}')
|
||||
sed -i "s#${provider_path}#./proxy_provider/${provider_name}#" "$1" 2>/dev/null
|
||||
sed -i "s#${provider_path}#./${2}/${provider_name}#" "$1" 2>/dev/null
|
||||
fi
|
||||
done
|
||||
fi 2>/dev/null
|
||||
}
|
||||
|
||||
#检查代理集文件防止启动失败
|
||||
yml_proxy_provider_check()
|
||||
#检查集文件防止启动失败
|
||||
yml_provider_check()
|
||||
{
|
||||
if [ ! -z "$proxy_provider_path_line" ]; then
|
||||
while ( [ ! -z "$(pidof clash)" ] && [ "$proxy_provider_path_exist" != 1 ] )
|
||||
provider_path_line=$(sed -n '/^ \{0,\}path:/=' "$1" 2>/dev/null)
|
||||
local provider_path_exist
|
||||
if [ -n "$provider_path_line" ]; then
|
||||
while ( [ -n "$(pidof clash)" ] && [ "$provider_path_exist" != 1 ] )
|
||||
do
|
||||
if [ "$proxy_provider_mode" = 1 ]; then
|
||||
proxy_provider_path_exist=1
|
||||
for n in $proxy_provider_path_line
|
||||
do
|
||||
provider_path=$(sed -n "${n}p" "$1" |awk -F 'path:' '{print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null)
|
||||
if [ "$(echo ${provider_path:0:1})" = "." ]; then
|
||||
provider_path_check="/etc/openclash/$(echo ${provider_path:2})"
|
||||
if [ -f "$provider_path_check" ]; then
|
||||
if [ -z "$(grep "'proxies:':" "$provider_path_check")" ] && [ -z "$(grep '"proxies:":' "$provider_path_check")" ] && [ -z "$(grep 'proxies:' "$provider_path_check")" ]; then
|
||||
proxy_provider_path_exist=0
|
||||
fi
|
||||
else
|
||||
proxy_provider_path_exist=0
|
||||
fi
|
||||
else
|
||||
provider_path_check="$provider_path"
|
||||
if [ -f "$provider_path_check" ]; then
|
||||
if [ -z "$(grep "'proxies:':" "$provider_path_check")" ] && [ -z "$(grep '"proxies:":' "$provider_path_check")" ] && [ -z "$(grep 'proxies:' "$provider_path_check")" ]; then
|
||||
proxy_provider_path_exist=0
|
||||
fi
|
||||
else
|
||||
proxy_provider_path_exist=0
|
||||
provider_path_exist=1
|
||||
for n in $provider_path_line
|
||||
do
|
||||
provider_path=$(sed -n "${n}p" "$1" |awk -F 'path:' '{print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null)
|
||||
if [ "$(echo ${provider_path:0:1})" = "." ]; then
|
||||
provider_path_check="/etc/openclash/$(echo ${provider_path:2})"
|
||||
if [ -f "$provider_path_check" ] && [ "$2" = "proxy_provider" ]; then
|
||||
if [ -z "$(grep "'proxies:':" "$provider_path_check")" ] && [ -z "$(grep '"proxies:":' "$provider_path_check")" ] && [ -z "$(grep 'proxies:' "$provider_path_check")" ]; then
|
||||
provider_path_exist=0
|
||||
fi
|
||||
elif [ "$2" = "proxy_provider" ]; then
|
||||
provider_path_exist=0
|
||||
fi
|
||||
done
|
||||
else
|
||||
proxy_provider_path_exist=1
|
||||
fi
|
||||
if [ -f "$provider_path_check" ] && [ "$2" = "rule_provider" ]; then
|
||||
if [ -z "$(grep "'payload:':" "$provider_path_check")" ] && [ -z "$(grep '"payload:":' "$provider_path_check")" ] && [ -z "$(grep 'payload:' "$provider_path_check")" ]; then
|
||||
provider_path_exist=0
|
||||
fi
|
||||
elif [ "$2" = "rule_provider" ]; then
|
||||
provider_path_exist=0
|
||||
fi
|
||||
else
|
||||
provider_path_check="$provider_path"
|
||||
if [ -f "$provider_path_check" ] && [ "$2" = "proxy_provider" ]; then
|
||||
if [ -z "$(grep "'proxies:':" "$provider_path_check")" ] && [ -z "$(grep '"proxies:":' "$provider_path_check")" ] && [ -z "$(grep 'proxies:' "$provider_path_check")" ]; then
|
||||
provider_path_exist=0
|
||||
fi
|
||||
elif [ "$2" = "proxy_provider" ]; then
|
||||
provider_path_exist=0
|
||||
fi
|
||||
if [ -f "$provider_path_check" ] && [ "$2" = "rule_provider" ]; then
|
||||
if [ -z "$(grep "'payload:':" "$provider_path_check")" ] && [ -z "$(grep '"payload:":' "$provider_path_check")" ] && [ -z "$(grep 'payload:' "$provider_path_check")" ]; then
|
||||
provider_path_exist=0
|
||||
fi
|
||||
elif [ "$2" = "rule_provider" ]; then
|
||||
provider_path_exist=0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -z "$(pidof clash)" ] && [ "$proxy_provider_mode" = 1 ]; then
|
||||
echo "错误: OpenClash 启动失败,请到日志页面查看详细错误信息!" >$START_LOG
|
||||
echo "${LOGTIME} OpenClash Can Not Start, Please Check The Error Info And Try Again" >> $LOG_FILE
|
||||
if [ -z "$(pidof clash)" ] && [ "$provider_path_exist" = 0 ]; then
|
||||
kill_clash
|
||||
stop
|
||||
if [ "$2" = "proxy_provider" ]; then
|
||||
echo "错误: 代理集文件下载失败,请到日志页面查看详细错误信息!" >$START_LOG
|
||||
echo "${LOGTIME} Faild to Download Proxy-Provider File, Please Check The Error Info And Try Again" >> $LOG_FILE
|
||||
else
|
||||
echo "错误: 规则集文件下载失败,请到日志页面查看详细错误信息!" >$START_LOG
|
||||
echo "${LOGTIME} Faild to Download Rule-Provider File, Please Check The Error Info And Try Again" >> $LOG_FILE
|
||||
fi
|
||||
sleep 10
|
||||
stop && echo "" >$START_LOG
|
||||
echo "" >$START_LOG
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@ -324,27 +382,27 @@ fi
|
||||
yml_cut()
|
||||
{
|
||||
cp "$4" "$1"
|
||||
sed -i '/^Rule:/,$d' "$1" 2>/dev/null
|
||||
sed -i '/^rules:/,$d' "$1" 2>/dev/null
|
||||
sed -n '/^ \{0,\}nameserver:/,$p' "$1" >"$3" 2>/dev/null
|
||||
if [ "$proxy_provider_mode" -eq 1 ]; then
|
||||
sed -n '/^ \{0,\}Proxy Group:/,$p' "$3" >"$7" 2>/dev/null
|
||||
sed -n '/^ \{0,\}proxy-groups:/,$p' "$3" >"$7" 2>/dev/null
|
||||
sed -n '/^ \{0,\}Proxy:/,$p' "$3" >"$5" 2>/dev/null
|
||||
sed -n '/^ \{0,\}proxy-provider:/,$p' "$3" >"$6" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Proxy Group:/,$d' "$5" 2>/dev/null
|
||||
sed -n '/^ \{0,\}proxy-providers:/,$p' "$3" >"$6" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-groups:/,$d' "$5" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Proxy:/,$d' "$6" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Proxy Group:/,$d' "$6" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-groups:/,$d' "$6" 2>/dev/null
|
||||
else
|
||||
sed -n '/^ \{0,\}Proxy Group:/,$p' "$3" >"$7" 2>/dev/null
|
||||
sed -n '/^ \{0,\}proxy-groups:/,$p' "$3" >"$7" 2>/dev/null
|
||||
sed -n '/^ \{0,\}Proxy:/,$p' "$3" >"$5" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Proxy Group:/,$d' "$5" 2>/dev/null
|
||||
fi
|
||||
sed -i '/^ \{0,\}proxy-groups:/,$d' "$5" 2>/dev/null
|
||||
fi 2>/dev/null
|
||||
sed -i '/^ \{0,\}nameserver:/,$d' "$1" 2>/dev/null
|
||||
if [ "$proxy_provider_mode" -eq 1 ]; then
|
||||
sed -i '/^ \{0,\}proxy-provider:/,$d' "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-providers:/,$d' "$3" 2>/dev/null
|
||||
else
|
||||
sed -i '/^ \{0,\}Proxy:/,$d' "$3" 2>/dev/null
|
||||
fi
|
||||
sed -n '/^Rule:/,$p' "$4" >"$2" 2>/dev/null
|
||||
fi 2>/dev/null
|
||||
sed -n '/^rules:/,$p' "$4" >"$2" 2>/dev/null
|
||||
}
|
||||
|
||||
#获取自定义DNS设置
|
||||
@ -378,15 +436,15 @@ yml_dns_get()
|
||||
dns_type="- https://"
|
||||
fi
|
||||
|
||||
if [ ! -z "$port" ] && [ ! -z "$ip" ]; then
|
||||
if [ -n "$port" ] && [ -n "$ip" ]; then
|
||||
dns_address="$ip:$port"
|
||||
elif [ -z "$port" ] && [ ! -z "$ip" ]; then
|
||||
elif [ -z "$port" ] && [ -n "$ip" ]; then
|
||||
dns_address="$ip"
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -z "$group" ]; then
|
||||
if [ -n "$group" ]; then
|
||||
if [ "$group" = "nameserver" ]; then
|
||||
echo " $dns_type$dns_address" >>/etc/openclash/config.namedns
|
||||
else
|
||||
@ -421,7 +479,7 @@ yml_dns_custom()
|
||||
fi
|
||||
|
||||
#fallback-filter
|
||||
if [ ! -z "$(grep '^ \{0,\}fallback:' $2)" ]; then
|
||||
if [ -n "$(grep '^ \{0,\}fallback:' $2)" ]; then
|
||||
if [ -z "$(grep '^ \{0,\}fallback-filter:' $2)" ]; then
|
||||
awk '/^ {0,}fallback:/,/OpenClash-General-Settings/{print}' "$2" |sed '1d' |sed '$d' >/tmp/fallback.cache 2>/dev/null
|
||||
sed -i '/cfw-bypass:/,$d' /tmp/fallback.cache 2>/dev/null
|
||||
@ -454,11 +512,11 @@ yml_dns_custom()
|
||||
fi
|
||||
#删除fallback-filter
|
||||
else
|
||||
if [ ! -z "$(grep '^ \{0,\}fallback-filter:' $2)" ]; then
|
||||
if [ -n "$(grep '^ \{0,\}fallback-filter:' $2)" ]; then
|
||||
sed -i '/fallback-filter:/,$d' "$2" 2>/dev/null
|
||||
echo "#===================== OpenClash-General-Settings =====================#" >>"$2"
|
||||
fi
|
||||
if [ ! -z "$(grep "^ \{0,1\}- " $2)" ]; then
|
||||
if [ -n "$(grep "^ \{0,1\}- " $2)" ]; then
|
||||
#添加参数空格
|
||||
sed -i "s/^ \{0,\}- / - /" "$2" 2>/dev/null
|
||||
fi
|
||||
@ -488,7 +546,7 @@ yml_auth_get()
|
||||
#添加认证信息
|
||||
yml_auth_custom()
|
||||
{
|
||||
if [ ! -z "$(grep "^authentication:" "$1")" ]; then
|
||||
if [ -n "$(grep "^authentication:" "$1")" ]; then
|
||||
sed -i '/^dns:/i\#authentication' "$1" 2>/dev/null
|
||||
sed -i '/^authentication:/,/^#authentication/d' "$1" 2>/dev/null
|
||||
fi
|
||||
@ -529,7 +587,7 @@ yml_game_rule_get()
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -z "$config" ] && [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then
|
||||
if [ -n "$config" ] && [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
@ -551,7 +609,7 @@ yml_game_group_get()
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -z "$config" ] && [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then
|
||||
if [ -n "$config" ] && [ "$config" != "$CONFIG_NAME" ] && [ "$config" != "all" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
@ -568,15 +626,15 @@ yml_game_custom()
|
||||
rm -rf $GAME_RULE_FILE 2>/dev/null
|
||||
config_load "openclash"
|
||||
config_foreach yml_game_rule_get "game_config"
|
||||
if [ ! -z "$(grep "OpenClash-Game-Rules" "$RULE_FILE")" ]; then
|
||||
if [ -n "$(grep "OpenClash-Game-Rules" "$RULE_FILE")" ]; then
|
||||
sed -i '/OpenClash-Game-Rules/,/OpenClash-Game-Rules-End/d' "$RULE_FILE" 2>/dev/null
|
||||
fi
|
||||
sed -i '/OpenClash-Game-Rules/d' "$RULE_FILE" 2>/dev/null
|
||||
sed -i '/OpenClash-Game-Rules-End/d' "$RULE_FILE" 2>/dev/null
|
||||
[ "$set_rule_file" = 1 ] && {
|
||||
if [ ! -z "$(grep "^ \{0,\}- GEOIP" "$RULE_FILE")" ]; then
|
||||
if [ -n "$(grep "^ \{0,\}- GEOIP" "$RULE_FILE")" ]; then
|
||||
sed -i '1,/^ \{0,\}- GEOIP,/{/^ \{0,\}- GEOIP,/s/^ \{0,\}- GEOIP,/#===================== OpenClash-Game-Rules =====================#\n&/}' "$RULE_FILE" 2>/dev/null
|
||||
elif [ ! -z "$(grep "^ \{0,\}- MATCH," "$RULE_FILE")" ]; then
|
||||
elif [ -n "$(grep "^ \{0,\}- MATCH," "$RULE_FILE")" ]; then
|
||||
sed -i '1,/^ \{0,\}- MATCH,/{/^ \{0,\}- MATCH,/s/^ \{0,\}- MATCH,/#===================== OpenClash-Game-Rules =====================#\n&/}' "$RULE_FILE" 2>/dev/null
|
||||
else
|
||||
echo "#===================== OpenClash-Game-Rules =====================#" >> "$RULE_FILE" 2>/dev/null
|
||||
@ -586,25 +644,25 @@ sed -i '/OpenClash-Game-Rules-End/d' "$RULE_FILE" 2>/dev/null
|
||||
}
|
||||
|
||||
#合并文件
|
||||
cat "$CHANGE_FILE" "$DNS_FILE" "$PROXY_PROVIDER_FILE" "$PROXY_FILE" "$GROUP_FILE" "$RULE_FILE" > "$CONFIG_FILE" 2>/dev/null
|
||||
cat "$CHANGE_FILE" "$DNS_FILE" "$PROXY_PROVIDER_FILE" "$PROXY_FILE" "$GROUP_FILE" "$RULE_PROVIDER_FILE" "$SCRIPT_FILE" "$RULE_FILE" > "$CONFIG_FILE" 2>/dev/null
|
||||
|
||||
#处理游戏节点与策略组
|
||||
config_load "openclash"
|
||||
config_foreach yml_game_group_get "game_config"
|
||||
sed -i '/^ \{0,\}Proxy Group:/r/tmp/yaml_groups.yaml' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-groups:/r/tmp/yaml_groups.yaml' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Proxy:/d' /tmp/yaml_servers.yaml 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-provider:/d' /tmp/yaml_provider.yaml 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-providers:/d' /tmp/yaml_provider.yaml 2>/dev/null
|
||||
if [ -z "$(grep "^ \{0,\}Proxy:" "$CONFIG_FILE" 2>/dev/null)" ] && [ -f "/tmp/yaml_servers.yaml" ]; then
|
||||
sed -i '/^ \{0,\}Proxy Group:/i\Proxy:' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-groups:/i\Proxy:' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Proxy:/r/tmp/yaml_servers.yaml' "$CONFIG_FILE" 2>/dev/null
|
||||
elif [ -f "/tmp/yaml_servers.yaml" ]; then
|
||||
sed -i '/^ \{0,\}Proxy:/r/tmp/yaml_servers.yaml' "$CONFIG_FILE" 2>/dev/null
|
||||
fi
|
||||
if [ -z "$(grep "^ \{0,\}proxy-provider:" "$CONFIG_FILE" 2>/dev/null)" ] && [ -f "/tmp/yaml_provider.yaml" ]; then
|
||||
sed -i '/OpenClash-General-Settings/a\proxy-provider:' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-provider:/r/tmp/yaml_provider.yaml' "$CONFIG_FILE" 2>/dev/null
|
||||
if [ -z "$(grep "^ \{0,\}proxy-providers:" "$CONFIG_FILE" 2>/dev/null)" ] && [ -f "/tmp/yaml_provider.yaml" ]; then
|
||||
sed -i '/OpenClash-General-Settings/a\proxy-providers:' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-providers:/r/tmp/yaml_provider.yaml' "$CONFIG_FILE" 2>/dev/null
|
||||
elif [ -f "/tmp/yaml_servers.yaml" ]; then
|
||||
sed -i '/^ \{0,\}proxy-provider:r/tmp/yaml_provider.yaml' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-providers:r/tmp/yaml_provider.yaml' "$CONFIG_FILE" 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@ -623,7 +681,7 @@ config_choose()
|
||||
{
|
||||
if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then
|
||||
CONFIG_NAME=$(ls -lt /etc/openclash/config/ | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}')
|
||||
if [ ! -z "$CONFIG_NAME" ]; then
|
||||
if [ -n "$CONFIG_NAME" ]; then
|
||||
uci set openclash.config.config_path="/etc/openclash/config/$CONFIG_NAME"
|
||||
uci commit openclash
|
||||
CONFIG_FILE="/etc/openclash/config/$CONFIG_NAME"
|
||||
@ -650,6 +708,7 @@ CONFIG_NAME=$(echo "$CONFIG_FILE" |awk -F '/' '{print $5}' 2>/dev/null)
|
||||
do_run_mode()
|
||||
{
|
||||
en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
|
||||
proxy_mode=$(uci get openclash.config.proxy_mode 2>/dev/null)
|
||||
|
||||
if [ ! -h "/etc/openclash/clash" ] && [ -s "/etc/openclash/clash" ] && [ ! -s "/etc/openclash/core/clash" ]; then
|
||||
mv "/etc/openclash/clash" "/etc/openclash/core/clash" 2>/dev/null
|
||||
@ -685,6 +744,11 @@ do_run_mode()
|
||||
core_type="Game"
|
||||
fi
|
||||
|
||||
if [ "$proxy_mode" = "Script" ] || [ -n "$(grep "^ \{0,\}rule-providers:" "$CONFIG_FILE" 2>/dev/null)" ]; then
|
||||
ln -s /etc/openclash/core/clash_tun /etc/openclash/clash 2>/dev/null
|
||||
core_type="Tun"
|
||||
fi
|
||||
|
||||
if [ ! -f "/etc/openclash/clash" ] && [ -f "/etc/openclash/core/clash" ]; then
|
||||
ln -s /etc/openclash/core/clash /etc/openclash/clash 2>/dev/null
|
||||
fi
|
||||
@ -732,11 +796,11 @@ EOF
|
||||
|
||||
#lan_ac
|
||||
if [ "$operation_mode" = "redir-host" ] && [ "$en_mode" = "redir-host" ]; then
|
||||
if [ "$lan_ac_mode" = "0" ] && [ ! -z "$(uci get openclash.config.lan_ac_black_ips 2>/dev/null)" ]; then
|
||||
if [ "$lan_ac_mode" = "0" ] && [ -n "$(uci get openclash.config.lan_ac_black_ips 2>/dev/null)" ]; then
|
||||
ipset create lan_ac_black_ips hash:net
|
||||
config_load "openclash"
|
||||
config_list_foreach "config" "lan_ac_black_ips" lan_ac "lan_ac_black_ips"
|
||||
elif [ "$lan_ac_mode" = "1" ] && [ ! -z "$(uci get openclash.config.lan_ac_white_ips 2>/dev/null)" ]; then
|
||||
elif [ "$lan_ac_mode" = "1" ] && [ -n "$(uci get openclash.config.lan_ac_white_ips 2>/dev/null)" ]; then
|
||||
ipset create lan_ac_white_ips hash:net
|
||||
config_load "openclash"
|
||||
config_list_foreach "config" "lan_ac_white_ips" lan_ac "lan_ac_white_ips"
|
||||
@ -754,7 +818,7 @@ fi
|
||||
ipset add localnetwork 240.0.0.0/4
|
||||
ipset add localnetwork 172.16.0.0/12
|
||||
|
||||
if [ ! -z "$wan_ip4" ]; then
|
||||
if [ -n "$wan_ip4" ]; then
|
||||
for wan_ip4s in $wan_ip4; do
|
||||
ipset add localnetwork "$wan_ip4s" 2>/dev/null
|
||||
done
|
||||
@ -795,7 +859,7 @@ if [ -z "$en_mode_tun" ]; then
|
||||
if [ "$ipv6_enable" -eq 1 ]; then
|
||||
#tcp
|
||||
ip6tables -t nat -N openclash
|
||||
if [ ! -z "$lan_ip6" ]; then
|
||||
if [ -n "$lan_ip6" ]; then
|
||||
for lan_ip6s in $lan_ip6; do
|
||||
ip6tables -t nat -A openclash -d "$lan_ip6s" -j RETURN 2>/dev/null
|
||||
done
|
||||
@ -806,7 +870,7 @@ if [ -z "$en_mode_tun" ]; then
|
||||
#udp
|
||||
#if [ "$enable_udp_proxy" -eq 1 ]; then
|
||||
# ip6tables -t mangle -N openclash
|
||||
# if [ ! -z "$lan_ip6" ]; then
|
||||
# if [ -n "$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
|
||||
@ -816,7 +880,7 @@ if [ -z "$en_mode_tun" ]; then
|
||||
# ip6tables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark "$PROXY_FWMARK"
|
||||
# ip6tables -t mangle -A PREROUTING -p udp -j openclash
|
||||
#fi
|
||||
fi
|
||||
fi 2>/dev/null
|
||||
else
|
||||
#TUN模式
|
||||
#启动TUN
|
||||
@ -826,7 +890,7 @@ else
|
||||
ip route replace default dev clash0 table "$PROXY_ROUTE_TABLE"
|
||||
elif [ "$en_mode_tun" = "1" ]; then
|
||||
TUN_WAIT=0
|
||||
while ( [ ! -z "$(pidof clash)" ] && [ -z "$(ip route list |grep utun)" ] && [ "$TUN_WAIT" -le 3 ] )
|
||||
while ( [ -n "$(pidof clash)" ] && [ -z "$(ip route list |grep utun)" ] && [ "$TUN_WAIT" -le 3 ] )
|
||||
do
|
||||
TUN_WAIT=$(expr "$TUN_WAIT" + 1)
|
||||
sleep 2
|
||||
@ -864,15 +928,6 @@ revert_firewall()
|
||||
|
||||
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 -X openclash >/dev/null 2>&1
|
||||
|
||||
iptables -t nat -F openclash >/dev/null 2>&1
|
||||
iptables -t nat -X openclash >/dev/null 2>&1
|
||||
|
||||
iptables -t nat -F openclash_output >/dev/null 2>&1
|
||||
iptables -t nat -X openclash_output >/dev/null 2>&1
|
||||
|
||||
out_lines=$(iptables -nvL OUTPUT -t nat |sed 1,2d |sed -n '/openclash/=' 2>/dev/null |sort -rn)
|
||||
for out_line in $out_lines; do
|
||||
iptables -t nat -D OUTPUT "$out_line" >/dev/null 2>&1
|
||||
@ -898,6 +953,12 @@ revert_firewall()
|
||||
#ip6tables -t mangle -D PREROUTING -p udp -j openclash >/dev/null 2>&1
|
||||
#ip6tables -t mangle -X openclash >/dev/null 2>&1
|
||||
|
||||
iptables -t nat -F openclash >/dev/null 2>&1
|
||||
iptables -t nat -X openclash >/dev/null 2>&1
|
||||
|
||||
iptables -t nat -F openclash_output >/dev/null 2>&1
|
||||
iptables -t nat -X openclash_output >/dev/null 2>&1
|
||||
|
||||
ip6tables -t nat -F openclash >/dev/null 2>&1
|
||||
ip6tables -t nat -D PREROUTING -p tcp -j openclash >/dev/null 2>&1
|
||||
ip6tables -t nat -X openclash >/dev/null 2>&1
|
||||
@ -915,6 +976,7 @@ revert_firewall()
|
||||
iptables -t mangle -D PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK" >/dev/null 2>&1
|
||||
iptables -t mangle -F openclash >/dev/null 2>&1
|
||||
iptables -t mangle -X openclash >/dev/null 2>&1
|
||||
|
||||
#ip6tables -t mangle -D PREROUTING -j MARK --set-mark "$PROXY_FWMARK" >/dev/null 2>&1
|
||||
|
||||
ipset destroy localnetwork >/dev/null 2>&1
|
||||
@ -939,12 +1001,12 @@ get_config()
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
}
|
||||
|
||||
start()
|
||||
@ -961,6 +1023,8 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
|
||||
#检查是否存在核心文件
|
||||
do_run_mode
|
||||
[ ! -f "$CLASH" ] && {
|
||||
kill_clash
|
||||
stop
|
||||
echo "内核文件不存在,开始下载..." >$START_LOG
|
||||
nohup /usr/share/openclash/openclash_core.sh "$core_type" &
|
||||
exit 0
|
||||
@ -970,14 +1034,15 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
|
||||
get_config
|
||||
echo "第二步: 配置文件检查..." >$START_LOG
|
||||
yml_check "$en_mode" "$enable_custom_dns" "$CONFIG_FILE" "$BACKUP_FILE" "$START_BACKUP"
|
||||
grep "^ \{0,\}Proxy Group:" "$CONFIG_FILE" >/dev/null 2>&1 && grep "^ \{0,\}Rule:" "$CONFIG_FILE" >/dev/null 2>&1
|
||||
grep "^ \{0,\}proxy-groups:" "$CONFIG_FILE" >/dev/null 2>&1 && grep "^ \{0,\}rules:" "$CONFIG_FILE" >/dev/null 2>&1
|
||||
if [ "$?" -eq "0" ]; then
|
||||
grep "^ \{0,\}Proxy:" "$CONFIG_FILE" >/dev/null 2>&1 || grep "^ \{0,\}proxy-provider:" "$CONFIG_FILE" >/dev/null 2>&1
|
||||
grep "^ \{0,\}Proxy:" "$CONFIG_FILE" >/dev/null 2>&1 || grep "^ \{0,\}proxy-providers:" "$CONFIG_FILE" >/dev/null 2>&1
|
||||
if [ "$?" -ne "0" ]; then
|
||||
nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 &
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: 配置文件完整性检查不通过,已自动还原配置文件,请根据日志信息对照模板格式检查修改配置文件!" >$START_LOG
|
||||
mv "$START_BACKUP" "$CONFIG_FILE"
|
||||
stop
|
||||
sleep 5
|
||||
echo "" >$START_LOG
|
||||
else
|
||||
@ -987,13 +1052,16 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
|
||||
yml_auth_custom "$CONFIG_FILE"
|
||||
yml_cut "$CHANGE_FILE" "$RULE_FILE" "$DNS_FILE" "$CONFIG_FILE" "$PROXY_FILE" "$PROXY_PROVIDER_FILE" "$GROUP_FILE"
|
||||
yml_dns_custom "$enable_custom_dns" "$DNS_FILE"
|
||||
yml_provider_path "$PROXY_PROVIDER_FILE"
|
||||
sh /usr/share/openclash/yml_change.sh >/dev/null 2>&1 "$LOGTIME" "$en_mode" "$enable_custom_dns" "$da_password" "$cn_port" "$proxy_port" "$CHANGE_FILE" "$ipv6_enable" "$http_port" "$socks_port" "$lan_ip" "$log_level" "$proxy_mode" "$intranet_allowed" "$en_mode_tun" &
|
||||
yml_provider_path "$PROXY_PROVIDER_FILE" "proxy_provider"
|
||||
yml_provider_path "$RULE_PROVIDER_FILE" "rule_provider"
|
||||
sh /usr/share/openclash/yml_change.sh >/dev/null 2>&1 "$LOGTIME" "$en_mode" "$enable_custom_dns" "$da_password" "$cn_port" "$proxy_port" "$CHANGE_FILE" "$ipv6_enable" "$http_port" "$socks_port" "$lan_ip" "$log_level" "$proxy_mode" "$intranet_allowed" "$en_mode_tun" "$stack_type" &
|
||||
sh /usr/share/openclash/yml_rules_change.sh >/dev/null 2>&1 "$LOGTIME" "$rule_source" "$enable_custom_clash_rules" "$RULE_FILE" "$set_rule_file" "$en_mode" "$enable_rule_proxy" "$BACKUP_FILE" &
|
||||
wait
|
||||
yml_game_custom
|
||||
echo "第四步: DNS设置检查..." >$START_LOG
|
||||
if [ ! -z "$(sed -n '/^ \{0,\}nameserver:/{n;p}' "$CONFIG_FILE" |grep '^ \{0,\}fallback:')" ] || [ ! -z "$(sed -n '/^ \{0,\}nameserver:/{n;p}' "$CONFIG_FILE" |grep 'OpenClash-General')" ]; then
|
||||
if [ -n "$(sed -n '/^ \{0,\}nameserver:/{n;p}' "$CONFIG_FILE" |grep '^ \{0,\}fallback:')" ] || [ -n "$(sed -n '/^ \{0,\}nameserver:/{n;p}' "$CONFIG_FILE" |grep 'OpenClash-General')" ]; then
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: 配置文件DNS选项下的Nameserver必须设置服务器,已自动还原配置文件,请重新设置!" >$START_LOG
|
||||
echo "${LOGTIME} Nameserver Must Be Set, Please Change Your Configrations In Config.yaml" >>$LOG_FILE
|
||||
mv "$START_BACKUP" "$CONFIG_FILE"
|
||||
@ -1001,20 +1069,22 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
|
||||
echo "" >$START_LOG
|
||||
else
|
||||
echo "第五步: 启动主程序..." >$START_LOG
|
||||
sed -i "s/^ \{0,\}Proxy:/proxies:/g" "$CONFIG_FILE" 2>/dev/null
|
||||
ulimit -SHn 65535 2>/dev/null
|
||||
config_reload=$(uci get openclash.config.config_reload 2>/dev/null)
|
||||
if [ -n "$(pidof clash)" ] && [ "$en_mode_tun" != "1" ] && [ "$config_reload" != "0" ]; then
|
||||
if [ -n "$(pidof clash)" ] && [ "$core_type" != "Tun" ] && [ "$config_reload" != "0" ]; then
|
||||
curl -s --connect-timeout 5 -m 5 -H 'Content-Type: application/json' -H "Authorization: Bearer ${da_password}" -XPUT http://"$lan_ip":"$cn_port"/configs -d "{\"path\": \"$CONFIG_FILE\"}" 2>/dev/null
|
||||
else
|
||||
kill -9 "$(pidof clash|sed 's/$//g')" 2>/dev/null
|
||||
kill_clash
|
||||
nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 &
|
||||
fi
|
||||
uci set openclash.config.config_reload=1
|
||||
uci commit openclash
|
||||
|
||||
#检测proxy_provider配置文件状态
|
||||
echo "第六步: 等待主程序下载代理集..." >$START_LOG
|
||||
yml_proxy_provider_check "$PROXY_PROVIDER_FILE"
|
||||
echo "第六步: 等待主程序下载外部文件..." >$START_LOG
|
||||
yml_provider_check "$PROXY_PROVIDER_FILE" "proxy_provider"
|
||||
yml_provider_check "$RULE_PROVIDER_FILE" "rule_provider"
|
||||
|
||||
echo "第七步: 设置控制面板..." >$START_LOG
|
||||
ln -s /usr/share/openclash/yacd /www/luci-static/openclash 2>/dev/null
|
||||
@ -1046,8 +1116,8 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
|
||||
echo "错误: OpenClash 启动失败,尝试还原第三方规则并重新启动 Clash 主程序..." >$START_LOG
|
||||
echo "${LOGTIME} OpenClash Can Not Start, Try Use Backup Rules Start Again" >> $LOG_FILE
|
||||
mv "$START_BACKUP" /etc/openclash/configrules.bak
|
||||
sed -i -n '/^Rule:/,$p' /etc/openclash/configrules.bak
|
||||
sed -i '/^Rule:/,$d' "$CONFIG_FILE"
|
||||
sed -i -n '/^rules:/,$p' /etc/openclash/configrules.bak
|
||||
sed -i '/^rules:/,$d' "$CONFIG_FILE"
|
||||
cat /etc/openclash/configrules.bak >> "$CONFIG_FILE"
|
||||
rm -rf /etc/openclash/configrules.bak
|
||||
nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 &
|
||||
@ -1070,27 +1140,30 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
|
||||
echo "OpenClash Already Start"
|
||||
echo "" >$START_LOG
|
||||
else
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: OpenClash 启动失败,请到日志页面查看详细错误信息!" >$START_LOG
|
||||
echo "${LOGTIME} OpenClash Can Not Start, Please Check The Error Info And Try Again" >> $LOG_FILE
|
||||
sleep 10
|
||||
echo "" >$START_LOG
|
||||
stop && echo "" >$START_LOG
|
||||
fi
|
||||
else
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: OpenClash 启动失败,请到日志页面查看详细错误信息!" >$START_LOG
|
||||
echo "${LOGTIME} OpenClash Can Not Start, Please Check The Error Info And Try Again" >> $LOG_FILE
|
||||
sleep 10
|
||||
echo "" >$START_LOG
|
||||
stop && echo "" >$START_LOG
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 &
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: 配置文件完整性检查不通过,已自动还原配置文件,请根据日志信息对照模板格式检查修改配置文件!" >$START_LOG
|
||||
mv "$START_BACKUP" "$CONFIG_FILE"
|
||||
stop
|
||||
sleep 5
|
||||
echo "" >$START_LOG
|
||||
fi
|
||||
@ -1098,11 +1171,15 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
|
||||
rm -rf /tmp/yaml_* 2>/dev/null
|
||||
else
|
||||
subscribe_url=$(uci get openclash.config.subscribe_url 2>/dev/null)
|
||||
if [ ! -f "$CONFIG_FILE" ] && [ ! -z "$subscribe_url" ]; then
|
||||
if [ ! -f "$CONFIG_FILE" ] && [ -n "$subscribe_url" ]; then
|
||||
kill_clash
|
||||
stop
|
||||
echo "OpenClash 配置文件不存在,开始下载..." >$START_LOG
|
||||
nohup /usr/share/openclash/openclash.sh &
|
||||
exit 0
|
||||
elif [ ! -f "$CONFIG_FILE" ]; then
|
||||
kill_clash
|
||||
stop
|
||||
echo "错误: OpenClash 缺少配置文件,请上传或更新配置文件!" >$START_LOG
|
||||
echo "${LOGTIME} Config Not Found" >> $LOG_FILE
|
||||
sleep 5
|
||||
@ -1121,9 +1198,8 @@ stop()
|
||||
|
||||
echo "OpenClash 开始关闭..." >$START_LOG
|
||||
echo "第一步: 备份当前节点状态..." >$START_LOG
|
||||
/usr/share/openclash/openclash_history_get.sh &
|
||||
wait
|
||||
|
||||
/usr/share/openclash/openclash_history_get.sh 2>/dev/null
|
||||
|
||||
echo "第二步: 删除 OpenClash 防火墙规则..." >$START_LOG
|
||||
revert_firewall
|
||||
|
||||
@ -1135,7 +1211,7 @@ stop()
|
||||
|
||||
echo "第四步: 关闭 Clash 主程序..." >$START_LOG
|
||||
if [ "$enable" -eq 0 ]; then
|
||||
kill -9 "$(pidof clash|sed 's/$//g')" 2>/dev/null
|
||||
kill_clash
|
||||
fi
|
||||
|
||||
echo "第五步: 重启 Dnsmasq 程序..." >$START_LOG
|
||||
@ -1157,7 +1233,8 @@ stop()
|
||||
echo "OpenClash 关闭成功!" >$START_LOG
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
|
||||
rm -rf /tmp/yaml_* 2>/dev/null
|
||||
rm -rf $START_LOG 2>/dev/null
|
||||
del_cron
|
||||
echo "OpenClash Already Stop"
|
||||
|
||||
Binary file not shown.
@ -72,7 +72,7 @@ dns: # 如订阅配置无包括此项的所有DNS设置,OpenClash将自动添
|
||||
# 以上设置您可直接覆盖到配置文件,无需更改
|
||||
# Openclash 不会对下方服务器设置进行任何更改,请确保设置正确
|
||||
|
||||
#proxy-provider: # 代理集设置,此部分与Proxy两者不能同时删除
|
||||
#proxy-providers: # 代理集设置,此部分与Proxy两者不能同时删除
|
||||
# pro:
|
||||
# type: http
|
||||
# path: ./proxy_provider/pro.yaml
|
||||
@ -90,7 +90,7 @@ dns: # 如订阅配置无包括此项的所有DNS设置,OpenClash将自动添
|
||||
# url: http://www.gstatic.com/generate_204
|
||||
# interval: 300
|
||||
|
||||
Proxy: # 节点设置,此部分与proxy-provider两者不能同时删除
|
||||
proxies: # 节点设置,此部分与proxy-provider两者不能同时删除
|
||||
|
||||
# shadowsocks
|
||||
# The supported ciphers(encrypt methods):
|
||||
@ -215,7 +215,7 @@ Proxy: # 节点设置,此部分与proxy-provider两者不能同时删除
|
||||
|
||||
# Openclash 不会对下方策略组设置进行任何更改,请确保设置正确
|
||||
|
||||
Proxy Group: # 此参数必须保留,不能删除
|
||||
proxy-groups: # 此参数必须保留,不能删除
|
||||
|
||||
# relay chains the proxies. proxies shall not contain a proxy-group. No UDP support.
|
||||
# Traffic: clash <-> http <-> vmess <-> ss1 <-> ss2 <-> Internet
|
||||
@ -275,7 +275,30 @@ Proxy Group: # 此参数必须保留,不能删除
|
||||
- Proxy
|
||||
- DIRECT
|
||||
|
||||
Rule: # 此参数必须保留,不能删除
|
||||
# https://lancellc.gitbook.io/clash/clash-config-file/rule-provider
|
||||
#rule-providers:
|
||||
# name: # name of the provider
|
||||
# type: http # type of the provider, it can be a HTTP or a File
|
||||
# behavior: ipcidr # or domain
|
||||
# path: # where is the file, ./ relative to clash home
|
||||
# url: # only available when type is HTTP, where to download a file. You don't need to create a new file in local space.
|
||||
# interval: # auto-update interval, only available when type is HTTP
|
||||
|
||||
# https://lancellc.gitbook.io/clash/clash-config-file/script
|
||||
#script:
|
||||
# code: |
|
||||
# def main(ctx, metadata):
|
||||
# ip = metadata["dst_ip"] = ctx.resolve_ip(metadata["host"])
|
||||
# if ip == "":
|
||||
# return "DIRECT"
|
||||
#
|
||||
# code = ctx.geoip(ip)
|
||||
# if code == "LAN" or code == "CN":
|
||||
# return "DIRECT"
|
||||
#
|
||||
# return "Proxy" # default policy for requests which are not matched by any other script
|
||||
|
||||
rules: # 此参数必须保留,不能删除
|
||||
# 如果您将一直使用第三方规则,下方可以留空。
|
||||
- DOMAIN-SUFFIX,google.com,auto
|
||||
- DOMAIN-KEYWORD,google,auto
|
||||
@ -287,6 +310,8 @@ Rule: # 此参数必须保留,不能删除
|
||||
- GEOIP,CN,DIRECT
|
||||
- DST-PORT,80,DIRECT
|
||||
- SRC-PORT,7777,DIRECT
|
||||
# or use rule with provider
|
||||
- RULE-SET,name,Proxy
|
||||
# FINAL would remove after prerelease
|
||||
# you also can use `FINAL,Proxy` or `FINAL,,Proxy` now
|
||||
- MATCH,auto
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -142,11 +142,11 @@ end
|
||||
end
|
||||
|
||||
local function corelv()
|
||||
local new = luci.sys.call(string.format("sh /usr/share/openclash/clash_version.sh"))
|
||||
luci.sys.call("sh /usr/share/openclash/clash_version.sh")
|
||||
local core_lv = luci.sys.exec("sed -n 1p /tmp/clash_last_version 2>/dev/null")
|
||||
local core_tun_lv = luci.sys.exec("sed -n 2p /tmp/clash_last_version 2>/dev/null")
|
||||
local core_game_lv = luci.sys.exec("sed -n 3p /tmp/clash_last_version 2>/dev/null")
|
||||
return core_lv .. "," .. core_tun_lv .. "," .. core_game_lv .. "," .. new
|
||||
return core_lv .. "," .. core_tun_lv .. "," .. core_game_lv
|
||||
end
|
||||
|
||||
local function opcv()
|
||||
|
||||
@ -90,8 +90,10 @@ clash = "/etc/openclash/clash"
|
||||
dir = "/etc/openclash/config/"
|
||||
bakck_dir="/etc/openclash/backup"
|
||||
proxy_pro_dir="/etc/openclash/proxy_provider/"
|
||||
rule_pro_dir="/etc/openclash/rule_provider/"
|
||||
create_bakck_dir=fs.mkdir(bakck_dir)
|
||||
create_proxy_pro_dir=fs.mkdir(proxy_pro_dir)
|
||||
create_rule_pro_dir=fs.mkdir(rule_pro_dir)
|
||||
|
||||
|
||||
HTTP.setfilehandler(
|
||||
@ -104,6 +106,8 @@ HTTP.setfilehandler(
|
||||
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
|
||||
elseif fp == "proxy-provider" then
|
||||
if meta and chunk then fd = nixio.open(proxy_pro_dir .. meta.file, "w") end
|
||||
elseif fp == "rule-provider" then
|
||||
if meta and chunk then fd = nixio.open(rule_pro_dir .. meta.file, "w") end
|
||||
end
|
||||
|
||||
if not fd then
|
||||
@ -117,21 +121,23 @@ HTTP.setfilehandler(
|
||||
if eof and fd then
|
||||
fd:close()
|
||||
fd = nil
|
||||
if IsYamlFile(meta.file) and fp ~= "proxy-provider" then
|
||||
if IsYamlFile(meta.file) and fp == "config" then
|
||||
local yamlbackup="/etc/openclash/backup/" .. meta.file
|
||||
local c=fs.copy(dir .. meta.file,yamlbackup)
|
||||
end
|
||||
if IsYmlFile(meta.file) and fp ~= "proxy-provider" then
|
||||
if IsYmlFile(meta.file) and fp == "config" then
|
||||
local ymlname=string.lower(string.sub(meta.file,0,-5))
|
||||
local ymlbackup="/etc/openclash/backup/".. ymlname .. ".yaml"
|
||||
local c=fs.rename(dir .. meta.file,"/etc/openclash/config/".. ymlname .. ".yaml")
|
||||
local c=fs.copy("/etc/openclash/config/".. ymlname .. ".yaml",ymlbackup)
|
||||
end
|
||||
if fp ~= "proxy-provider" then
|
||||
if fp == "config" then
|
||||
um.value = translate("File saved to") .. ' "/etc/openclash/config/"'
|
||||
CHIF = "1"
|
||||
else
|
||||
elseif fp == "proxy-provider" then
|
||||
um.value = translate("File saved to") .. ' "/etc/openclash/proxy_provider/"'
|
||||
elseif fp == "rule-provider" then
|
||||
um.value = translate("File saved to") .. ' "/etc/openclash/rule_provider/"'
|
||||
end
|
||||
fs.unlink("/tmp/Proxy_Group")
|
||||
end
|
||||
@ -251,6 +257,7 @@ end
|
||||
btnrm.write=function(a,t)
|
||||
fs.unlink("/tmp/Proxy_Group")
|
||||
fs.unlink("/etc/openclash/backup/"..luci.openclash.basename(e[t].name))
|
||||
fs.unlink("/etc/openclash/history/"..luci.openclash.basename(e[t].name))
|
||||
local a=fs.unlink("/etc/openclash/config/"..luci.openclash.basename(e[t].name))
|
||||
if a then table.remove(e,t)end
|
||||
return a
|
||||
|
||||
@ -65,11 +65,20 @@ o:value("0", translate("Disable"))
|
||||
o:value("1", translate("Enable"))
|
||||
o.default = "1"
|
||||
|
||||
o = s:taboption("op_mode", ListValue, "stack_type", font_red..bold_on..translate("Select Stack Type")..bold_off..font_off)
|
||||
o.description = translate("Select Stack Type For Tun Mode, According To The Running Speed on Your Machine")
|
||||
o:depends("en_mode", "redir-host-tun")
|
||||
o:depends("en_mode", "fake-ip-tun")
|
||||
o:value("system", translate("System "))
|
||||
o:value("gvisor", translate("Gvisor"))
|
||||
o.default = "system"
|
||||
|
||||
o = s:taboption("op_mode", 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"))
|
||||
o:value("Global", translate("Global Proxy Mode"))
|
||||
o:value("Direct", translate("Direct Proxy Mode"))
|
||||
o:value("Script", translate("Script Proxy Mode (Tun Core Only)"))
|
||||
o.default = "Rule"
|
||||
|
||||
o = s:taboption("op_mode", Button, translate("Switch Operation Mode"))
|
||||
@ -156,7 +165,7 @@ o:value("1", translate("Enable"))
|
||||
o.default = 0
|
||||
|
||||
o = s:taboption("dns", ListValue, "ipv6_enable", translate("Enable ipv6 Resolve"))
|
||||
o.description = font_red..bold_on..translate("Force Enable to Resolve ipv6 DNS Requests")..bold_off..font_off
|
||||
o.description = font_red..bold_on..translate("Enable Clash to Resolve ipv6 DNS Requests")..bold_off..font_off
|
||||
o:value("0", translate("Disable"))
|
||||
o:value("1", translate("Enable"))
|
||||
o:depends("en_mode", "redir-host")
|
||||
|
||||
@ -137,7 +137,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+'" alt="currentversion" width="200px" onload="return clashversion_check()" onclick="return go_update()">';
|
||||
}
|
||||
});
|
||||
|
||||
@ -157,7 +157,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+'" alt="currentversion" width="200px" onclick="return go_update()">';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -128,26 +128,28 @@
|
||||
var corelvis = arr_core[0];
|
||||
var coretunlvis = arr_core[1];
|
||||
var coregamelvis = arr_core[2];
|
||||
var new_ch = arr_core[3];
|
||||
if ( new_ch == "2" || new_ch == "4" ) {
|
||||
if (corelvis != status.corecv && corelvis != "" && corelvis != "\n") {
|
||||
core_lv.innerHTML = "<b><font color=green>"+corelvis+"<%:<New>%></font></b>";
|
||||
}
|
||||
else if (corelvis != "" && corelvis != "\n" ) {
|
||||
else if (corelvis != "" && corelvis != "\n" && corelvis == status.corecv) {
|
||||
core_lv.innerHTML = "<b><font color=green>"+corelvis+"</font></b>";
|
||||
}
|
||||
else {
|
||||
core_lv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
|
||||
}
|
||||
if ( new_ch == "3" || new_ch == "4" ) {
|
||||
if (coretunlvis != status.coretuncv && coretunlvis != "" && coretunlvis != "\n") {
|
||||
core_tun_lv.innerHTML = "<b><font color=green>"+coretunlvis+"<%:<New>%></font></b>";
|
||||
}
|
||||
else if (coretunlvis != "" && coretunlvis != "\n" ) {
|
||||
else if (coretunlvis != "" && coretunlvis != "\n" && coretunlvis == status.coretuncv) {
|
||||
core_tun_lv.innerHTML = "<b><font color=green>"+coretunlvis+"</font></b>";
|
||||
}
|
||||
else {
|
||||
core_tun_lv.innerHTML = "<b><font color=red><%:Unknown%></font></b>";
|
||||
}
|
||||
if (coregamelvis != "" && coregamelvis != "\n" ) {
|
||||
if (coregamelvis != status.coregamecv && coregamelvis != "" && coregamelvis != "\n") {
|
||||
core_game_lv.innerHTML = "<b><font color=green>"+coregamelvis+"<%:<New>%></font></b>";
|
||||
}
|
||||
else if (coregamelvis != "" && coregamelvis != "\n" && coregamelvis == status.coregamecv) {
|
||||
core_game_lv.innerHTML = "<b><font color=green>"+coregamelvis+"</font></b>";
|
||||
}
|
||||
else {
|
||||
@ -259,7 +261,7 @@
|
||||
var arr_core = corelv.split(",");
|
||||
var coretunlvis = arr_core[1];
|
||||
if ( status.corever != "0\n" && coretunlvis != "\n" && coretunlvis != "" ) {
|
||||
url3='https://github.com/Dreamacro/clash/releases/download/TUN/clash-'+status.corever+'-'+coretunlvis+'.gz';
|
||||
url3='https://github.com/vernesong/OpenClash/releases/download/TUN-Premium/clash-'+status.corever+'-'+coretunlvis+'.gz';
|
||||
winOpen(url3);
|
||||
}
|
||||
else if ( status.corever == "0\n" ) {
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
<select name="file_type" style="width:auto">
|
||||
<option value="config" selected="selected"><%:Config File%></option>
|
||||
<option value="proxy-provider"><%:Proxy Provider File%></option>
|
||||
<option value="rule-provider"><%:Rule Provider File%></option>
|
||||
</select>
|
||||
<input class="cbi-input-file" style="width: 30%" type="file" id="ulfile" name="ulfile" />
|
||||
<input type="submit" class="cbi-button cbi-input-reload" name="upload" value="<%:Upload%>" />
|
||||
|
||||
@ -6,10 +6,6 @@ status=$(ps|grep -c /usr/share/openclash/clash_version.sh)
|
||||
|
||||
CKTIME=$(date "+%Y-%m-%d-%H")
|
||||
LAST_OPVER="/tmp/clash_last_version"
|
||||
LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
|
||||
CLASH_VER=$(/etc/openclash/core/clash -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
|
||||
LAST_TUN_VER=$(sed -n 2p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
|
||||
CLASH_TUN_VER=$(/etc/openclash/core/clash_tun -v 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
|
||||
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
PROXY_ADDR=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
|
||||
|
||||
@ -25,18 +21,8 @@ if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{prin
|
||||
curl -sL --connect-timeout 10 --retry 2 "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
|
||||
fi
|
||||
if [ "$?" -eq "0" ] && [ -s "$LAST_OPVER" ]; then
|
||||
LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
|
||||
LAST_TUN_VER=$(sed -n 2p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F 'v' '{print $2}' 2>/dev/null |awk -F '.' '{print $1"."$2$3}' 2>/dev/null)
|
||||
echo "CheckTime:$CKTIME" >>$LAST_OPVER
|
||||
else
|
||||
rm -rf $LAST_OPVER
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$(expr "$LAST_VER" \> "$CLASH_VER")" -eq 1 ] && [ "$(expr "$LAST_TUN_VER" \> "$CLASH_TUN_VER")" -eq 1 ]; then
|
||||
return 4
|
||||
elif [ "$(expr "$LAST_VER" \> "$CLASH_VER")" -eq 1 ]; then
|
||||
return 2
|
||||
elif [ "$(expr "$LAST_TUN_VER" \> "$CLASH_TUN_VER")" -eq 1 ]; then
|
||||
return 3
|
||||
fi 2>/dev/null
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#!/bin/bash /etc/rc.common
|
||||
status=$(ps|grep -c /usr/share/openclash/openclash.sh)
|
||||
[ "$status" -gt "3" ] && exit 0
|
||||
status=$(ps|grep -c /etc/init.d/openclash)
|
||||
[ "$status" -gt "1" ] && sleep 5
|
||||
|
||||
START_LOG="/tmp/openclash_start.log"
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
@ -203,9 +205,9 @@ sub_info_get()
|
||||
|
||||
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
|
||||
grep "^ \{0,\}proxy-groups:" "$CFG_FILE" >/dev/null 2>&1 && grep "^ \{0,\}rules:" "$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
|
||||
grep "^ \{0,\}Proxy:" "$CFG_FILE" >/dev/null 2>&1 || grep "^ \{0,\}proxy-providers:" "$CFG_FILE" >/dev/null 2>&1
|
||||
if [ "$?" -eq 0 ]; then
|
||||
config_su_check
|
||||
else
|
||||
|
||||
@ -50,7 +50,7 @@ if [ "$CORE_CV" != "$CORE_LV" ] || [ -z "$CORE_CV" ]; then
|
||||
case $CORE_TYPE in
|
||||
"Tun")
|
||||
echo "正在下载【Tun】版本内核,如下载失败请尝试手动下载并上传..." >$START_LOG
|
||||
curl -sL -m 30 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://github.com/Dreamacro/clash/releases/download/TUN/clash-"$CPU_MODEL"-"$CORE_LV".gz -o /tmp/clash.gz >/dev/null 2>&1
|
||||
curl -sL -m 30 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://github.com/vernesong/OpenClash/releases/download/TUN-Premium/clash-"$CPU_MODEL"-"$CORE_LV".gz -o /tmp/clash.gz >/dev/null 2>&1
|
||||
;;
|
||||
"Game")
|
||||
echo "正在下载【Game】版本内核,如下载失败请尝试手动下载并上传..." >$START_LOG
|
||||
|
||||
@ -262,10 +262,10 @@ if [ -n "$(grep OpenClash-General-Settings "$CONFIG_FILE")" ]; then
|
||||
else
|
||||
/usr/share/openclash/yml_field_name_ch.sh "$CONFIG_FILE" 2>/dev/null
|
||||
proxy_len=$(sed -n '/^Proxy:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^proxy-provider:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
group_len=$(sed -n '/^Proxy Group:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^proxy-providers:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
group_len=$(sed -n '/^proxy-groups:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
dns_len=$(sed -n '/^dns:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
rule_len=$(sed -n '/^Rule:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
rule_len=$(sed -n '/^rules:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
if [ "$dns_len" -ge "$proxy_len" ] || [ "$dns_len" -ge "$rule_len" ] || [ "$dns_len" -ge "$group_len" ]; then
|
||||
echo "错误: 不支持的配置文件, General 设置部分应位于开头,请根据模板修改后重试!" >> "$DEBUG_LOG"
|
||||
fi 2>/dev/null
|
||||
@ -281,11 +281,11 @@ else
|
||||
if [ "$proxy_len" -le "$provider_len" ]; then
|
||||
sed '/^ \{0,\}Proxy:/,$d' "$CONFIG_FILE" >> "$DEBUG_LOG" 2>/dev/null
|
||||
elif [ "$proxy_len" -ge "$provider_len" ]; then
|
||||
sed '/^ \{0,\}proxy-provider:/,$d' "$CONFIG_FILE" >> "$DEBUG_LOG" 2>/dev/null
|
||||
sed '/^ \{0,\}proxy-providers:/,$d' "$CONFIG_FILE" >> "$DEBUG_LOG" 2>/dev/null
|
||||
elif [ -n "$proxy_len" ] && [ -z "$provider_len" ]; then
|
||||
sed '/^ \{0,\}Proxy:/,$d' "$CONFIG_FILE" >> "$DEBUG_LOG" 2>/dev/null
|
||||
elif [ -z "$proxy_len" ] && [ -n "$provider_len" ]; then
|
||||
sed '/^ \{0,\}proxy-provider:/,$d' "$CONFIG_FILE" >> "$DEBUG_LOG" 2>/dev/null
|
||||
sed '/^ \{0,\}proxy-providers:/,$d' "$CONFIG_FILE" >> "$DEBUG_LOG" 2>/dev/null
|
||||
fi 2>/dev/null
|
||||
fi
|
||||
|
||||
|
||||
@ -3,15 +3,20 @@
|
||||
CURL_GROUP_CACHE="/tmp/openclash_history_gorup.json"
|
||||
CURL_NOW_CACHE="/tmp/openclash_history_now.json"
|
||||
CURL_CACHE="/tmp/openclash_history_curl.json"
|
||||
HISTORY_PATH="/etc/openclash/history"
|
||||
CONFIG_FILE=$(ps -w|grep /etc/openclash/clash 2>/dev/null |grep -v grep |awk -F '-f ' '{print $2}' 2>/dev/null)
|
||||
CONFIG_NAME=$(echo "$CONFIG_FILE" |awk -F '/' '{print $5}' 2>/dev/null)
|
||||
HISTORY_PATH="/etc/openclash/history/$CONFIG_NAME"
|
||||
SECRET=$(uci get openclash.config.dashboard_password 2>/dev/null)
|
||||
LAN_IP=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
|
||||
PORT=$(uci get openclash.config.cn_port 2>/dev/null)
|
||||
|
||||
curl -m 5 --retry 2 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies > "$CURL_CACHE" 2>/dev/null
|
||||
if [ "$(sed -n '$p' "$CURL_CACHE" 2>/dev/null)" = "200" ]; then
|
||||
cat "$CURL_CACHE" |jsonfilter -e '@["proxies"][@.type="Selector"]["name"]' > "$CURL_GROUP_CACHE" 2>/dev/null
|
||||
cat "$CURL_CACHE" |jsonfilter -e '@["proxies"][@.type="Selector"]["now"]' > "$CURL_NOW_CACHE" 2>/dev/null
|
||||
awk 'NR==FNR{a[i]=$0;i++}NR>FNR{print a[j]"#*#"$0;j++}' "$CURL_GROUP_CACHE" "$CURL_NOW_CACHE" > "$HISTORY_PATH" 2>/dev/null
|
||||
if pidof clash >/dev/null; then
|
||||
curl -m 5 --retry 2 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies > "$CURL_CACHE" 2>/dev/null
|
||||
if [ "$(sed -n '$p' "$CURL_CACHE" 2>/dev/null)" = "200" ]; then
|
||||
mkdir -p /etc/openclash/history 2>/dev/null
|
||||
cat "$CURL_CACHE" |jsonfilter -e '@["proxies"][@.type="Selector"]["name"]' > "$CURL_GROUP_CACHE" 2>/dev/null
|
||||
cat "$CURL_CACHE" |jsonfilter -e '@["proxies"][@.type="Selector"]["now"]' > "$CURL_NOW_CACHE" 2>/dev/null
|
||||
awk 'NR==FNR{a[i]=$0;i++}NR>FNR{print a[j]"#*#"$0;j++}' "$CURL_GROUP_CACHE" "$CURL_NOW_CACHE" > "$HISTORY_PATH" 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
rm -rf /tmp/openclash_history_* 2>/dev/null
|
||||
@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
HISTORY_PATH="/etc/openclash/history"
|
||||
CONFIG_FILE=$(uci get openclash.config.config_path 2>/dev/null)
|
||||
CONFIG_NAME=$(echo "$CONFIG_FILE" |awk -F '/' '{print $5}' 2>/dev/null)
|
||||
HISTORY_PATH="/etc/openclash/history/$CONFIG_NAME"
|
||||
SECRET=$(uci get openclash.config.dashboard_password 2>/dev/null)
|
||||
LAN_IP=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
|
||||
PORT=$(uci get openclash.config.cn_port 2>/dev/null)
|
||||
@ -19,24 +21,32 @@ GROUP_STATE() {
|
||||
echo "$(curl -m 5 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies/"$1" 2>/dev/null |sed -n '$p' 2>/dev/null)"
|
||||
}
|
||||
|
||||
restore_history() {
|
||||
GROUP_NAME=$(urlencode "$GROUP_NAME")
|
||||
NOW_NAME=$(echo $line |awk -F '#*#' '{print $3}')
|
||||
GROUP_STATE=$(GROUP_STATE "$GROUP_NAME")
|
||||
GROUP_STATE_NUM=0
|
||||
while ( [ ! -z "$(pidof clash)" ] && [ "$GROUP_STATE" != "200" ] && [ "$GROUP_STATE_NUM" -le 1 ] )
|
||||
do
|
||||
sleep 3
|
||||
GROUP_STATE_NUM=$(expr "$GROUP_STATE_NUM" + 1)
|
||||
GROUP_STATE=$(GROUP_STATE "$GROUP_NAME")
|
||||
done
|
||||
curl -m 5 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GROUP_NAME" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
if [ -s "$HISTORY_PATH" ]; then
|
||||
cat $HISTORY_PATH |while read line
|
||||
do
|
||||
GROUP_NAME=$(echo $line |awk -F '#*#' '{print $1}')
|
||||
if [ -z "$(echo $line |grep "#*#")" ] || [ -z "$(grep "^$GROUP_NAME$" /tmp/Proxy_Group)" ]; then
|
||||
continue
|
||||
if [ "$GROUP_NAME" != "GLOBAL" ]; then
|
||||
if [ -z "$(echo $line |grep "#*#")" ] || [ -z "$(grep "^$GROUP_NAME$" /tmp/Proxy_Group)" ]; then
|
||||
continue
|
||||
else
|
||||
restore_history
|
||||
fi
|
||||
else
|
||||
GROUP_NAME=$(urlencode "$GROUP_NAME")
|
||||
NOW_NAME=$(echo $line |awk -F '#*#' '{print $3}')
|
||||
GROUP_STATE=$(GROUP_STATE "$GROUP_NAME")
|
||||
GROUP_STATE_NUM=0
|
||||
while ( [ ! -z "$(pidof clash)" ] && [ "$GROUP_STATE" != "200" ] && [ "$GROUP_STATE_NUM" -le 1 ] )
|
||||
do
|
||||
sleep 3
|
||||
GROUP_STATE_NUM=$(expr "$GROUP_STATE_NUM" + 1)
|
||||
GROUP_STATE=$(GROUP_STATE "$GROUP_NAME")
|
||||
done
|
||||
curl -m 5 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GROUP_NAME" >/dev/null 2>&1
|
||||
restore_history
|
||||
fi
|
||||
done >/dev/null 2>&1
|
||||
fi
|
||||
@ -1,4 +1,7 @@
|
||||
#!/bin/sh
|
||||
status=$(ps|grep -c /etc/init.d/openclash)
|
||||
[ "$status" -gt "1" ] && sleep 5
|
||||
|
||||
START_LOG="/tmp/openclash_start.log"
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOG_FILE="/tmp/openclash.log"
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#!/bin/sh
|
||||
status=$(ps|grep -c /etc/init.d/openclash)
|
||||
[ "$status" -gt "1" ] && sleep 5
|
||||
|
||||
START_LOG="/tmp/openclash_start.log"
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOG_FILE="/tmp/openclash.log"
|
||||
@ -17,31 +20,31 @@
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/lhie1/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
fi
|
||||
sed -i '1i Rule:' /tmp/rules.yaml
|
||||
sed -i '1i rules:' /tmp/rules.yaml
|
||||
elif [ "$RUlE_SOURCE" = "ConnersHua" ]; then
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT -U "$PROXY_AUTH" https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/Pro.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/Pro.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
fi
|
||||
sed -i "/^rules:/c\^Rule:" /tmp/rules.yaml 2>/dev/null && sed -i -n '/^Rule:/,$p' /tmp/rules.yaml 2>/dev/null
|
||||
sed -i "/^Rule:/c\^rules:" /tmp/rules.yaml 2>/dev/null && sed -i -n '/^rules:/,$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 -U "$PROXY_AUTH" 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 "/^rules:/c\^Rule:" /tmp/rules.yaml 2>/dev/null && sed -i -n '/^Rule:/,$p' /tmp/rules.yaml 2>/dev/null
|
||||
sed -i "/^Rule:/c\^rules:" /tmp/rules.yaml 2>/dev/null && sed -i -n '/^rules:/,$p' /tmp/rules.yaml 2>/dev/null
|
||||
fi
|
||||
if [ "$?" -eq "0" ] && [ "$RUlE_SOURCE" != 0 ] && [ -s "/tmp/rules.yaml" ]; then
|
||||
echo "下载成功,开始预处理规则文件..." >$START_LOG
|
||||
sed -i "/^Rule:/a\##source:${RUlE_SOURCE}" /tmp/rules.yaml >/dev/null 2>&1
|
||||
sed -i "/^rules:/a\##source:${RUlE_SOURCE}" /tmp/rules.yaml >/dev/null 2>&1
|
||||
echo "检查下载的规则文件是否有更新..." >$START_LOG
|
||||
cmp -s /etc/openclash/"$RUlE_SOURCE".yaml /tmp/rules.yaml
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "检测到下载的规则文件有更新,开始替换..." >$START_LOG
|
||||
mv /tmp/rules.yaml /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1
|
||||
sed -i '/^Rule:/a\##updated' /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1
|
||||
sed -i '/^rules:/a\##updated' /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1
|
||||
echo "替换成功,重新加载 OpenClash 应用新规则..." >$START_LOG
|
||||
/etc/init.d/openclash restart 2>/dev/null
|
||||
echo "${LOGTIME} Other Rules 【$RUlE_SOURCE】 Update Successful" >>$LOG_FILE
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="UTF-8"><link rel="shortcut icon" href="yacd.ico"><link rel="icon" type="image/png" sizes="64x64" href="yacd-64.png"><link rel="icon" type="image/png" sizes="128x128" href="yacd-128.png"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="application-name" content="yacd"><meta name="description" content="Yet Another Clash Dashboard"><meta name="theme-color" content="#202020"><title>yacd - Yet Another Clash Dashboard</title><link href="https://fonts.googleapis.com/css2?family=Merriweather+Sans:wght@400;700&family=Roboto+Mono&display=swap" rel="stylesheet"><meta property="og:image" content="https://user-images.githubusercontent.com/1166872/47304841-536f3d80-d65a-11e8-8908-1917127dafc5.png"><meta property="og:site_name" content="yacd"><meta property="og:type" content="object"><meta property="og:title" content="yacd"><meta property="og:url" content="http://yacd.haishan.me"><meta property="og:description" content="Yet Another Clash Dashboard"><script defer="defer" src="runtime.4c1edc8c2d6902d92cc4.js"></script><script defer="defer" src="core-js~app.b0709810482830abfa61.js"></script><script defer="defer" src="react~app.45d91d3dcd725ceea7ca.js"></script><script defer="defer" src="app.081203a887c789b3caf4.js"></script><link href="app.dd24893376573afd8b22.css" rel="stylesheet"></head><body><div id="app"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="UTF-8"><link rel="shortcut icon" href="yacd.ico"><link rel="icon" type="image/png" sizes="64x64" href="yacd-64.png"><link rel="icon" type="image/png" sizes="128x128" href="yacd-128.png"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="application-name" content="yacd"><meta name="description" content="Yet Another Clash Dashboard"><meta name="theme-color" content="#202020"><title>yacd - Yet Another Clash Dashboard</title><link href="https://fonts.googleapis.com/css2?family=Merriweather+Sans:wght@400;700&family=Roboto+Mono&display=swap" rel="stylesheet"><meta property="og:image" content="https://user-images.githubusercontent.com/1166872/47304841-536f3d80-d65a-11e8-8908-1917127dafc5.png"><meta property="og:site_name" content="yacd"><meta property="og:type" content="object"><meta property="og:title" content="yacd"><meta property="og:url" content="http://yacd.haishan.me"><meta property="og:description" content="Yet Another Clash Dashboard"><script defer="defer" src="runtime.19a1a1c098f3d2fbd54e.js"></script><script defer="defer" src="core-js~app.b214178cdb71012cd622.js"></script><script defer="defer" src="react~app.e2d573992419eb24e61b.js"></script><script defer="defer" src="app.1de83e4934f843dc8d9b.js"></script><link href="app.6c8a97d4cbae5f4b8f38.css" rel="stylesheet"></head><body><div id="app"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,9 @@
|
||||
._37wt2_a2Gx{display:flex;align-items:center}._37wt2_a2Gx .L80zPM0Rx0{display:inline-flex;-ms-transform:rotate(0deg);transform:rotate(0deg);transition:transform .3s}._37wt2_a2Gx .L80zPM0Rx0._36RO7_wtuv{-ms-transform:rotate(180deg);transform:rotate(180deg)}._37wt2_a2Gx .L80zPM0Rx0:focus{outline:var(--color-focus-blue) solid 1px}._2XKN3NArpV{margin-left:5px}._1s98xvUoBx{font-family:var(--font-normal);font-size:.75em;margin-left:3px;padding:2px 7px;display:inline-flex;justify-content:center;align-items:center;background-color:var(--bg-near-transparent);border-radius:30px}
|
||||
._2V-RqIAl7n{border-radius:20px;color:#eee;font-size:.6em}@media screen and (min-width:30em){._2V-RqIAl7n{font-size:1em}}
|
||||
.NpfXwxWAxo{position:relative;padding:5px;border-radius:8px;overflow:hidden;max-width:280px;background-color:var(--color-bg-proxy)}@media screen and (min-width:30em){.NpfXwxWAxo{min-width:200px;border-radius:10px;padding:10px}}.NpfXwxWAxo._2zD7drviYH{background-color:var(--color-focus-blue);color:#ddd}.NpfXwxWAxo._2bylJNYYdN{opacity:.5}._1rVl-Kdmss{font-family:var(--font-mono);font-size:.6em}@media screen and (min-width:30em){._1rVl-Kdmss{font-size:1em}}.aS2noEcBcP{display:flex;align-items:center;justify-content:space-between}._3kdi5nima5{width:100%;overflow:hidden;text-overflow:ellipsis;margin-bottom:5px;font-size:.85em}@media screen and (min-width:30em){._3kdi5nima5{font-size:1.1em}}._3NpxWygDxO{width:12px;height:12px;border-radius:8px}._3NpxWygDxO ._2zD7drviYH{outline:1px solid pink}
|
||||
._3PCSxT0l14{margin-bottom:12px}._1yYRIyvlRd{display:flex;flex-wrap:wrap;margin-top:8px}._1OcDlvlM5R{margin-right:5px;margin-bottom:5px;transition:transform .2s ease-in-out}@media screen and (min-width:30em){._1OcDlvlM5R{margin-right:10px;margin-bottom:10px}}._1OcDlvlM5R._3oAxPKtZFv{cursor:pointer}._1OcDlvlM5R._3oAxPKtZFv:hover{-ms-transform:translateY(-2px);transform:translateY(-2px)}
|
||||
._2OKIZuCJtW{background-color:rgba(0,0,0,.6)}._1y6NeshM4O{position:absolute;background-color:var(--bg-modal);color:var(--color-text);line-height:1.4;opacity:.6;transition:all .3s ease;-ms-transform:translate(-50%,-50%) scale(1.2);transform:translate(-50%,-50%) scale(1.2);box-shadow:0 4px 4px rgba(0,0,0,.12),0 16px 32px rgba(0,0,0,.24)}._25KARE4UsT{opacity:1;-ms-transform:translate(-50%,-50%) scale(1);transform:translate(-50%,-50%) scale(1)}
|
||||
.t6lsDKNXTK{height:30px;width:100%;padding-left:8px;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--color-background);color:var(--color-text);padding-right:20px;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg width='8' height='24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 7l3 4H1l3-4zM4 17l-3-4h6l-3 4z' fill='%23999'/%3E%3C/svg%3E");border-radius:4px;border-image:initial;border:1px solid var(--select-border-color);transition:all .1s ease 0s;background-position:calc(100% - 8px) 50%;background-repeat:no-repeat}.t6lsDKNXTK:focus,.t6lsDKNXTK:hover{border-color:#343434;outline:none!important;color:var(--color-text-highlight);background-image:var(--select-bg-hover)}.t6lsDKNXTK option{background-color:var(--color-background)}
|
||||
._1h4Qixiwxj{max-width:85vw;width:400px;display:flex;justify-content:space-between;align-items:center;font-size:13px;padding:13px 0}hr{height:1px;background-color:var(--color-separator);border:none;outline:none;margin:1rem 0}
|
||||
._3GVE9k27aM{margin-bottom:12px}._3GVE9k27aM small{color:#777}._1PV2l5z2zN{padding:10px 15px}@media screen and (min-width:30em){._1PV2l5z2zN{padding:10px 40px}}._1b5XrAhEUm{display:flex}._1b5XrAhEUm button{margin:0 5px}._1b5XrAhEUm button:first-child{margin-left:0}._2t6Q6BkZ73{display:flex;justify-content:center;align-items:center;cursor:pointer}
|
||||
._39uWX_-wQq{position:-webkit-sticky;position:sticky;top:0;z-index:1;background:var(--color-background);display:flex;justify-content:flex-end;padding:5px 5px 2px 0}._1myfcMimT9{padding:10px 15px}@media screen and (min-width:30em){._1myfcMimT9{padding:10px 40px}}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{BVyM:function(e,t,a){"use strict";a.r(t);var r=a("ODXe"),n=a("q1tI"),i=a.n(n),o=a("iR1w"),c=a("OAQO"),l=a("9cvt"),u=a("WfPo"),s=a("OADI"),f=a("DKqX"),p=a("17x9"),d=a.n(p),m=a("xrux"),v=a.n(m),b={_default:"#59caf9",DIRECT:"#f5bc41",REJECT:"#cb3166"};function y(e){var t=e.type,a=e.payload,r=e.proxy,n=e.id,o=function(e){var t=e.proxy,a=b._default;return b[t]&&(a=b[t]),{color:a}}({proxy:r});return i.a.createElement("div",{className:v.a.rule},i.a.createElement("div",{className:v.a.left},n),i.a.createElement("div",null,i.a.createElement("div",{className:v.a.b},a),i.a.createElement("div",{className:v.a.a},i.a.createElement("div",{className:v.a.type},t),i.a.createElement("div",{style:o},r))))}y.propTypes={id:d.a.number,type:d.a.string,payload:d.a.string,proxy:d.a.string};var O=y,E=a("II4a"),h=a("EwbC"),w=Object(u.a)((function(e){return{searchText:Object(h.d)(e),updateSearchText:h.f}}))(E.a),g=a("Kv4h"),x=i.a.memo,j=i.a.useEffect,k=i.a.useMemo,C=i.a.useCallback;function N(e,t){return t[e].id}var I=x((function(e){var t=e.index,a=e.style,r=e.data[t];return i.a.createElement("div",{style:a},i.a.createElement(O,r))}),o.b);t.default=Object(u.a)((function(e){return{apiConfig:Object(s.b)(e),rules:Object(h.c)(e)}}))((function(e){var t=e.dispatch,a=e.apiConfig,n=e.rules,u=C((function(){t(Object(h.a)(a))}),[a,t]);j((function(){t(Object(h.b)(a))}),[t,a]);var s=Object(g.a)(),p=Object(r.a)(s,2),d=p[0],m=p[1],v=k((function(){return i.a.createElement(c.a,{width:16})}),[]);return i.a.createElement("div",null,i.a.createElement(f.a,{title:"Rules"}),i.a.createElement(w,null),i.a.createElement("div",{ref:d,style:{paddingBottom:30}},i.a.createElement(o.a,{height:m-30,width:"100%",itemCount:n.length,itemSize:80,itemData:n,itemKey:N},I)),i.a.createElement(l.b,{icon:v,text:"Refresh",onClick:u,position:l.c}))}))},OAQO:function(e,t,a){"use strict";var r=a("q1tI"),n=a.n(r),i=a("17x9"),o=a.n(i);function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e}).apply(this,arguments)}function l(e,t){if(null==e)return{};var a,r,n=function(e,t){if(null==e)return{};var a,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)>=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var u=Object(r.forwardRef)((function(e,t){var a=e.color,r=void 0===a?"currentColor":a,i=e.size,o=void 0===i?24:i,u=l(e,["color","size"]);return n.a.createElement("svg",c({ref:t,xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},u),n.a.createElement("polyline",{points:"23 4 23 10 17 10"}),n.a.createElement("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"}))}));u.propTypes={color:o.a.string,size:o.a.oneOfType([o.a.string,o.a.number])},u.displayName="RotateCw",t.a=u},xrux:function(e,t,a){e.exports={rule:"_3eSLieOhVX",left:"_2n1pW09UvV",a:"t1XJIwvW7A",b:"_1fNf8kj0HA",type:"_3yJmN0tON0"}}}]);
|
||||
@ -1 +0,0 @@
|
||||
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{BVyM:function(e,t,a){"use strict";a.r(t);var r=a("ODXe"),n=a("q1tI"),i=a.n(n),c=a("5Wrh"),o=a("iR1w"),l=a("OAQO"),u=a("WfPo"),s=a("OADI"),f=a("DKqX"),p=a("17x9"),m=a.n(p),d=a("xrux"),v=a.n(d),b={_default:"#59caf9",DIRECT:"#f5bc41",REJECT:"#cb3166"};function y(e){var t=e.type,a=e.payload,r=e.proxy,n=e.id,c=function(e){var t=e.proxy,a=b._default;return b[t]&&(a=b[t]),{color:a}}({proxy:r});return i.a.createElement("div",{className:v.a.rule},i.a.createElement("div",{className:v.a.left},n),i.a.createElement("div",null,i.a.createElement("div",{className:v.a.b},a),i.a.createElement("div",{className:v.a.a},i.a.createElement("div",{className:v.a.type},t),i.a.createElement("div",{style:c},r))))}y.propTypes={id:m.a.number,type:m.a.string,payload:m.a.string,proxy:m.a.string};var O=y,E=a("II4a"),h=a("EwbC"),w=Object(u.a)((function(e){return{searchText:Object(h.d)(e),updateSearchText:h.f}}))(E.a),g=a("Kv4h"),x=i.a.memo,j=i.a.useEffect,k=i.a.useMemo,C=i.a.useCallback;function N(e,t){return t[e].id}var I=x((function(e){var t=e.index,a=e.style,r=e.data[t];return i.a.createElement("div",{style:a},i.a.createElement(O,r))}),o.b);t.default=Object(u.a)((function(e){return{apiConfig:Object(s.b)(e),rules:Object(h.c)(e)}}))((function(e){var t=e.dispatch,a=e.apiConfig,n=e.rules,u=C((function(){t(Object(h.a)(a))}),[a,t]);j((function(){t(Object(h.b)(a))}),[t,a]);var s=Object(g.a)(),p=Object(r.a)(s,2),m=p[0],d=p[1],v=k((function(){return i.a.createElement(l.a,{width:16})}),[]);return i.a.createElement("div",null,i.a.createElement(f.a,{title:"Rules"}),i.a.createElement(w,null),i.a.createElement("div",{ref:m,style:{paddingBottom:30}},i.a.createElement(o.a,{height:d-30,width:"100%",itemCount:n.length,itemSize:80,itemData:n,itemKey:N},I)),i.a.createElement("div",{className:"fabgrp"},i.a.createElement(c.a,{text:"Refresh",start:v,onClick:u})))}))},OAQO:function(e,t,a){"use strict";var r=a("q1tI"),n=a.n(r),i=a("17x9"),c=a.n(i);function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e}).apply(this,arguments)}function l(e,t){if(null==e)return{};var a,r,n=function(e,t){if(null==e)return{};var a,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)>=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var u=Object(r.forwardRef)((function(e,t){var a=e.color,r=void 0===a?"currentColor":a,i=e.size,c=void 0===i?24:i,u=l(e,["color","size"]);return n.a.createElement("svg",o({ref:t,xmlns:"http://www.w3.org/2000/svg",width:c,height:c,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},u),n.a.createElement("polyline",{points:"23 4 23 10 17 10"}),n.a.createElement("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"}))}));u.propTypes={color:c.a.string,size:c.a.oneOfType([c.a.string,c.a.number])},u.displayName="RotateCw",t.a=u},xrux:function(e,t,a){e.exports={rule:"_3eSLieOhVX",left:"_2n1pW09UvV",a:"t1XJIwvW7A",b:"_1fNf8kj0HA",type:"_3yJmN0tON0"}}}]);
|
||||
@ -1 +1 @@
|
||||
!function(e){function t(t){for(var n,o,i=t[0],l=t[1],d=t[2],f=t[3]||[],s=0,h=[];s<i.length;s++)o=i[s],Object.prototype.hasOwnProperty.call(a,o)&&a[o]&&h.push(a[o][0]),a[o]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(p&&p(t),u.push.apply(u,f);h.length;)h.shift()();return c.push.apply(c,d||[]),r()}function r(){for(var e,t=0;t<c.length;t++){for(var r=c[t],n=!0,o=1;o<r.length;o++){var d=r[o];0!==a[d]&&(n=!1)}n&&(c.splice(t--,1),e=l(l.s=r[0]))}return 0===c.length&&(u.forEach((function(e){if(void 0===a[e]){a[e]=null;var t=document.createElement("link");l.nc&&t.setAttribute("nonce",l.nc),t.rel="prefetch",t.as="script",t.href=i(e),document.head.appendChild(t)}})),u.length=0),e}var n={},o={5:0},a={5:0},c=[],u=[];function i(e){return l.p+""+({2:"proxies",4:"rules",6:"vendors~chartjs",7:"vendors~proxies"}[e]||e)+"."+{2:"290aebbdd24f562dda4f",4:"62726e52be64c2dee90b",6:"57612a3f835ecbd3f833",7:"39da2826d7e3275c0f85",8:"7c5d9bf7da55a9a368d7"}[e]+".js"}function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.e=function(e){var t=[];o[e]?t.push(o[e]):0!==o[e]&&{2:1,4:1}[e]&&t.push(o[e]=new Promise((function(t,r){for(var n=({2:"proxies",4:"rules",6:"vendors~chartjs",7:"vendors~proxies"}[e]||e)+"."+{2:"b04c42e07b90325c0dc5",4:"664f8b737878361937cb",6:"31d6cfe0d16ae931b73c",7:"31d6cfe0d16ae931b73c",8:"31d6cfe0d16ae931b73c"}[e]+".css",a=l.p+n,c=document.getElementsByTagName("link"),u=0;u<c.length;u++){var i=(f=c[u]).getAttribute("data-href")||f.getAttribute("href");if("stylesheet"===f.rel&&(i===n||i===a))return t()}var d=document.getElementsByTagName("style");for(u=0;u<d.length;u++){var f;if((i=(f=d[u]).getAttribute("data-href"))===n||i===a)return t()}var s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.onload=t,s.onerror=function(t){var n=t&&t.target&&t.target.src||a,c=new Error("Loading CSS chunk "+e+" failed.\n("+n+")");c.code="CSS_CHUNK_LOAD_FAILED",c.request=n,delete o[e],s.parentNode.removeChild(s),r(c)},s.href=a,document.getElementsByTagName("head")[0].appendChild(s)})).then((function(){o[e]=0})));var r=a[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=a[e]=[t,n]}));t.push(r[2]=n);var c,u=document.createElement("script");u.charset="utf-8",u.timeout=120,l.nc&&u.setAttribute("nonce",l.nc),u.src=i(e);var d=new Error;c=function(t){u.onerror=u.onload=null,clearTimeout(f);var r=a[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;d.message="Loading chunk "+e+" failed.\n("+n+": "+o+")",d.name="ChunkLoadError",d.type=n,d.request=o,r[1](d)}a[e]=void 0}};var f=setTimeout((function(){c({type:"timeout",target:u})}),12e4);u.onerror=u.onload=c,document.head.appendChild(u)}return Promise.all(t)},l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="",l.oe=function(e){throw console.error(e),e};var d=window.webpackJsonp=window.webpackJsonp||[],f=d.push.bind(d);d.push=t,d=d.slice();for(var s=0;s<d.length;s++)t(d[s]);var p=f;r()}([]);
|
||||
!function(e){function t(t){for(var n,o,i=t[0],l=t[1],f=t[2],s=t[3]||[],d=0,h=[];d<i.length;d++)o=i[d],Object.prototype.hasOwnProperty.call(a,o)&&a[o]&&h.push(a[o][0]),a[o]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(p&&p(t),u.push.apply(u,s);h.length;)h.shift()();return c.push.apply(c,f||[]),r()}function r(){for(var e,t=0;t<c.length;t++){for(var r=c[t],n=!0,o=1;o<r.length;o++){var f=r[o];0!==a[f]&&(n=!1)}n&&(c.splice(t--,1),e=l(l.s=r[0]))}return 0===c.length&&(u.forEach((function(e){if(void 0===a[e]){a[e]=null;var t=document.createElement("link");l.nc&&t.setAttribute("nonce",l.nc),t.rel="prefetch",t.as="script",t.href=i(e),document.head.appendChild(t)}})),u.length=0),e}var n={},o={5:0},a={5:0},c=[],u=[];function i(e){return l.p+""+({2:"proxies",4:"rules",6:"vendors~chartjs",7:"vendors~proxies"}[e]||e)+"."+{2:"98cabc7dc53e642492d1",4:"5123c4f00bc3b0a54628",6:"fa4d4e9c5ca3297a0d20",7:"cd3f974bfcc521d59a74",8:"7958f6e20b89d91ec605"}[e]+".js"}function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.e=function(e){var t=[];o[e]?t.push(o[e]):0!==o[e]&&{2:1,4:1}[e]&&t.push(o[e]=new Promise((function(t,r){for(var n=({2:"proxies",4:"rules",6:"vendors~chartjs",7:"vendors~proxies"}[e]||e)+"."+{2:"f2fb2adff629251cabb9",4:"664f8b737878361937cb",6:"31d6cfe0d16ae931b73c",7:"31d6cfe0d16ae931b73c",8:"31d6cfe0d16ae931b73c"}[e]+".css",a=l.p+n,c=document.getElementsByTagName("link"),u=0;u<c.length;u++){var i=(s=c[u]).getAttribute("data-href")||s.getAttribute("href");if("stylesheet"===s.rel&&(i===n||i===a))return t()}var f=document.getElementsByTagName("style");for(u=0;u<f.length;u++){var s;if((i=(s=f[u]).getAttribute("data-href"))===n||i===a)return t()}var d=document.createElement("link");d.rel="stylesheet",d.type="text/css",d.onload=t,d.onerror=function(t){var n=t&&t.target&&t.target.src||a,c=new Error("Loading CSS chunk "+e+" failed.\n("+n+")");c.code="CSS_CHUNK_LOAD_FAILED",c.request=n,delete o[e],d.parentNode.removeChild(d),r(c)},d.href=a,document.getElementsByTagName("head")[0].appendChild(d)})).then((function(){o[e]=0})));var r=a[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=a[e]=[t,n]}));t.push(r[2]=n);var c,u=document.createElement("script");u.charset="utf-8",u.timeout=120,l.nc&&u.setAttribute("nonce",l.nc),u.src=i(e);var f=new Error;c=function(t){u.onerror=u.onload=null,clearTimeout(s);var r=a[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;f.message="Loading chunk "+e+" failed.\n("+n+": "+o+")",f.name="ChunkLoadError",f.type=n,f.request=o,r[1](f)}a[e]=void 0}};var s=setTimeout((function(){c({type:"timeout",target:u})}),12e4);u.onerror=u.onload=c,document.head.appendChild(u)}return Promise.all(t)},l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="",l.oe=function(e){throw console.error(e),e};var f=window.webpackJsonp=window.webpackJsonp||[],s=f.push.bind(f);f.push=t,f=f.slice();for(var d=0;d<f.length;d++)t(f[d]);var p=s;r()}([]);
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -14,7 +14,7 @@
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(grep '^ enhanced-mode: $2' "$7")" ]; then
|
||||
if [ -z "$(grep "^ enhanced-mode: $2" "$7")" ]; then
|
||||
if [ ! -z "$(grep "^ \{0,\}enhanced-mode:" "$7")" ]; then
|
||||
sed -i "/^ \{0,\}enhanced-mode:/c\ enhanced-mode: ${2}" "$7"
|
||||
else
|
||||
@ -37,7 +37,7 @@
|
||||
sed -i '/##Custom DNS##/d' "$7" 2>/dev/null
|
||||
|
||||
|
||||
if [ -z "$(grep '^redir-port: $6' "$7")" ]; then
|
||||
if [ -z "$(grep "^redir-port: $6" "$7")" ]; then
|
||||
if [ ! -z "$(grep "^ \{0,\}redir-port:" "$7")" ]; then
|
||||
sed -i "/^ \{0,\}redir-port:/c\redir-port: ${6}" "$7"
|
||||
else
|
||||
@ -45,7 +45,7 @@
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(grep '^port: $9' "$7")" ]; then
|
||||
if [ -z "$(grep "^port: $9" "$7")" ]; then
|
||||
if [ ! -z "$(grep "^ \{0,\}port:" "$7")" ]; then
|
||||
sed -i "/^ \{0,\}port:/c\port: ${9}" "$7"
|
||||
else
|
||||
@ -53,7 +53,7 @@
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(grep '^socks-port: $10' "$7")" ]; then
|
||||
if [ -z "$(grep "^socks-port: $10" "$7")" ]; then
|
||||
if [ ! -z "$(grep "^ \{0,\}socks-port:" "$7")" ]; then
|
||||
sed -i "/^ \{0,\}socks-port:/c\socks-port: ${10}" "$7"
|
||||
else
|
||||
@ -61,7 +61,7 @@
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(grep '^mode: $13' "$7")" ]; then
|
||||
if [ -z "$(grep "^mode: $13" "$7")" ]; then
|
||||
if [ ! -z "$(grep "^ \{0,\}mode:" "$7")" ]; then
|
||||
sed -i "/^ \{0,\}mode:/c\mode: ${13}" "$7"
|
||||
else
|
||||
@ -69,7 +69,7 @@
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$(grep '^log-level: $12' "$7")" ]; then
|
||||
if [ -z "$(grep "^log-level: $12" "$7")" ]; then
|
||||
if [ ! -z "$(grep "^ \{0,\}log-level:" "$7")" ]; then
|
||||
sed -i "/^ \{0,\}log-level:/c\log-level: ${12}" "$7"
|
||||
else
|
||||
@ -81,11 +81,11 @@
|
||||
controller_address="0.0.0.0"
|
||||
bind_address="*"
|
||||
else
|
||||
controller_address="$11"
|
||||
bind_address="$11"
|
||||
controller_address=$11
|
||||
bind_address=$11
|
||||
fi
|
||||
|
||||
if [ -z "$(grep '^external-controller: $controller_address:$5' "$7")" ]; then
|
||||
if [ -z "$(grep "^external-controller: $controller_address:$5" "$7")" ]; then
|
||||
if [ ! -z "$(grep "^ \{0,\}external-controller:" "$7")" ]; then
|
||||
sed -i "/^ \{0,\}external-controller:/c\external-controller: ${controller_address}:${5}" "$7"
|
||||
else
|
||||
@ -94,7 +94,7 @@
|
||||
uci set openclash.config.config_reload=0
|
||||
fi
|
||||
|
||||
if [ -z "$(grep '^secret: \"$4\"' "$7")" ]; then
|
||||
if [ -z "$(grep "^secret: \"$4\"" "$7")" ]; then
|
||||
if [ ! -z "$(grep "^ \{0,\}secret:" "$7")" ]; then
|
||||
sed -i "/^ \{0,\}secret:/c\secret: \"${4}\"" "$7"
|
||||
else
|
||||
@ -114,7 +114,21 @@
|
||||
fi
|
||||
|
||||
uci commit openclash
|
||||
|
||||
dns_hijack_len=$(sed -n '/dns-hijack:/=' "$7" 2>/dev/null)
|
||||
if [ -n "$dns_hijack_len" ]; then
|
||||
dns_hijack_end_len=$dns_hijack_len
|
||||
while ( [ -n "$(echo "$hijack_line" |grep "^ \{0,\}-")" ] || [ -n "$(echo "$hijack_line" |grep "^ \{0,\}$")" ] || [ -z "$hijack_line" ] )
|
||||
do
|
||||
dns_hijack_end_len=$(expr "$dns_hijack_end_len" + 1)
|
||||
hijack_line=$(sed -n "${dns_hijack_end_len}p" "$7")
|
||||
done 2>/dev/null
|
||||
dns_hijack_end_len=$(expr "$dns_hijack_end_len" - 1)
|
||||
sed -i "${dns_hijack_len},${dns_hijack_end_len}d" "$7" 2>/dev/null
|
||||
fi
|
||||
sed -i '/^ \{0,\}tun:/,/^ \{0,\}enable:/d' "$7" 2>/dev/null
|
||||
sed -i '/^ \{0,\}dns-hijack:/d' "$7" 2>/dev/null
|
||||
sed -i '/^ \{0,\}stack:/d' "$7" 2>/dev/null
|
||||
sed -i '/^ \{0,\}device-url:/d' "$7" 2>/dev/null
|
||||
sed -i '/^ \{0,\}dns-listen:/d' "$7" 2>/dev/null
|
||||
|
||||
@ -166,7 +180,17 @@
|
||||
if [ "$15" -eq 1 ]; then
|
||||
sed -i "/^dns:/i\tun:" "$7"
|
||||
sed -i "/^dns:/i\ enable: true" "$7"
|
||||
elif [ ! -z "$15" ]; then
|
||||
if [ -n "$16" ]; then
|
||||
sed -i "/^dns:/i\ stack: ${16}" "$7"
|
||||
else
|
||||
sed -i "/^dns:/i\ stack: system" "$7"
|
||||
fi
|
||||
sed -i "/^dns:/i\ dns-hijack:" "$7"
|
||||
# sed -i "/^dns:/i\ - 8.8.8.8:53" "$7"
|
||||
sed -i "/^dns:/i\ - tcp://8.8.8.8:53" "$7"
|
||||
# sed -i "/^dns:/i\ - 8.8.4.4:53" "$7"
|
||||
sed -i "/^dns:/i\ - tcp://8.8.4.4:53" "$7"
|
||||
elif [ "$15" -eq 2 ]; then
|
||||
sed -i "/^dns:/i\tun:" "$7"
|
||||
sed -i "/^dns:/i\ enable: true" "$7"
|
||||
sed -i "/^dns:/i\ device-url: dev://clash0" "$7"
|
||||
@ -176,10 +200,10 @@
|
||||
#添加自定义Hosts设置
|
||||
|
||||
if [ "$2" = "redir-host" ]; then
|
||||
if [ -z "$(grep '^ \{0,\}hosts:' $7)" ]; then
|
||||
if [ -z "$(grep "^ \{0,\}hosts:" $7)" ]; then
|
||||
sed -i '/^dns:/i\hosts:' "$7" 2>/dev/null
|
||||
else
|
||||
if [ ! -z "$(grep '^ \{1,\}hosts:' $7)" ]; then
|
||||
if [ ! -z "$(grep "^ \{1,\}hosts:" $7)" ]; then
|
||||
sed -i "/^ \{0,\}hosts:/c\hosts:" "$7"
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -3,20 +3,20 @@
|
||||
YML_FILE="$1"
|
||||
|
||||
#proxy-providers
|
||||
[ -z "$(grep "^proxy-provider:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{1,\}proxy-provider:/proxy-provider:/g" "$YML_FILE" 2>/dev/null
|
||||
[ -z "$(grep "^proxy-providers:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{1,\}proxy-providers:/proxy-providers:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
[ -z "$(grep "^proxy-provider:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{0,\}proxy-providers:/proxy-provider:/g" "$YML_FILE" 2>/dev/null
|
||||
[ -z "$(grep "^proxy-providers:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{0,\}proxy-provider:/proxy-providers:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
#proxy-groups
|
||||
[ -z "$(grep "^Proxy Group:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{0,\}\'Proxy Group\':/Proxy Group:/g" "$YML_FILE" 2>/dev/null
|
||||
sed -i 's/^ \{0,\}\"Proxy Group\":/Proxy Group:/g' "$YML_FILE" 2>/dev/null
|
||||
sed -i "s/^ \{1,\}Proxy Group:/Proxy Group:/g" "$YML_FILE" 2>/dev/null
|
||||
[ -z "$(grep "^proxy-groups:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{0,\}\'Proxy Group\':/proxy-groups:/g" "$YML_FILE" 2>/dev/null
|
||||
sed -i 's/^ \{0,\}\"Proxy Group\":/proxy-groups:/g' "$YML_FILE" 2>/dev/null
|
||||
sed -i "s/^ \{1,\}proxy-groups:/proxy-groups:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
[ -z "$(grep "^Proxy Group:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{0,\}proxy-groups:/Proxy Group:/g" "$YML_FILE" 2>/dev/null
|
||||
[ -z "$(grep "^proxy-groups:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{0,\}Proxy Group:/proxy-groups:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
|
||||
#proxies
|
||||
@ -30,14 +30,24 @@ YML_FILE="$1"
|
||||
group_len=$(sed -n '/^Proxy Group:/=' "$YML_FILE" 2>/dev/null)
|
||||
proxies_len=$(sed -n '/proxies:/=' "$YML_FILE" 2>/dev/null |sed -n 1p)
|
||||
if [ "$proxies_len" -lt "$group_len" ]; then
|
||||
sed -i "${proxies_len}s/proxies:/Proxy:/" "$YML_FILE" 2>/dev/null
|
||||
sed -i "${proxies_len}s/ \{0,\}proxies:/Proxy:/" "$YML_FILE" 2>/dev/null
|
||||
fi 2>/dev/null
|
||||
}
|
||||
|
||||
#rules
|
||||
[ -z "$(grep "^Rule:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{1,\}Rule:/Rule:/g" "$YML_FILE" 2>/dev/null
|
||||
[ -z "$(grep "^rules:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{1,\}rules:/rules:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
[ -z "$(grep "^rules:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{0,\}Rule:/rules:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
|
||||
#rule-providers:
|
||||
[ -z "$(grep "^rule-providers:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{1,\}rule-providers:/rule-providers:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
|
||||
#script:
|
||||
[ -z "$(grep "^script:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{1,\}script:/script:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
[ -z "$(grep "^Rule:" "$YML_FILE")" ] && {
|
||||
sed -i "s/^ \{0,\}rules:/Rule:/g" "$YML_FILE" 2>/dev/null
|
||||
}
|
||||
@ -47,12 +47,12 @@ echo "开始更新【$CONFIG_NAME】的策略组配置..." >$START_LOG
|
||||
}
|
||||
|
||||
#判断各个区位置
|
||||
group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^ \{0,\}proxy-provider:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
group_len=$(sed -n '/^ \{0,\}proxy-groups:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^ \{0,\}proxy-providers:/=' "$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
|
||||
awk '/proxy-groups:/,/proxy-providers:/{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
|
||||
awk '/proxy-groups:/,/rules:/{print}' "$CONFIG_FILE" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\t/ /g' 2>/dev/null >/tmp/yaml_group.yaml 2>&1
|
||||
fi 2>/dev/null
|
||||
|
||||
#判断当前配置文件是否有策略组信息
|
||||
|
||||
@ -1,8 +1,33 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
. /lib/functions.sh
|
||||
|
||||
CFG_FILE=$(uci get openclash.config.config_path 2>/dev/null)
|
||||
UPDATE_CONFIG_FILE=$(uci get openclash.config.config_update_path 2>/dev/null)
|
||||
|
||||
get_nextlen()
|
||||
{
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for i in $@
|
||||
do
|
||||
if [ -z "$group_len" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
if [ "$group_len" -ge "$i" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$next_len" -gt "$i" ] || [ -z "$next_len" ]; then
|
||||
next_len="$i"
|
||||
fi
|
||||
done 2>/dev/null
|
||||
|
||||
}
|
||||
|
||||
if [ ! -z "$UPDATE_CONFIG_FILE" ]; then
|
||||
CFG_FILE="$UPDATE_CONFIG_FILE"
|
||||
fi
|
||||
@ -16,12 +41,16 @@ if [ -f "$CFG_FILE" ]; then
|
||||
/usr/share/openclash/yml_field_name_ch.sh "$CFG_FILE"
|
||||
|
||||
#判断各个区位置
|
||||
group_len=$(sed -n '/^Proxy Group:/=' "$CFG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/proxy-provider:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
if [ "$provider_len" -ge "$group_len" ]; then
|
||||
awk '/Proxy Group:/,/proxy-provider:/{print}' "$CFG_FILE" 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed 's/\t/ /g' 2>/dev/null |grep name: |awk -F 'name:' '{print $2}' |sed 's/,.*//' |sed 's/^ \{0,\}//' 2>/dev/null |sed 's/ \{0,\}$//' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null >/tmp/Proxy_Group 2>&1
|
||||
group_len=$(sed -n '/^proxy-groups:/=' "$CFG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/proxy-providers:/=' "$CFG_FILE" 2>/dev/null)
|
||||
rule_provider_len=$(sed -n '/^rule-providers:/=' "$CFG_FILE" 2>/dev/null)
|
||||
script_len=$(sed -n '/^script:/=' "$CFG_FILE" 2>/dev/null)
|
||||
get_nextlen "$provider_len" "$rule_provider_len" "$script_len"
|
||||
|
||||
if [ -n "$next_len" ]; then
|
||||
sed -n "${group_len},${next_len}p" "$CFG_FILE" 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed 's/\t/ /g' 2>/dev/null |grep name: |awk -F 'name:' '{print $2}' |sed 's/,.*//' |sed 's/^ \{0,\}//' 2>/dev/null |sed 's/ \{0,\}$//' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null >/tmp/Proxy_Group 2>&1
|
||||
else
|
||||
awk '/Proxy Group:/,/Rule:/{print}' "$CFG_FILE" 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed 's/\t/ /g' 2>/dev/null |grep name: |awk -F 'name:' '{print $2}' |sed 's/,.*//' |sed 's/^ \{0,\}//' 2>/dev/null |sed 's/ \{0,\}$//' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null >/tmp/Proxy_Group 2>&1
|
||||
awk '/proxy-groups:/,/rules:/{print}' "$CFG_FILE" 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed 's/\t/ /g' 2>/dev/null |grep name: |awk -F 'name:' '{print $2}' |sed 's/,.*//' |sed 's/^ \{0,\}//' 2>/dev/null |sed 's/ \{0,\}$//' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null >/tmp/Proxy_Group 2>&1
|
||||
fi
|
||||
|
||||
if [ "$?" -eq "0" ]; then
|
||||
|
||||
@ -245,7 +245,7 @@ if [ "$create_config" = "0" ] || [ "$servers_if_update" = "1" ] || [ ! -z "$if_g
|
||||
else
|
||||
if [ -z "$if_game_group" ]; then
|
||||
echo "开始写入配置文件【$CONFIG_NAME】的策略组信息..." >$START_LOG
|
||||
echo "Proxy Group:" >$GROUP_FILE
|
||||
echo "proxy-groups:" >$GROUP_FILE
|
||||
else
|
||||
echo "开始加入游戏策略组【$if_game_group】的信息..." >$START_LOG
|
||||
rm -rf $GROUP_FILE
|
||||
|
||||
@ -34,22 +34,22 @@ fi
|
||||
|
||||
#判断各个区位置
|
||||
proxy_len=$(sed -n '/^ \{0,\}Proxy:/=' "$CONFIG_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)
|
||||
group_len=$(sed -n '/^ \{0,\}proxy-groups:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^ \{0,\}proxy-providers:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
|
||||
if [ "$provider_len" -ge "$proxy_len" ] && [ "$provider_len" -le "$group_len" ]; then
|
||||
awk '/^ {0,}Proxy:/,/^ {0,}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_proxy.yaml 2>&1
|
||||
awk '/^ {0,}proxy-provider:/,/^ {0,}Proxy Group:/{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_provider.yaml 2>&1
|
||||
awk '/^ {0,}Proxy:/,/^ {0,}proxy-providers:/{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_proxy.yaml 2>&1
|
||||
awk '/^ {0,}proxy-providers:/,/^ {0,}proxy-groups:/{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_provider.yaml 2>&1
|
||||
elif [ "$provider_len" -le "$proxy_len" ]; then
|
||||
awk '/^ {0,}Proxy:/,/^ {0,}Proxy Group:/{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_proxy.yaml 2>&1
|
||||
awk '/^ {0,}proxy-provider:/,/^ {0,}Proxy:/{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_provider.yaml 2>&1
|
||||
awk '/^ {0,}Proxy:/,/^ {0,}proxy-groups:/{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_proxy.yaml 2>&1
|
||||
awk '/^ {0,}proxy-providers:/,/^ {0,}Proxy:/{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_provider.yaml 2>&1
|
||||
elif [ "$provider_len" -ge "$group_len" ]; then
|
||||
awk '/^ {0,}Proxy:/,/^ {0,}Proxy Group:/{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_proxy.yaml 2>&1
|
||||
awk '/^ {0,}proxy-provider:/,/^ {0,}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_provider.yaml 2>&1
|
||||
awk '/^ {0,}Proxy:/,/^ {0,}proxy-groups:/{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_proxy.yaml 2>&1
|
||||
awk '/^ {0,}proxy-providers:/,/^ {0,}rules:/{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_provider.yaml 2>&1
|
||||
elif [ "$provider_len" -le "$group_len" ]; then
|
||||
awk '/^ {0,}proxy-provider:/,/^ {0,}Proxy Group:/{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_provider.yaml 2>&1
|
||||
awk '/^ {0,}proxy-providers:/,/^ {0,}proxy-groups:/{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_provider.yaml 2>&1
|
||||
else
|
||||
awk '/^ {0,}Proxy:/,/^ {0,}Proxy Group:/{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_proxy.yaml 2>&1
|
||||
awk '/^ {0,}Proxy:/,/^ {0,}proxy-groups:/{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_proxy.yaml 2>&1
|
||||
fi
|
||||
|
||||
CFG_FILE="/etc/config/openclash"
|
||||
@ -79,8 +79,8 @@ sed -i 's/\"//g' $provider_file 2>/dev/null
|
||||
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 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_line=$(awk '{print $0"#*#"FNR}' $provider_file 2>/dev/null |grep -v '^ \{0,\}proxy-providers:\|^ \{0,\}Proxy:\|^ \{0,\}proxy-groups:\|^ \{0,\}rules:\|^ \{0,\}type:\|^ \{0,\}path:\|^ \{0,\}url:\|^ \{0,\}interval:\|^ \{0,\}health-check:\|^ \{0,\}enable:' |awk -F '#*#' '{print $3}')
|
||||
provider_num=$(grep -c "type:" $provider_file 2>/dev/null)
|
||||
provider_count=1
|
||||
|
||||
cfg_get()
|
||||
|
||||
@ -481,7 +481,7 @@ config_load "openclash"
|
||||
config_foreach new_servers_group_set "config_subscribe"
|
||||
#proxy-provider
|
||||
echo "开始写入配置文件【$CONFIG_NAME】的代理集信息..." >$START_LOG
|
||||
echo "proxy-provider:" >$PROXY_PROVIDER_FILE
|
||||
echo "proxy-providers:" >$PROXY_PROVIDER_FILE
|
||||
rm -rf /tmp/Proxy_Provider
|
||||
config_foreach yml_proxy_provider_set "proxy-provider"
|
||||
sed -i "s/^ \{0,\}/ - /" /tmp/Proxy_Provider 2>/dev/null #添加参数
|
||||
@ -507,7 +507,7 @@ fi
|
||||
#一键创建配置文件
|
||||
if [ "$rule_sources" = "ConnersHua" ] && [ "$servers_if_update" != "1" ] && [ -z "$if_game_proxy" ]; then
|
||||
echo "使用ConnersHua规则创建中..." >$START_LOG
|
||||
echo "Proxy Group:" >>$SERVER_FILE
|
||||
echo "proxy-groups:" >>$SERVER_FILE
|
||||
cat >> "$SERVER_FILE" <<-EOF
|
||||
- name: Auto - UrlTest
|
||||
type: url-test
|
||||
@ -607,7 +607,7 @@ ${UCI_SET}Others="Others"
|
||||
}
|
||||
elif [ "$rule_sources" = "lhie1" ] && [ "$servers_if_update" != "1" ] && [ -z "$if_game_proxy" ]; then
|
||||
echo "使用lhie1规则创建中..." >$START_LOG
|
||||
echo "Proxy Group:" >>$SERVER_FILE
|
||||
echo "proxy-groups:" >>$SERVER_FILE
|
||||
cat >> "$SERVER_FILE" <<-EOF
|
||||
- name: Auto - UrlTest
|
||||
type: url-test
|
||||
@ -825,7 +825,7 @@ ${UCI_SET}Others="Others"
|
||||
}
|
||||
elif [ "$rule_sources" = "ConnersHua_return" ] && [ "$servers_if_update" != "1" ] && [ -z "$if_game_proxy" ]; then
|
||||
echo "使用ConnersHua回国规则创建中..." >$START_LOG
|
||||
echo "Proxy Group:" >>$SERVER_FILE
|
||||
echo "proxy-groups:" >>$SERVER_FILE
|
||||
cat >> "$SERVER_FILE" <<-EOF
|
||||
- name: Auto - UrlTest
|
||||
type: url-test
|
||||
@ -876,7 +876,7 @@ ${UCI_SET}Others="Others"
|
||||
fi
|
||||
|
||||
if [ "$create_config" != "0" ] && [ "$servers_if_update" != "1" ] && [ -z "$if_game_proxy" ]; then
|
||||
echo "Rule:" >>$SERVER_FILE
|
||||
echo "rules:" >>$SERVER_FILE
|
||||
echo "配置文件【$CONFIG_NAME】创建完成,正在更新服务器、代理集、策略组信息..." >$START_LOG
|
||||
cat "$PROXY_PROVIDER_FILE" > "$CONFIG_FILE" 2>/dev/null
|
||||
cat "$SERVER_FILE" >> "$CONFIG_FILE" 2>/dev/null
|
||||
@ -885,23 +885,23 @@ elif [ -z "$if_game_proxy" ]; then
|
||||
echo "服务器、代理集、策略组信息修改完成,正在更新配置文件【$CONFIG_NAME】..." >$START_LOG
|
||||
#判断各个区位置
|
||||
proxy_len=$(sed -n '/^Proxy:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^proxy-provider:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
group_len=$(sed -n '/^ \{0,\}proxy-groups:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^proxy-providers:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
if [ "$provider_len" -le "$proxy_len" ]; then
|
||||
sed -i '/^ \{0,\}proxy-provider:/i\#change server#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Rule:/i\#change server end#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-provider:/,/#change server end#/d' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-providers:/i\#change server#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}rules:/i\#change server end#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-providers:/,/#change server end#/d' "$CONFIG_FILE" 2>/dev/null
|
||||
elif [ "$provider_len" -le "$group_len" ] && [ -z "$proxy_len" ]; then
|
||||
sed -i '/^ \{0,\}proxy-provider:/i\#change server#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Rule:/i\#change server end#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-provider:/,/#change server end#/d' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-providers:/i\#change server#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}rules:/i\#change server end#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-providers:/,/#change server end#/d' "$CONFIG_FILE" 2>/dev/null
|
||||
elif [ "$provider_len" -ge "$group_len" ] && [ -z "$proxy_len" ]; then
|
||||
sed -i '/^ \{0,\}Proxy Group:/i\#change server#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Rule:/i\#change server end#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Proxy Group:/,/#change server end#/d' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-groups:/i\#change server#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}rules:/i\#change server end#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}proxy-groups:/,/#change server end#/d' "$CONFIG_FILE" 2>/dev/null
|
||||
else
|
||||
sed -i '/^ \{0,\}Proxy:/i\#change server#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Rule:/i\#change server end#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}rules:/i\#change server end#' "$CONFIG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}Proxy:/,/#change server end#/d' "$CONFIG_FILE" 2>/dev/null
|
||||
fi
|
||||
|
||||
|
||||
@ -129,44 +129,44 @@ if [ "$2" != 0 ]; then
|
||||
|
||||
if [ "$check_def" -eq 1 ]; then
|
||||
if [ "$2" = "lhie1" ]; then
|
||||
sed -i '/^Rule:/,$d' "$4"
|
||||
sed -i '/^rules:/,$d' "$4"
|
||||
cat /etc/openclash/lhie1.yaml >> "$4"
|
||||
sed -i -e "s/,GlobalTV$/,${GlobalTV}#d/g" -e "/Rule:/a\##GlobalTV:${GlobalTV}"\
|
||||
-e "s/,AsianTV$/,${AsianTV}#d/g" -e "/Rule:/a\##AsianTV:${AsianTV}"\
|
||||
-e "s/,Proxy$/,${Proxy}#d/g" -e "/Rule:/a\##Proxy:${Proxy}"\
|
||||
sed -i -e "s/,GlobalTV$/,${GlobalTV}#d/g" -e "/rules:/a\##GlobalTV:${GlobalTV}"\
|
||||
-e "s/,AsianTV$/,${AsianTV}#d/g" -e "/rules:/a\##AsianTV:${AsianTV}"\
|
||||
-e "s/,Proxy$/,${Proxy}#d/g" -e "/rules:/a\##Proxy:${Proxy}"\
|
||||
-e "s/,Apple$/,${Apple}#d/g"\
|
||||
-e "s/,Apple,no-resolve$/,${Apple},no-resolve#d/g" -e "/Rule:/a\##Apple:${Apple}"\
|
||||
-e "s/,Netflix$/,${Netflix}#d/g" -e "/Rule:/a\##Netflix:${Netflix}"\
|
||||
-e "s/,Spotify$/,${Spotify}#d/g" -e "/Rule:/a\##Spotify:${Spotify}"\
|
||||
-e "s/,Steam$/,${Steam}#d/g" -e "/Rule:/a\##Steam:${Steam}"\
|
||||
-e "s/,AdBlock$/,${AdBlock}#d/g" -e "/Rule:/a\##AdBlock:${AdBlock}"\
|
||||
-e "s/,Netease Music$/,${Netease_Music}#d/g" -e "/Rule:/a\##Netease_Music:${Netease_Music}"\
|
||||
-e "s/,Speedtest$/,${Speedtest}#d/g" -e "/Rule:/a\##Speedtest:${Speedtest}"\
|
||||
-e "s/,Telegram$/,${Telegram}#d/g" -e "/Rule:/a\##Telegram:${Telegram}"\
|
||||
-e "s/,Microsoft$/,${Microsoft}#d/g" -e "/Rule:/a\##Microsoft:${Microsoft}"\
|
||||
-e "s/,PayPal$/,${PayPal}#d/g" -e "/Rule:/a\##PayPal:${PayPal}"\
|
||||
-e "s/,Domestic$/,${Domestic}#d/g" -e "/Rule:/a\##Domestic:${Domestic}"\
|
||||
-e "s/,Others$/,${Others}#d/g" -e "/Rule:/a\##Others:${Others}"\
|
||||
-e "s/,Apple,no-resolve$/,${Apple},no-resolve#d/g" -e "/rules:/a\##Apple:${Apple}"\
|
||||
-e "s/,Netflix$/,${Netflix}#d/g" -e "/rules:/a\##Netflix:${Netflix}"\
|
||||
-e "s/,Spotify$/,${Spotify}#d/g" -e "/rules:/a\##Spotify:${Spotify}"\
|
||||
-e "s/,Steam$/,${Steam}#d/g" -e "/rules:/a\##Steam:${Steam}"\
|
||||
-e "s/,AdBlock$/,${AdBlock}#d/g" -e "/rules:/a\##AdBlock:${AdBlock}"\
|
||||
-e "s/,Netease Music$/,${Netease_Music}#d/g" -e "/rules:/a\##Netease_Music:${Netease_Music}"\
|
||||
-e "s/,Speedtest$/,${Speedtest}#d/g" -e "/rules:/a\##Speedtest:${Speedtest}"\
|
||||
-e "s/,Telegram$/,${Telegram}#d/g" -e "/rules:/a\##Telegram:${Telegram}"\
|
||||
-e "s/,Microsoft$/,${Microsoft}#d/g" -e "/rules:/a\##Microsoft:${Microsoft}"\
|
||||
-e "s/,PayPal$/,${PayPal}#d/g" -e "/rules:/a\##PayPal:${PayPal}"\
|
||||
-e "s/,Domestic$/,${Domestic}#d/g" -e "/rules:/a\##Domestic:${Domestic}"\
|
||||
-e "s/,Others$/,${Others}#d/g" -e "/rules:/a\##Others:${Others}"\
|
||||
-e "s/#d//g" "$4"
|
||||
elif [ "$2" = "ConnersHua" ]; then
|
||||
sed -i '/^Rule:/,$d' "$4"
|
||||
sed -i '/^rules:/,$d' "$4"
|
||||
cat /etc/openclash/ConnersHua.yaml >> "$4"
|
||||
sed -i -e "s/,GlobalMedia$/,${GlobalTV}#d/g"\
|
||||
-e "s/,GlobalMedia,no-resolve$/,${GlobalTV},no-resolve#d/g" -e "/Rule:/a\##GlobalTV:${GlobalTV}"\
|
||||
-e "s/,HKMTMedia$/,${AsianTV}#d/g" -e "/Rule:/a\##AsianTV:${AsianTV}"\
|
||||
-e "s/,GlobalMedia,no-resolve$/,${GlobalTV},no-resolve#d/g" -e "/rules:/a\##GlobalTV:${GlobalTV}"\
|
||||
-e "s/,HKMTMedia$/,${AsianTV}#d/g" -e "/rules:/a\##AsianTV:${AsianTV}"\
|
||||
-e "s/,PROXY$/,${Proxy}#d/g"\
|
||||
-e "s/,PROXY,no-resolve$/,${Proxy},no-resolve#d/g" -e "/Rule:/a\##Proxy:${Proxy}"\
|
||||
-e "s/,Apple$/,${Apple}#d/g" -e "/Rule:/a\##Apple:${Apple}"\
|
||||
-e "s/,PROXY,no-resolve$/,${Proxy},no-resolve#d/g" -e "/rules:/a\##Proxy:${Proxy}"\
|
||||
-e "s/,Apple$/,${Apple}#d/g" -e "/rules:/a\##Apple:${Apple}"\
|
||||
-e "s/,Hijacking,no-resolve$/,${AdBlock},no-resolve#d/g"\
|
||||
-e "s/,Hijacking$/,${AdBlock}#d/g" -e "/Rule:/a\##AdBlock:${AdBlock}"\
|
||||
-e "s/,DIRECT$/,${Domestic}#d/g" -e "/Rule:/a\##Domestic:${Domestic}"\
|
||||
-e "s/,Final$/,${Others}#d/g" -e "/Rule:/a\##Others:${Others}"\
|
||||
-e "s/,Hijacking$/,${AdBlock}#d/g" -e "/rules:/a\##AdBlock:${AdBlock}"\
|
||||
-e "s/,DIRECT$/,${Domestic}#d/g" -e "/rules:/a\##Domestic:${Domestic}"\
|
||||
-e "s/,Final$/,${Others}#d/g" -e "/rules:/a\##Others:${Others}"\
|
||||
-e "s/#d//g" "$4"
|
||||
else
|
||||
sed -i '/^Rule:/,$d' "$4"
|
||||
sed -i '/^rules:/,$d' "$4"
|
||||
cat /etc/openclash/ConnersHua_return.yaml >> "$4"
|
||||
sed -i -e "s/,PROXY$/,${Proxy}#d/g" -e "/Rule:/a\##Proxy:${Proxy}"\
|
||||
-e "s/,DIRECT$/,${Others}#d/g" -e "/Rule:/a\##Others:${Others}"\
|
||||
sed -i -e "s/,PROXY$/,${Proxy}#d/g" -e "/rules:/a\##Proxy:${Proxy}"\
|
||||
-e "s/,DIRECT$/,${Others}#d/g" -e "/rules:/a\##Others:${Others}"\
|
||||
-e "s/#d//g" "$4"
|
||||
fi
|
||||
fi
|
||||
@ -176,8 +176,8 @@ elif [ "$2" = 0 ]; then
|
||||
grep '##source:' "$4" 1>/dev/null
|
||||
if [ "$?" -eq "0" ]; then
|
||||
cp "$8" /etc/openclash/configrules.bak
|
||||
sed -i -n '/^Rule:/,$p' /etc/openclash/configrules.bak
|
||||
sed -i '/^Rule:/,$d' "$4"
|
||||
sed -i -n '/^rules:/,$p' /etc/openclash/configrules.bak
|
||||
sed -i '/^rules:/,$d' "$4"
|
||||
cat /etc/openclash/configrules.bak >> "$4"
|
||||
rm -rf /etc/openclash/configrules.bak
|
||||
fi
|
||||
@ -226,8 +226,8 @@ fi
|
||||
fi
|
||||
|
||||
if [ "$3" = 1 ]; then
|
||||
sed -i '/^Rule:/a\##Custom Rules End##' "$4" 2>/dev/null
|
||||
sed -i '/^Rule:/a\##Custom Rules##' "$4" 2>/dev/null
|
||||
sed -i '/^rules:/a\##Custom Rules End##' "$4" 2>/dev/null
|
||||
sed -i '/^rules:/a\##Custom Rules##' "$4" 2>/dev/null
|
||||
sed -i '/^##Custom Rules##/r/etc/openclash/custom/openclash_custom_rules.list' "$4" 2>/dev/null
|
||||
sed -i '/^ \{0,\}- MATCH,/i\##Custom Rules 2##' "$4" 2>/dev/null\
|
||||
|| sed -i '/^ \{0,\}- FINAL,/i\##Custom Rules 2##' "$4" 2>/dev/null\
|
||||
|
||||
@ -131,6 +131,15 @@ msgstr "Global【全局代理(需前往控制面板手动指定节点)】"
|
||||
msgid "Direct Proxy Mode"
|
||||
msgstr "Direct【全局直连】"
|
||||
|
||||
msgid "Script Proxy Mode (Tun Core Only)"
|
||||
msgstr "Script【脚本模式 - 仅Tun内核】"
|
||||
|
||||
msgid "Select Stack Type"
|
||||
msgstr "网络栈类型"
|
||||
|
||||
msgid "Select Stack Type For Tun Mode, According To The Running Speed on Your Machine"
|
||||
msgstr "请自行根据运行速度为Tun模式选择合适的网络栈"
|
||||
|
||||
msgid "Log Level"
|
||||
msgstr "日志等级"
|
||||
|
||||
@ -234,9 +243,9 @@ msgid "(Communication protocol)"
|
||||
msgstr "(通讯协议)"
|
||||
|
||||
msgid "Enable ipv6 Resolve"
|
||||
msgstr "IPV6类型DNS解析"
|
||||
msgstr "允许IPV6类型DNS解析"
|
||||
|
||||
msgid "Force Enable to Resolve ipv6 DNS Requests"
|
||||
msgid "Enable Clash to Resolve ipv6 DNS Requests"
|
||||
msgstr ""
|
||||
"固件须配置好IPV6的NAT,如你不使用IPV6请关闭固件的相关服务,避免客户端连接出现异常"
|
||||
|
||||
@ -255,6 +264,9 @@ msgstr "上传文件类型"
|
||||
msgid "Proxy Provider File"
|
||||
msgstr "代理集文件"
|
||||
|
||||
msgid "Rule Provider File"
|
||||
msgstr "规则集文件"
|
||||
|
||||
msgid "Upload"
|
||||
msgstr "上传"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user