mirror of https://github.com/mack-a/v2ray-agent
feat(脚本): 优化订阅更新逻辑,当使用主节点查看订阅时会自动更新从节点
parent
6e7beaf80f
commit
476df4f840
51
install.sh
51
install.sh
|
@ -6926,6 +6926,7 @@ addSubscribeMenu() {
|
||||||
elif [[ "${addSubscribeStatus}" == "2" ]]; then
|
elif [[ "${addSubscribeStatus}" == "2" ]]; then
|
||||||
rm -rf /etc/v2ray-agent/subscribe_remote/clashMeta/*
|
rm -rf /etc/v2ray-agent/subscribe_remote/clashMeta/*
|
||||||
rm -rf /etc/v2ray-agent/subscribe_remote/default/*
|
rm -rf /etc/v2ray-agent/subscribe_remote/default/*
|
||||||
|
echo >/etc/v2ray-agent/subscribe_remote/remoteSubscribeUrl
|
||||||
echoContent green " ---> 其他机器订阅删除成功"
|
echoContent green " ---> 其他机器订阅删除成功"
|
||||||
subscribe
|
subscribe
|
||||||
fi
|
fi
|
||||||
|
@ -6942,6 +6943,7 @@ addOtherSubscribe() {
|
||||||
elif ! echo "${remoteSubscribeUrl}" | grep -q ":"; then
|
elif ! echo "${remoteSubscribeUrl}" | grep -q ":"; then
|
||||||
echoContent red " ---> 规则不合法"
|
echoContent red " ---> 规则不合法"
|
||||||
else
|
else
|
||||||
|
echo "${remoteSubscribeUrl}" >/etc/v2ray-agent/subscribe_remote/remoteSubscribeUrl
|
||||||
local remoteUrl=
|
local remoteUrl=
|
||||||
remoteUrl=$(echo "${remoteSubscribeUrl}" | awk -F "[:]" '{print $1":"$2}')
|
remoteUrl=$(echo "${remoteSubscribeUrl}" | awk -F "[:]" '{print $1":"$2}')
|
||||||
|
|
||||||
|
@ -7435,6 +7437,13 @@ subscribe() {
|
||||||
cat "/etc/v2ray-agent/subscribe_local/default/${email}" >>"/etc/v2ray-agent/subscribe/default/${emailMd5}"
|
cat "/etc/v2ray-agent/subscribe_local/default/${email}" >>"/etc/v2ray-agent/subscribe/default/${emailMd5}"
|
||||||
|
|
||||||
if [[ -f "/etc/v2ray-agent/subscribe_remote/default/${email}" ]]; then
|
if [[ -f "/etc/v2ray-agent/subscribe_remote/default/${email}" ]]; then
|
||||||
|
echo >"/etc/v2ray-agent/subscribe_remote/default/${email}_tmp"
|
||||||
|
while read -r remoteUrl; do
|
||||||
|
updateRemoteSubscribe "${emailMd5}" "${email}" "${remoteUrl}" "default"
|
||||||
|
done < <(grep "VLESS_TCP/TLS_Vision" <"/etc/v2ray-agent/subscribe_remote/default/${email}" | awk -F "@" '{print $2}' | awk -F "?" '{print $1}')
|
||||||
|
|
||||||
|
echo >"/etc/v2ray-agent/subscribe_remote/default/${email}"
|
||||||
|
cat "/etc/v2ray-agent/subscribe_remote/default/${email}_tmp" >"/etc/v2ray-agent/subscribe_remote/default/${email}"
|
||||||
cat "/etc/v2ray-agent/subscribe_remote/default/${email}" >>"/etc/v2ray-agent/subscribe/default/${emailMd5}"
|
cat "/etc/v2ray-agent/subscribe_remote/default/${email}" >>"/etc/v2ray-agent/subscribe/default/${emailMd5}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -7460,6 +7469,12 @@ subscribe() {
|
||||||
cat "/etc/v2ray-agent/subscribe_local/clashMeta/${email}" >>"/etc/v2ray-agent/subscribe/clashMeta/${emailMd5}"
|
cat "/etc/v2ray-agent/subscribe_local/clashMeta/${email}" >>"/etc/v2ray-agent/subscribe/clashMeta/${emailMd5}"
|
||||||
|
|
||||||
if [[ -f "/etc/v2ray-agent/subscribe_remote/clashMeta/${email}" ]]; then
|
if [[ -f "/etc/v2ray-agent/subscribe_remote/clashMeta/${email}" ]]; then
|
||||||
|
echo >"/etc/v2ray-agent/subscribe_remote/clashMeta/${email}_tmp"
|
||||||
|
while read -r remoteUrl; do
|
||||||
|
updateRemoteSubscribe "${emailMd5}" "${email}" "${remoteUrl}" "ClashMeta"
|
||||||
|
done < <(grep -A3 "VLESS_TCP/TLS_Vision" <"/etc/v2ray-agent/subscribe_remote/clashMeta/${email}" | awk '/server:|port:/ {print $2}' | paste -d ':' - -)
|
||||||
|
echo >"/etc/v2ray-agent/subscribe_remote/clashMeta/${email}"
|
||||||
|
cat "/etc/v2ray-agent/subscribe_remote/clashMeta/${email}_tmp" >"/etc/v2ray-agent/subscribe_remote/clashMeta/${email}"
|
||||||
cat "/etc/v2ray-agent/subscribe_remote/clashMeta/${email}" >>"/etc/v2ray-agent/subscribe/clashMeta/${emailMd5}"
|
cat "/etc/v2ray-agent/subscribe_remote/clashMeta/${email}" >>"/etc/v2ray-agent/subscribe/clashMeta/${emailMd5}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -7481,6 +7496,40 @@ subscribe() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 更新远程订阅
|
||||||
|
updateRemoteSubscribe() {
|
||||||
|
local emailMD5=$1
|
||||||
|
local email=$2
|
||||||
|
local remoteUrl=$3
|
||||||
|
local type=$4
|
||||||
|
local remoteDomain=
|
||||||
|
remoteDomain=$(echo "${remoteUrl}" | awk -F ":" '{print $1}')
|
||||||
|
local serverAlias=
|
||||||
|
serverAlias=$(grep "${remoteDomain}" <"/etc/v2ray-agent/subscribe_remote/remoteSubscribeUrl" | awk -F ":" '{print $3}')
|
||||||
|
|
||||||
|
if [[ "${type}" == "ClashMeta" ]]; then
|
||||||
|
local clashMetaProxies=
|
||||||
|
clashMetaProxies=$(curl -s -4 "https://${remoteUrl}/s/clashMeta/${emailMD5}" | sed '/proxies:/d' | sed "s/${email}/${email}_${serverAlias}/g")
|
||||||
|
if echo "${clashMetaProxies}" | grep -q "${email}"; then
|
||||||
|
echo "${clashMetaProxies}" >>"/etc/v2ray-agent/subscribe_remote/clashMeta/${email}_tmp"
|
||||||
|
|
||||||
|
echoContent green " ---> clashMeta订阅 ${remoteDomain}:${email} 更新成功"
|
||||||
|
else
|
||||||
|
echoContent red " ---> clashMeta订阅 ${remoteDomain}:${email}不存在"
|
||||||
|
fi
|
||||||
|
elif [[ "${type}" == "default" ]]; then
|
||||||
|
local default=
|
||||||
|
default=$(curl -s -4 "https://${remoteUrl}/s/default/${emailMD5}" | base64 -d | sed "s/${email}/${email}_${serverAlias}/g")
|
||||||
|
if echo "${default}" | grep -q "${email}"; then
|
||||||
|
echo "${default}" >>"/etc/v2ray-agent/subscribe_remote/default/${email}_tmp"
|
||||||
|
|
||||||
|
echoContent green " ---> 通用订阅 ${remoteDomain}:${email} 更新成功"
|
||||||
|
else
|
||||||
|
echoContent red " ---> 通用订阅 ${remoteDomain}:${email} 不存在"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# 切换alpn
|
# 切换alpn
|
||||||
switchAlpn() {
|
switchAlpn() {
|
||||||
echoContent skyBlue "\n功能 1/${totalProgress} : 切换alpn"
|
echoContent skyBlue "\n功能 1/${totalProgress} : 切换alpn"
|
||||||
|
@ -7821,7 +7870,7 @@ menu() {
|
||||||
cd "$HOME" || exit
|
cd "$HOME" || exit
|
||||||
echoContent red "\n=============================================================="
|
echoContent red "\n=============================================================="
|
||||||
echoContent green "作者:mack-a"
|
echoContent green "作者:mack-a"
|
||||||
echoContent green "当前版本:v2.10.1"
|
echoContent green "当前版本:v2.10.2"
|
||||||
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
|
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
|
||||||
echoContent green "描述:八合一共存脚本\c"
|
echoContent green "描述:八合一共存脚本\c"
|
||||||
showInstallStatus
|
showInstallStatus
|
||||||
|
|
Loading…
Reference in New Issue