|
@@ -45,14 +45,22 @@ old_server_ip6=$(yunohost app setting vpnclient server_ip6)
|
|
|
new_ip6_gw=$(ip -6 route | awk '/default via/ { print $3 }')
|
|
|
new_wired_device=$(ip route | awk '/default via/ { print $5; }')
|
|
|
ynh_server_names=$(grep -o -P '^\s*remote\s+\K([^\s]+)' /etc/openvpn/client.conf | sort | uniq)
|
|
|
-new_server_ip6=$(dig AAAA +short $ynh_server_names @127.0.0.1 | grep -v '\.$' | grep -v "timed out" | sort | uniq)
|
|
|
|
|
|
+# In case an ip has been provided in ovpn conf
|
|
|
+new_server_ip6=""
|
|
|
+new_server_ip4=""
|
|
|
for i in $ynh_server_names; do
|
|
|
- if [[ "${i}" =~ : ]] && [[ ! "$new_server_ip6" == *"${i}"* ]] ; then
|
|
|
+ if [[ "${i}" =~ : ]]; then
|
|
|
new_server_ip6+=" ${i}"
|
|
|
+ elif [[ "${i}" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
|
+ new_server_ip4+=" ${i}"
|
|
|
fi
|
|
|
done
|
|
|
|
|
|
+if [[ -z "${new_server_ip6}" && -z "${new_server_ip4}" ]]; then
|
|
|
+ new_server_ip6=$(dig AAAA +short $ynh_server_names @127.0.0.1 | grep -v '\.$' | grep -v "timed out" | sort | uniq)
|
|
|
+fi
|
|
|
+
|
|
|
echo "[INFO] Autodetected internet interface: ${new_wired_device} (last start: ${old_wired_device})"
|
|
|
echo "[INFO] Autodetected IPv6 address for the VPN server: ${new_server_ip6} (last start: ${old_server_ip6})"
|
|
|
|