mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-07-24 15:47:11 +00:00
原轮询 [ -n "$ip" ] 只判非空,members.3322.org 被限流返回 429 HTML 错误页时也判为成功 return,后续更可靠的源不会被尝试。 - 每个响应用 grep -oE 提取合法 IPv4,提取失败(HTML/空)则继续下一个 - 新增 http://ddns.oray.com/checkip 放首位(响应含 'Current IP Address:' 前缀,grep 提取末尾 IPv4),比 3322 免费 DDNS 更稳定 - 移除 http://4.ipw.cn(部分运营商 DNS 解析失败)
17 lines
701 B
Bash
17 lines
701 B
Bash
|
||
get_ecs_address() {
|
||
for f in /tmp/resolv.conf.auto /tmp/resolv.conf /tmp/resolv.conf.d/resolv.conf.auto; do
|
||
[ -f "$f" ] || continue
|
||
ip=$(grep -A1 "^# Interface wan$" "$f" | grep nameserver | awk '{printf "%s ", $2}')
|
||
[ -n "$ip" ] && return
|
||
done
|
||
. "$CRASHDIR"/libs/web_get_lite.sh
|
||
#轮询公网IP,提取并校验为合法IPv4才采用,否则继续尝试下一个
|
||
for web in http://ddns.oray.com/checkip http://members.3322.org/dyndns/getip http://ipinfo.io/ip; do
|
||
ip=$(web_get_lite "$web" 0 | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | tail -1)
|
||
[ -n "$ip" ] && return
|
||
done
|
||
}
|
||
get_ecs_address
|
||
[ -n "$ip" ] && ecs_address="${ip%.*}.0/24"
|