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

make code ipv6 safe #55

Open
Luap99 opened this issue Sep 22, 2021 · 1 comment
Open

make code ipv6 safe #55

Luap99 opened this issue Sep 22, 2021 · 1 comment

Comments

@Luap99
Copy link
Member

Luap99 commented Sep 22, 2021

In many places strings.Split(remote, ":") is used to split the ip and port. This does not work for ipv6 addresses.

split := strings.Split(remote, ":")
if len(split) != 2 {
return errors.New("invalid remote addr")
}

To make this work with ipv6 addresses net.SplitHostPort should be used, https://pkg.go.dev/net#SplitHostPort.
To combine a port with a ip address use net.JoinHostPort, https://pkg.go.dev/net#JoinHostPort

@guillaumerose
Copy link
Contributor

Very good point! ipv6 also deserves e2e tests I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants