Skip to content

Commit afdfd64

Browse files
committed
slow dig backup
1 parent 5f2d18b commit afdfd64

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Homepage: https://github.com/ipitio/closure
44
Standards-Version: 3.9.2
55

66
Package: closure
7-
Version: 1.6.24
7+
Version: 1.6.25
88
Maintainer: ipitio <[email protected]>
99
Depends: curl, flatpak, gpg, hostapd, isc-dhcp-server, iw, macchanger, netplan.io, network-manager, net-tools, qrencode, rfkill, wireguard, wireless-tools, wget
1010
Recommends: containerd.io, docker-ce, docker-ce-cli, docker-buildx-plugin, docker-compose-plugin

lib.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ curl() {
220220
local result
221221

222222
while [ "$i" -lt "$max_attempts" ]; do
223-
result=$(command curl -sSLNZ --connect-timeout 60 -m 120 "$@" 2>/dev/null)
223+
result=$(command curl -sSLNZ --connect-timeout 60 -m 120 --retry 5 --retry-delay 1 --retry-all-errors "$@" 2>/dev/null)
224224
[ -n "$result" ] && echo "$result" && return 0
225225
sleep "$wait_time"
226226
((i++))
@@ -232,7 +232,7 @@ curl() {
232232
}
233233

234234
dig() {
235-
command dig +short "$1" 2>/dev/null | tail -n1
235+
[ -z "$2" ] && command dig +short "$1" 2>/dev/null | tail -n1 || command dig "$1" +trace 2>/dev/null | grep -oP "(?<=^${1//\./\\\.}\.).+(AAA)?A.+" | grep -oP '\S+$'
236236
}
237237

238238
direct_domain() {
@@ -248,7 +248,7 @@ get_server_ip() {
248248

249249
if ! is_ip "$server_ip"; then
250250
if [[ "$CLS_TYPE_NODE" =~ (spoke|saah) ]]; then
251-
server_ip=$(dig "$SERVERURL" | tail -n1)
251+
server_ip=$(dig "$SERVERURL" "$1" | tail -n1)
252252
else
253253
server_ip=$(direct_domain "curl https://icanhazip.com" | tail -n1)
254254
fi

start.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,16 @@ eval "cast pre-up ${*@Q}"
9393

9494
until ip a show "$CLS_INTERN_IFACE" | grep -q UP && ([[ ! "$CLS_TYPE_NODE" =~ spoke ]] || ping -c1 "$CLS_WG_SERVER" >/dev/null); do
9595
get_local_ip
96-
new_ip=$(get_server_ip)
97-
! is_ip "$new_ip" || og_server_ip="$new_ip"
96+
new_ip=$(get_server_ip 1)
97+
98+
if is_ip "$new_ip"; then
99+
if is_ip "$og_server_ip"; then
100+
[ "$og_server_ip" = "$new_ip" ] || exec sudo CLS_WG_ONLY=true bash restart.sh ${@@Q}
101+
else
102+
og_server_ip="$new_ip"
103+
fi
104+
fi
105+
98106
sleep 1
99107
done
100108

0 commit comments

Comments
 (0)