Skip to content

Commit 26683f6

Browse files
committed
wg-quick: wait on process substitutions
Bash does not propagate error values, which is a bummer, but process substitutions are a useful feature. Introduce a new idiom to deal with this: either "; wait $!" after the line to propagate the error, or "|| true" to indicate explicitly that we don't care about the error. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 13fac76 commit 26683f6

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

src/wg-quick/darwin.bash

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ detect_launchd() {
9292
LAUNCHED_BY_LAUNCHD=1
9393
break
9494
fi
95-
done < <(launchctl procinfo $$ 2>/dev/null)
95+
done < <(launchctl procinfo $$ 2>/dev/null); wait $!
9696
}
9797

9898
read_bool() {
@@ -132,14 +132,14 @@ del_routes() {
132132
local todelete=( ) destination gateway netif
133133
while read -r destination _ _ _ _ netif _; do
134134
[[ $netif == "$REAL_INTERFACE" ]] && todelete+=( "$destination" )
135-
done < <(netstat -nr -f inet)
135+
done < <(netstat -nr -f inet); wait $!
136136
for destination in "${todelete[@]}"; do
137137
cmd route -q -n delete -inet "$destination" >/dev/null || true
138138
done
139139
todelete=( )
140140
while read -r destination gateway _ netif; do
141141
[[ $netif == "$REAL_INTERFACE" || ( $netif == lo* && $gateway == "$REAL_INTERFACE" ) ]] && todelete+=( "$destination" )
142-
done < <(netstat -nr -f inet6)
142+
done < <(netstat -nr -f inet6); wait $!
143143
for destination in "${todelete[@]}"; do
144144
cmd route -q -n delete -inet6 "$destination" >/dev/null || true
145145
done
@@ -181,7 +181,7 @@ set_mtu() {
181181
defaultif="$netif"
182182
break
183183
fi
184-
done < <(netstat -nr -f inet)
184+
done < <(netstat -nr -f inet); wait $!
185185
[[ -n $defaultif && $(ifconfig "$defaultif") =~ mtu\ ([0-9]+) ]] && mtu="${BASH_REMATCH[1]}"
186186
[[ $mtu -gt 0 ]] || mtu=1500
187187
mtu=$(( mtu - 80 ))
@@ -197,22 +197,22 @@ collect_gateways() {
197197
[[ $destination == default ]] || continue
198198
GATEWAY4="$gateway"
199199
break
200-
done < <(netstat -nr -f inet)
200+
done < <(netstat -nr -f inet); wait $!
201201

202202
GATEWAY6=""
203203
while read -r destination gateway _; do
204204
[[ $destination == default ]] || continue
205205
GATEWAY6="$gateway"
206206
break
207-
done < <(netstat -nr -f inet6)
207+
done < <(netstat -nr -f inet6); wait $!
208208
}
209209

210210
collect_endpoints() {
211211
ENDPOINTS=( )
212212
while read -r _ endpoint; do
213213
[[ $endpoint =~ ^\[?([a-z0-9:.]+)\]?:[0-9]+$ ]] || continue
214214
ENDPOINTS+=( "${BASH_REMATCH[1]}" )
215-
done < <(wg show "$REAL_INTERFACE" endpoints)
215+
done < <(wg show "$REAL_INTERFACE" endpoints); wait $!
216216
}
217217

218218
declare -A SERVICE_DNS
@@ -230,7 +230,7 @@ collect_new_service_dns() {
230230
get_response="$(cmd networksetup -getsearchdomains "$service")"
231231
[[ $get_response == *" "* ]] && get_response="Empty"
232232
[[ -n $get_response ]] && SERVICE_DNS_SEARCH["$service"]="$get_response"
233-
done; } < <(networksetup -listallnetworkservices)
233+
done; } < <(networksetup -listallnetworkservices); wait $!
234234

235235
for service in "${!SERVICE_DNS[@]}"; do
236236
if ! [[ -n ${found_services["$service"]} ]]; then
@@ -304,7 +304,7 @@ set_dns() {
304304
else
305305
cmd networksetup -setsearchdomains "$service" "${DNS_SEARCH[@]}"
306306
fi
307-
)
307+
); wait $!
308308
done
309309
}
310310

@@ -316,7 +316,7 @@ del_dns() {
316316
done < <(
317317
cmd networksetup -setdnsservers "$service" ${SERVICE_DNS["$service"]} || true
318318
cmd networksetup -setsearchdomains "$service" ${SERVICE_DNS_SEARCH["$service"]} || true
319-
)
319+
); wait $!
320320
done
321321
}
322322

@@ -339,7 +339,7 @@ monitor_daemon() {
339339
set_dns
340340
sleep 2 && kill -ALRM $pid 2>/dev/null &
341341
fi
342-
done < <(route -n monitor)) &
342+
done < <(route -n monitor); wait $!) &
343343
[[ -n $LAUNCHED_BY_LAUNCHD ]] || disown
344344
}
345345

@@ -367,15 +367,15 @@ add_route() {
367367
}
368368

369369
set_config() {
370-
cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
370+
cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG"); wait $!
371371
}
372372

373373
save_config() {
374374
local old_umask new_config current_config address cmd
375375
new_config=$'[Interface]\n'
376376
while read -r address; do
377377
[[ $address =~ inet6?\ ([^ ]+) ]] && new_config+="Address = ${BASH_REMATCH[1]}"$'\n'
378-
done < <(ifconfig "$REAL_INTERFACE")
378+
done < <(ifconfig "$REAL_INTERFACE"); wait $!
379379
# TODO: actually determine current DNS for interface
380380
for address in "${DNS[@]}"; do
381381
new_config+="DNS = $address"$'\n'
@@ -458,7 +458,7 @@ cmd_up() {
458458
done
459459
set_mtu
460460
up_if
461-
for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$REAL_INTERFACE" allowed-ips) | sort -nr -k 2 -t /); do
461+
for i in $({ while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$REAL_INTERFACE" allowed-ips); wait $!; } | sort -nr -k 2 -t /); do
462462
add_route "$i"
463463
done
464464
[[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route

src/wg-quick/freebsd.bash

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ del_routes() {
121121
local todelete=( ) destination gateway netif
122122
while read -r destination _ _ _ _ netif _; do
123123
[[ $netif == "$INTERFACE" ]] && todelete+=( "$destination" )
124-
done < <(netstat -nr -f inet)
124+
done < <(netstat -nr -f inet); wait $!
125125
for destination in "${todelete[@]}"; do
126126
cmd route -q -n delete -inet "$destination" || true
127127
done
128128
todelete=( )
129129
while read -r destination gateway _ netif; do
130130
[[ $netif == "$INTERFACE" || ( $netif == lo* && $gateway == "$INTERFACE" ) ]] && todelete+=( "$destination" )
131-
done < <(netstat -nr -f inet6)
131+
done < <(netstat -nr -f inet6); wait $!
132132
for destination in "${todelete[@]}"; do
133133
cmd route -q -n delete -inet6 "$destination" || true
134134
done
@@ -191,9 +191,9 @@ set_mtu() {
191191
[[ ${BASH_REMATCH[1]} == *:* ]] && family=inet6
192192
output="$(route -n get "-$family" "${BASH_REMATCH[1]}" || true)"
193193
[[ $output =~ interface:\ ([^ ]+)$'\n' && $(ifconfig "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
194-
done < <(wg show "$INTERFACE" endpoints)
194+
done < <(wg show "$INTERFACE" endpoints); wait $!
195195
if [[ $mtu -eq 0 ]]; then
196-
read -r output < <(route -n get default || true) || true
196+
read -r output < <(route -n get default) || true
197197
[[ $output =~ interface:\ ([^ ]+)$'\n' && $(ifconfig "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
198198
fi
199199
[[ $mtu -gt 0 ]] || mtu=1500
@@ -209,22 +209,22 @@ collect_gateways() {
209209
[[ $destination == default ]] || continue
210210
GATEWAY4="$gateway"
211211
break
212-
done < <(netstat -nr -f inet)
212+
done < <(netstat -nr -f inet); wait $!
213213

214214
GATEWAY6=""
215215
while read -r destination gateway _; do
216216
[[ $destination == default ]] || continue
217217
GATEWAY6="$gateway"
218218
break
219-
done < <(netstat -nr -f inet6)
219+
done < <(netstat -nr -f inet6); wait $!
220220
}
221221

222222
collect_endpoints() {
223223
ENDPOINTS=( )
224224
while read -r _ endpoint; do
225225
[[ $endpoint =~ ^\[?([a-z0-9:.]+)\]?:[0-9]+$ ]] || continue
226226
ENDPOINTS+=( "${BASH_REMATCH[1]}" )
227-
done < <(wg show "$INTERFACE" endpoints)
227+
done < <(wg show "$INTERFACE" endpoints); wait $!
228228
}
229229

230230
set_endpoint_direct_route() {
@@ -294,7 +294,7 @@ monitor_daemon() {
294294
if_exists || break
295295
[[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route
296296
# TODO: set the mtu as well, but only if up
297-
done < <(route -n monitor)) & disown
297+
done < <(route -n monitor); wait $!) & disown
298298
}
299299

300300
HAVE_SET_DNS=0
@@ -335,21 +335,21 @@ add_route() {
335335
}
336336

337337
set_config() {
338-
cmd wg setconf "$INTERFACE" <(echo "$WG_CONFIG")
338+
cmd wg setconf "$INTERFACE" <(echo "$WG_CONFIG"); wait $!
339339
}
340340

341341
save_config() {
342342
local old_umask new_config current_config address cmd
343343
new_config=$'[Interface]\n'
344344
{ read -r _; while read -r _ _ _ address _; do
345345
new_config+="Address = $address"$'\n'
346-
done } < <(netstat -I "$INTERFACE" -n -W -f inet)
346+
done } < <(netstat -I "$INTERFACE" -n -W -f inet); wait $!
347347
{ read -r _; while read -r _ _ _ address _; do
348348
new_config+="Address = $address"$'\n'
349-
done } < <(netstat -I "$INTERFACE" -n -W -f inet6)
349+
done } < <(netstat -I "$INTERFACE" -n -W -f inet6); wait $!
350350
while read -r address; do
351351
[[ $address =~ ^nameserver\ ([a-zA-Z0-9_=+:%.-]+)$ ]] && new_config+="DNS = ${BASH_REMATCH[1]}"$'\n'
352-
done < <(resolvconf -l "$INTERFACE" 2>/dev/null)
352+
done < <(resolvconf -l "$INTERFACE" 2>/dev/null); wait $!
353353
[[ -n $MTU ]] && new_config+="MTU = $MTU"$'\n'
354354
[[ -n $TABLE ]] && new_config+="Table = $TABLE"$'\n'
355355
[[ $SAVE_CONFIG -eq 0 ]] || new_config+=$'SaveConfig = true\n'
@@ -427,7 +427,7 @@ cmd_up() {
427427
set_mtu
428428
up_if
429429
set_dns
430-
for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$INTERFACE" allowed-ips) | sort -nr -k 2 -t /); do
430+
for i in $({ while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$INTERFACE" allowed-ips); wait $!; } | sort -nr -k 2 -t /); do
431431
add_route "$i"
432432
done
433433
[[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route

src/wg-quick/linux.bash

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ set_mtu_up() {
132132
[[ $endpoint =~ ^\[?([a-z0-9:.]+)\]?:[0-9]+$ ]] || continue
133133
output="$(ip route get "${BASH_REMATCH[1]}" || true)"
134134
[[ ( $output =~ mtu\ ([0-9]+) || ( $output =~ dev\ ([^ ]+) && $(ip link show dev "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) ) ) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
135-
done < <(wg show "$INTERFACE" endpoints)
135+
done < <(wg show "$INTERFACE" endpoints); wait $!
136136
if [[ $mtu -eq 0 ]]; then
137-
read -r output < <(ip route show default || true) || true
137+
read -r output < <(ip route show default) || true
138138
[[ ( $output =~ mtu\ ([0-9]+) || ( $output =~ dev\ ([^ ]+) && $(ip link show dev "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) ) ) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
139139
fi
140140
[[ $mtu -gt 0 ]] || mtu=1500
@@ -191,8 +191,8 @@ remove_firewall() {
191191
local table nftcmd
192192
while read -r table; do
193193
[[ $table == *" wg-quick-$INTERFACE" ]] && printf -v nftcmd '%sdelete %s\n' "$nftcmd" "$table"
194-
done < <(nft list tables 2>/dev/null)
195-
[[ -z $nftcmd ]] || cmd nft -f <(echo -n "$nftcmd")
194+
done < <(nft list tables 2>/dev/null) || true
195+
[[ -z $nftcmd ]] || cmd nft -f <(echo -n "$nftcmd"); wait $!
196196
fi
197197
if type -p iptables >/dev/null; then
198198
local line iptables found restore
@@ -202,7 +202,7 @@ remove_firewall() {
202202
[[ $line == "*"* || $line == COMMIT || $line == "-A "*"-m comment --comment \"wg-quick(8) rule for $INTERFACE\""* ]] || continue
203203
[[ $line == "-A"* ]] && found=1
204204
printf -v restore '%s%s\n' "$restore" "${line/#-A/-D}"
205-
done < <($iptables-save 2>/dev/null)
205+
done < <($iptables-save 2>/dev/null) || true
206206
[[ $found -ne 1 ]] || echo -n "$restore" | cmd $iptables-restore -n
207207
done
208208
fi
@@ -233,22 +233,22 @@ add_default() {
233233
[[ $line =~ .*inet6?\ ([0-9a-f:.]+)/[0-9]+.* ]] || continue
234234
printf -v restore '%s-I PREROUTING ! -i %s -d %s -m addrtype ! --src-type LOCAL -j DROP %s\n' "$restore" "$INTERFACE" "${BASH_REMATCH[1]}" "$marker"
235235
printf -v nftcmd '%sadd rule %s %s preraw iifname != "%s" %s daddr %s fib saddr type != local drop\n' "$nftcmd" "$pf" "$nftable" "$INTERFACE" "$pf" "${BASH_REMATCH[1]}"
236-
done < <(ip -o $proto addr show dev "$INTERFACE" 2>/dev/null)
236+
done < <(ip -o $proto addr show dev "$INTERFACE"); wait $!
237237
printf -v restore '%sCOMMIT\n*mangle\n-I POSTROUTING -m mark --mark %d -p udp -j CONNMARK --save-mark %s\n-I PREROUTING -p udp -j CONNMARK --restore-mark %s\nCOMMIT\n' "$restore" $table "$marker" "$marker"
238238
printf -v nftcmd '%sadd rule %s %s postmangle meta l4proto udp mark %d ct mark set mark \n' "$nftcmd" "$pf" "$nftable" $table
239239
printf -v nftcmd '%sadd rule %s %s premangle meta l4proto udp meta mark set ct mark \n' "$nftcmd" "$pf" "$nftable"
240240
[[ $proto == -4 ]] && cmd sysctl -q net.ipv4.conf.all.src_valid_mark=1
241241
if type -p nft >/dev/null; then
242-
cmd nft -f <(echo -n "$nftcmd")
242+
cmd nft -f <(echo -n "$nftcmd"); wait $!
243243
else
244-
echo -n "$restore" | cmd $iptables-restore -n
244+
echo -n "$restore" | cmd $iptables-restore -n; wait $!
245245
fi
246246
HAVE_SET_FIREWALL=1
247247
return 0
248248
}
249249

250250
set_config() {
251-
cmd wg setconf "$INTERFACE" <(echo "$WG_CONFIG")
251+
cmd wg setconf "$INTERFACE" <(echo "$WG_CONFIG"); wait $!
252252
}
253253

254254
save_config() {
@@ -260,7 +260,7 @@ save_config() {
260260
done
261261
while read -r address; do
262262
[[ $address =~ ^nameserver\ ([a-zA-Z0-9_=+:%.-]+)$ ]] && new_config+="DNS = ${BASH_REMATCH[1]}"$'\n'
263-
done < <(resolvconf -l "$(resolvconf_iface_prefix)$INTERFACE" 2>/dev/null || cat "/etc/resolvconf/run/interface/$(resolvconf_iface_prefix)$INTERFACE" 2>/dev/null)
263+
done < <(resolvconf -l "$(resolvconf_iface_prefix)$INTERFACE" 2>/dev/null || cat "/etc/resolvconf/run/interface/$(resolvconf_iface_prefix)$INTERFACE" 2>/dev/null) || true
264264
[[ -n $MTU && $(ip link show dev "$INTERFACE") =~ mtu\ ([0-9]+) ]] && new_config+="MTU = ${BASH_REMATCH[1]}"$'\n'
265265
[[ -n $TABLE ]] && new_config+="Table = $TABLE"$'\n'
266266
[[ $SAVE_CONFIG -eq 0 ]] || new_config+=$'SaveConfig = true\n'
@@ -335,7 +335,7 @@ cmd_up() {
335335
done
336336
set_mtu_up
337337
set_dns
338-
for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$INTERFACE" allowed-ips) | sort -nr -k 2 -t /); do
338+
for i in $({ while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$INTERFACE" allowed-ips); wait $!; } | sort -nr -k 2 -t /); do
339339
add_route "$i"
340340
done
341341
execute_hooks "${POST_UP[@]}"

src/wg-quick/openbsd.bash

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ del_routes() {
131131
[[ -n $REAL_INTERFACE ]] || return 0
132132
while read -r destination _ _ _ _ netif _; do
133133
[[ $netif == "$REAL_INTERFACE" ]] && todelete+=( "$destination" )
134-
done < <(netstat -nr -f inet)
134+
done < <(netstat -nr -f inet); wait $!
135135
for destination in "${todelete[@]}"; do
136136
cmd route -q -n delete -inet "$destination" || true
137137
done
138138
todelete=( )
139139
while read -r destination gateway _ netif; do
140140
[[ $netif == "$REAL_INTERFACE" || ( $netif == lo* && $gateway == "$REAL_INTERFACE" ) ]] && todelete+=( "$destination" )
141-
done < <(netstat -nr -f inet6)
141+
done < <(netstat -nr -f inet6); wait $!
142142
for destination in "${todelete[@]}"; do
143143
cmd route -q -n delete -inet6 "$destination" || true
144144
done
@@ -189,9 +189,9 @@ set_mtu() {
189189
[[ ${BASH_REMATCH[1]} == *:* ]] && family=inet6
190190
output="$(route -n get "-$family" "${BASH_REMATCH[1]}" || true)"
191191
[[ $output =~ interface:\ ([^ ]+)$'\n' && $(ifconfig "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
192-
done < <(wg show "$REAL_INTERFACE" endpoints)
192+
done < <(wg show "$REAL_INTERFACE" endpoints); wait $!
193193
if [[ $mtu -eq 0 ]]; then
194-
read -r output < <(route -n get default || true) || true
194+
read -r output < <(route -n get default) || true
195195
[[ $output =~ interface:\ ([^ ]+)$'\n' && $(ifconfig "${BASH_REMATCH[1]}") =~ mtu\ ([0-9]+) && ${BASH_REMATCH[1]} -gt $mtu ]] && mtu="${BASH_REMATCH[1]}"
196196
fi
197197
[[ $mtu -gt 0 ]] || mtu=1500
@@ -207,22 +207,22 @@ collect_gateways() {
207207
[[ $destination == default ]] || continue
208208
GATEWAY4="$gateway"
209209
break
210-
done < <(netstat -nr -f inet)
210+
done < <(netstat -nr -f inet); wait $!
211211

212212
GATEWAY6=""
213213
while read -r destination gateway _; do
214214
[[ $destination == default ]] || continue
215215
GATEWAY6="$gateway"
216216
break
217-
done < <(netstat -nr -f inet6)
217+
done < <(netstat -nr -f inet6); wait $!
218218
}
219219

220220
collect_endpoints() {
221221
ENDPOINTS=( )
222222
while read -r _ endpoint; do
223223
[[ $endpoint =~ ^\[?([a-z0-9:.]+)\]?:[0-9]+$ ]] || continue
224224
ENDPOINTS+=( "${BASH_REMATCH[1]}" )
225-
done < <(wg show "$REAL_INTERFACE" endpoints)
225+
done < <(wg show "$REAL_INTERFACE" endpoints); wait $!
226226
}
227227

228228
set_endpoint_direct_route() {
@@ -290,7 +290,7 @@ monitor_daemon() {
290290
ifconfig "$REAL_INTERFACE" >/dev/null 2>&1 || break
291291
[[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route
292292
# TODO: set the mtu as well, but only if up
293-
done < <(route -n monitor)) & disown
293+
done < <(route -n monitor); wait $!) & disown
294294
}
295295

296296
set_dns() {
@@ -339,15 +339,15 @@ add_route() {
339339
}
340340

341341
set_config() {
342-
cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG")
342+
cmd wg setconf "$REAL_INTERFACE" <(echo "$WG_CONFIG"); wait $!
343343
}
344344

345345
save_config() {
346346
local old_umask new_config current_config address network cmd
347347
new_config=$'[Interface]\n'
348348
{ read -r _; while read -r _ _ network address _; do
349349
[[ $network == *Link* ]] || new_config+="Address = $address"$'\n'
350-
done } < <(netstat -I "$REAL_INTERFACE" -n -v)
350+
done } < <(netstat -I "$REAL_INTERFACE" -n -v); wait $!
351351
# TODO: actually determine current DNS for interface
352352
for address in "${DNS[@]}"; do
353353
new_config+="DNS = $address"$'\n'
@@ -428,7 +428,7 @@ cmd_up() {
428428
set_mtu
429429
up_if
430430
set_dns
431-
for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$REAL_INTERFACE" allowed-ips) | sort -nr -k 2 -t /); do
431+
for i in $({ while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$REAL_INTERFACE" allowed-ips); wait $!; } | sort -nr -k 2 -t /); do
432432
add_route "$i"
433433
done
434434
[[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route

0 commit comments

Comments
 (0)