2 if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
3 shopt -s inherit_errexit
2>/dev
/null ||
: # ignore fail in bash < 4.4
5 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?. PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
7 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
11 # We block dns lookups from going outside the vpn network namespace,
12 # there might be some other workaround, but just resolving to static ips
16 while read -r host port
; do
18 echo $ip |
egrep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' &>/dev
/null ||
continue
19 printf "remote %s %s\n" "$ip" "$port" >>$conf
21 done < <(timeout
-s 9 1 dig +short
$host ||
:)
22 done < <(sed -rn 's/^ *# *remote //p' $conf)
27 sed --follow-symlinks -i '/^ *remote /d' $conf
30 # give it one retry if it failed initially
37 echo "vpn-static-ip: error: failed to set any ips" >&2