From c97e3cc6b34a54941b052f979974d0929201ca7e Mon Sep 17 00:00:00 2001 From: Stanislas Lange Date: Sun, 22 Jan 2023 15:25:13 +0100 Subject: [PATCH] Handle IPv6 format for server endpoint Fix https://github.com/angristan/wireguard-install/issues/352 --- wireguard-install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wireguard-install.sh b/wireguard-install.sh index e8f594b..79dd829 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -273,6 +273,12 @@ net.ipv6.conf.all.forwarding = 1" >/etc/sysctl.d/wg.conf } function newClient() { + # If SERVER_PUB_IP is IPv6, add brackets if missing + if [[ ${SERVER_PUB_IP} =~ .*:.* ]]; then + if [[ ${SERVER_PUB_IP} != *"["* ]] || [[ ${SERVER_PUB_IP} != *"]"* ]]; then + SERVER_PUB_IP="[${SERVER_PUB_IP}]" + fi + fi ENDPOINT="${SERVER_PUB_IP}:${SERVER_PORT}" echo ""