Skip to content

Commit

Permalink
Merge pull request #94 from taoso/fix-ipv6-zone
Browse files Browse the repository at this point in the history
Fix IPv6 link local address without brackets
  • Loading branch information
natesales authored Jul 21, 2024
2 parents de71183 + 48a2ea3 commit 88eed1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func setPort(u *url.URL, port int) {
func parseServer(s string) (string, transport.Type, error) {
// Remove IPv6 scope ID if present
var scopeId string
v6scopeRe := regexp.MustCompile(`\[[a-fA-F0-9:]+%[a-zA-Z0-9]+]`)
v6scopeRe := regexp.MustCompile(`(^|\[)[a-fA-F0-9:]+%[a-zA-Z0-9]+`)
if v6scopeRe.MatchString(s) {
v6scopeRemoveRe := regexp.MustCompile(`(%[a-zA-Z0-9]+)`)
matches := v6scopeRemoveRe.FindStringSubmatch(s)
Expand Down
5 changes: 5 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,11 @@ func TestMainParseServer(t *testing.T) {
Type: transport.TypeQUIC,
ExpectedHost: "dns.adguard.com:8530",
},
{ // IPv6 plain with scope ID but without port
Server: "fe80::1%en0",
Type: transport.TypePlain,
ExpectedHost: "[fe80::1%en0]:53",
},
{ // IPv6 with scope ID and explicit port
Server: "plain://[fe80::1%en0]:53",
Type: transport.TypePlain,
Expand Down

0 comments on commit 88eed1e

Please sign in to comment.