fix: resolve failure to update server IP in sb -d

fix: 修复 sb -d 服务端 IP 修改失败的问题
This commit is contained in:
fscarmen
2026-06-25 09:55:07 +08:00
committed by GitHub
parent 6bb22b3562
commit 53ce0dc541
+1 -2
View File
@@ -860,13 +860,12 @@ change_config() {
[[ ! "$NEW_VAL" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] && [[ ! "$NEW_VAL" =~ ^[0-9a-fA-F:]+$ ]] && error " $(text 133) " [[ ! "$NEW_VAL" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] && [[ ! "$NEW_VAL" =~ ^[0-9a-fA-F:]+$ ]] && error " $(text 133) "
fi fi
# 批量替换,更换服务IP和指纹不需重启服务 # 批量替换,更换服务IP和指纹不需重启服务
[[ ! "$KEY" =~ ^(fingerprint|serverip|cdn)$ ]] && hint " $(text 112) " [[ ! "$KEY" =~ ^(fingerprint|serverip|cdn)$ ]] && hint " $(text 112) "
if [[ "$KEY" =~ ^(serverip|cdn)$ ]]; then if [[ "$KEY" =~ ^(serverip|cdn)$ ]]; then
# IP 在配置里出现的形式有多种,逐一替换 # IP 在配置里出现的形式有多种,逐一替换
find ${WORK_DIR} -type f | xargs -P 50 sed -i -e "s|\"server\": \"${OLD}\"|\"server\": \"${NEW_VAL}\"|g" 2>/dev/null find ${WORK_DIR} -type f | xargs -P 50 sed -i -e "s|\"server\": \"${OLD}\"|\"server\": \"${NEW_VAL}\"|g; s|\"WS_SERVER_IP_SHOW\": \"${OLD}\"|\"WS_SERVER_IP_SHOW\": \"${NEW_VAL}\"|g" 2>/dev/null
# 同时更新 subscribe/list 等文本文件中可能出现的裸 IP # 同时更新 subscribe/list 等文本文件中可能出现的裸 IP
find ${WORK_DIR}/subscribe -type f | xargs -P 50 sed -i "s|${OLD}|${NEW_VAL}|g" 2>/dev/null find ${WORK_DIR}/subscribe -type f | xargs -P 50 sed -i "s|${OLD}|${NEW_VAL}|g" 2>/dev/null