luci-proto-wireguard: Escape IPv6 endpoints with [] in generated wireguard config 6593/head
authorJonathan Duncan <JonathanDuncan@gmail.com>
Sun, 24 Sep 2023 15:16:35 +0000 (16:16 +0100)
committerJonathan Duncan <JonathanDuncan@gmail.com>
Sun, 24 Sep 2023 15:16:35 +0000 (16:16 +0100)
Signed-off-by: Jonathan Duncan <JonathanDuncan@gmail.com>
protocols/luci-proto-wireguard/htdocs/luci-static/resources/protocol/wireguard.js

index fc28d2bbe578c983c480ed238072bf5e468864f2..58537f38f8b9e68c92130e762070ca6ebbeff015 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,