diff options
author | Stanislas Lange <git@slange.me> | 2023-01-22 15:25:13 +0100 |
---|---|---|
committer | Stanislas Lange <git@slange.me> | 2023-01-22 15:25:13 +0100 |
commit | c97e3cc6b34a54941b052f979974d0929201ca7e (patch) | |
tree | 4eb707942be61d2361c06d5d7a43c8ccef4704ca | |
parent | d7b8cd9948381ff4e474447e761ca92539dc4c72 (diff) |
Handle IPv6 format for server endpoint
Fix https://github.com/angristan/wireguard-install/issues/352
-rw-r--r-- | wireguard-install.sh | 6 |
1 files changed, 6 insertions, 0 deletions
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 "" |