luci-proto-wireguard: Escape IPv6 endpoints with [] in generated wireguard config

Signed-off-by: Jonathan Duncan <JonathanDuncan@gmail.com>
This commit is contained in:
Jonathan Duncan 2023-09-24 16:16:35 +01:00
parent d7e905e83a
commit 527453ff48

View 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,