mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-10 23:41:22 +00:00
~增加ecs优化功能
This commit is contained in:
17
scripts/libs/get_ecsip.sh
Normal file
17
scripts/libs/get_ecsip.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
get_ecs_address() {
|
||||
ip=$(uci get network.wan.dns 2>/dev/null)
|
||||
[ -n "$ip" ] && return
|
||||
for f in /tmp/resolv.conf.auto /tmp/resolv.conf /tmp/resolv.conf.d/resolv.conf.auto; do
|
||||
[ -f "$f" ] || continue
|
||||
ip=$(grep -A2 "^# Interface wan" "$f" | grep nameserver | awk '{printf "%s ", $2}')
|
||||
[ -n "$ip" ] && return
|
||||
done
|
||||
. "$CRASHDIR"/libs/web_get_lite.sh
|
||||
for web in http://members.3322.org/dyndns/getip http://4.ipw.cn http://ipinfo.io/ip; do
|
||||
ip=$(web_get_lite "$web" 0)
|
||||
[ -n "$ip" ] && return
|
||||
done
|
||||
}
|
||||
get_ecs_address
|
||||
[ -n "$ip" ] && ecs_address="${ip%.*}.0/24"
|
||||
@@ -1,7 +1,7 @@
|
||||
. "$CRASHDIR"/libs/set_proxy.sh
|
||||
#$1:目标地址 $2:json字符串
|
||||
#$1:目标地址 $2:禁用proxy
|
||||
web_get_lite() {
|
||||
setproxy
|
||||
[ -z "$2" ] && setproxy
|
||||
if curl --version >/dev/null 2>&1; then
|
||||
curl -ksSl --connect-timeout 3 "$1" 2>/dev/null
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user