add an option to use two option for detect public IP

This commit is contained in:
Mohammad Parvin 2022-10-20 23:37:03 +03:00
parent 908bffdb5b
commit 8d84eebd79

View File

@ -227,8 +227,14 @@ function installQuestions() {
echo "I need to know the IPv4 address of the network interface you want OpenVPN listening to." echo "I need to know the IPv4 address of the network interface you want OpenVPN listening to."
echo "Unless your server is behind NAT, it should be your public IPv4 address." echo "Unless your server is behind NAT, it should be your public IPv4 address."
# Detect public IPv4 address and pre-fill for the user # If detect_from_net is not set detect the IP from the network
IP=$(ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$|\1|p' | head -1) # Else use this command to detect ip: curl -s https://api.ipify.org
if [[ -z $DETECT_FROM_NET ]]; then
# Detect public IPv4 address and pre-fill for the user
IP=$(ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$|\1|p' | head -1)
else
IP=$(curl -s https://api.ipify.org)
fi
if [[ -z $IP ]]; then if [[ -z $IP ]]; then
# Detect public IPv6 address # Detect public IPv6 address