Skip to content

Commit 12f08bf

Browse files
committed
fix(configuration/sources/files/wireguard): fix parsing ipv6 endpoint port
1 parent 4ea2337 commit 12f08bf

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

internal/configuration/sources/files/wireguard.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"os"
88
"path/filepath"
99
"regexp"
10-
"strings"
1110

1211
"gopkg.in/ini.v1"
1312
)
@@ -84,10 +83,7 @@ func parseWireguardPeerSection(peerSection *ini.Section) (
8483
host, port, err := net.SplitHostPort(*endpoint)
8584
if err == nil {
8685
endpointIP = &host
87-
// IPv6 hosts contain colons; port is managed by the provider for those
88-
if !strings.Contains(host, ":") {
89-
endpointPort = &port
90-
}
86+
endpointPort = &port
9187
} else {
9288
endpointIP = endpoint
9389
}

internal/configuration/sources/files/wireguard_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ Endpoint = 1.2.3.4:51820`,
182182
"ipv6_endpoint": {
183183
iniData: `[Peer]
184184
Endpoint = [2a02:bbbb:aaaa:8075::10]:51820`,
185-
endpointIP: ptrTo("2a02:bbbb:aaaa:8075::10"),
185+
endpointIP: ptrTo("2a02:bbbb:aaaa:8075::10"),
186+
endpointPort: ptrTo("51820"),
186187
},
187188
}
188189

0 commit comments

Comments
 (0)