mirror of
https://github.com/angristan/openvpn-install.git
synced 2025-05-09 18:28:23 +02:00
Fix Public IP detection
This commit is contained in:
parent
2ce1ee765e
commit
d7cba3c2dc
@ -625,16 +625,40 @@ function installOpenVPN() {
|
|||||||
PASS=${PASS:-1}
|
PASS=${PASS:-1}
|
||||||
CONTINUE=${CONTINUE:-y}
|
CONTINUE=${CONTINUE:-y}
|
||||||
|
|
||||||
|
if [[ -z $ENDPOINT ]]; then
|
||||||
|
|
||||||
|
# IP version flags, we'll use as default the IPv4
|
||||||
|
CURL_IP_VERSION_FLAG="-4"
|
||||||
|
DIG_IP_VERSION_FLAG="-4"
|
||||||
|
|
||||||
# Behind NAT, we'll default to the publicly reachable IPv4/IPv6.
|
# Behind NAT, we'll default to the publicly reachable IPv4/IPv6.
|
||||||
if [[ $IPV6_SUPPORT == "y" ]]; then
|
if [[ $IPV6_SUPPORT == "y" ]]; then
|
||||||
if ! PUBLIC_IP=$(curl -f --retry 5 --retry-connrefused https://ip.seeip.org); then
|
CURL_IP_VERSION_FLAG=""
|
||||||
PUBLIC_IP=$(dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"')
|
DIG_IP_VERSION_FLAG="-6"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
if ! PUBLIC_IP=$(curl -f --retry 5 --retry-connrefused -4 https://ip.seeip.org); then
|
# If there is no public ip yet, we'll try to solve it using: https://ip.seeip.org
|
||||||
PUBLIC_IP=$(dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"')
|
if [[ -z $PUBLIC_IP ]]; then
|
||||||
|
PUBLIC_IP=$(curl -f -m 5 -sS --retry 5 --retry-connrefused $CURL_IP_VERSION_FLAG https://ip.seeip.org 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If there is no public ip yet, we'll try to solve it using: https://ifconfig.me
|
||||||
|
if [[ -z $PUBLIC_IP ]]; then
|
||||||
|
PUBLIC_IP=$(curl -f -m 5 -sS --retry 5 --retry-connrefused $CURL_IP_VERSION_FLAG https://ifconfig.me 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If there is no public ip yet, we'll try to solve it using: https://api.ipify.org
|
||||||
|
if [[ -z $PUBLIC_IP ]]; then
|
||||||
|
PUBLIC_IP=$(curl -f -m 5 -sS --retry 5 --retry-connrefused $CURL_IP_VERSION_FLAG https://api.ipify.org 2>/dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If there is no public ip yet, we'll try to solve it using: ns1.google.com
|
||||||
|
if [[ -z $PUBLIC_IP ]]; then
|
||||||
|
PUBLIC_IP=$(dig $DIG_IP_VERSION_FLAG TXT +short o-o.myaddr.l.google.com @ns1.google.com | tr -d '"')
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
ENDPOINT=${ENDPOINT:-$PUBLIC_IP}
|
ENDPOINT=${ENDPOINT:-$PUBLIC_IP}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user