luci-proto-wireguard: Escape IPv6 endpoints with [] in generated wireguard config
authorJonathan Duncan <JonathanDuncan@gmail.com>
Sun, 24 Sep 2023 15:16:35 +0000 (16:16 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 2 Nov 2023 10:44:15 +0000 (11:44 +0100)
Signed-off-by: Jonathan Duncan <JonathanDuncan@gmail.com>
(cherry picked from commit 527453ff4851a0594f804aa2c572e820706827c8)

protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js

index 2126403de6b6cfee4661e332a63aba6487fc6dde..3db1fe80f3a60e67c5a7776cd04b8da632a514f8 100644 (file)
@@ -700,6 +700,11 @@ return network.registerProtocol('wireguard', {
                            eport = this.section.formvalue(section_id, 'endpoint_port'),
                            keep = this.section.formvalue(section_id, 'persistent_keepalive');
 
+                       // If endpoint is IPv6 we must escape it with []
+                       if (endpoint.indexOf(':') > 0) {
+                               endpoint = '['+endpoint+']';
+                       }
+
                        return [
                                '[Interface]',
                                'PrivateKey = ' + prv,