Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IPv6 link local address without brackets #94

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading