mirror of https://github.com/dadevel/wg-netns
parent
008833d7fc
commit
da967b34d3
@ -1,7 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if ! ping -q -c 1 -W "${WG_TIMEOUT:-5}" "$WG_GATEWAY"; then
|
||||
# dependencies: dig, ip, ping and wg
|
||||
|
||||
WG_ENDPOINT_DOMAIN="${WG_ENDPOINT%%:*}"
|
||||
WG_ENDPOINT_PORT="${WG_ENDPOINT##*:}"
|
||||
|
||||
if ! ip netns exec "$WG_NAMESPACE" ping -q -c 1 -W "${WG_TIMEOUT:-5}" "$WG_GATEWAY"; then
|
||||
echo 'probe failed, resolving endpoint'
|
||||
wg set "$WG_INTERFACE" peer "$WG_PEER" endpoint "$WG_ENDPOINT"
|
||||
ip netns exec "$WG_NAMESPACE" wg set "$WG_INTERFACE" peer "$WG_PEER" endpoint "$(dig +short "$WG_ENDPOINT_DOMAIN"):$WG_ENDPOINT_PORT"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue