aboutsummaryrefslogtreecommitdiff
path: root/wireguard-install.sh
diff options
context:
space:
mode:
authorLeopere <colin@nixc.us>2019-06-05 10:52:44 -0400
committerLeopere <colin@nixc.us>2019-06-05 11:04:52 -0400
commitbb2861390ea6a5df6c33d35a0cf2299a1a88f4ed (patch)
tree826cae7a1fc5fd1e2a0311bc80142667e28f2c83 /wireguard-install.sh
parent7e71ea7dbb5a3962daea8abee065fd550ade31b8 (diff)
Detect rather than ask IP Version
Diffstat (limited to 'wireguard-install.sh')
-rw-r--r--wireguard-install.sh11
1 files changed, 6 insertions, 5 deletions
diff --git a/wireguard-install.sh b/wireguard-install.sh
index cec2b4b..07ef9a1 100644
--- a/wireguard-install.sh
+++ b/wireguard-install.sh
@@ -38,8 +38,6 @@ fi
SERVER_PUB_IPV4=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
read -rp "IPv4 or IPv6 public address: " -e -i "$SERVER_PUB_IPV4" SERVER_PUB_IP
-read -rp "Did you enter an IPv6 address? (y/n) " -e -i n SERVER_PUB_IPV6_USED
-
# Detect public interface and pre-fill for the user
SERVER_PUB_NIC="$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1)"
read -rp "Public interface: " -e -i "$SERVER_PUB_NIC" SERVER_PUB_NIC
@@ -69,10 +67,13 @@ read -rp "First DNS resolver to use for the client: " -e -i "$CLIENT_DNS_1" CLIE
CLIENT_DNS_2="176.103.130.131"
read -rp "Second DNS resolver to use for the client: " -e -i "$CLIENT_DNS_2" CLIENT_DNS_2
-if [[ $SERVER_PUB_IPV6_USED = 'y' ]]; then
- ENDPOINT="[$SERVER_PUB_IP]:$SERVER_PORT"
+if [[ $SERVER_PUB_IP =~ .*:.* ]]
+then
+ echo "IPv6 Detected"
+ ENDPOINT="[$SERVER_PUB_IP]:$SERVER_PORT"
else
- ENDPOINT="$SERVER_PUB_IP:$SERVER_PORT"
+ echo "IPv4 Detected"
+ ENDPOINT="$SERVER_PUB_IP:$SERVER_PORT"
fi
# Install WireGuard tools and module