-
Notifications
You must be signed in to change notification settings - Fork 160
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 snet.UDPAddress parsing & serialization #3650
Conversation
Allow <IPv4>:port without []. Use net library functions instead of manual parsing. Fixes scionproto#3647
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @oncilla)
go/lib/snet/udpaddr.go, line 70 at r2 (raw file):
} hostPortPart := parts["host"] host, portS, err := net.SplitHostPort(hostPortPart)
Just use net.ResolveUDPAddr(...)
here then we can remove the code below.
go/lib/snet/udpaddr.go, line 151 at r2 (raw file):
I
lower case start of error message
go/lib/snet/udpaddr.go, line 165 at r2 (raw file):
// If the input is invalid, or also contains a port, nil is returned. func hostOnly(s string) net.IP { left, right := strings.Count(s, "["), strings.Count(s, "]")
I think the bracket checks could be done separately in the beginning as a validation function. If any of those 2 conditions fail, it is an error and the format is wrong. SplitHostPort will also fail. hostOnly is really only the last line of this function, at which point I don't see the need for a separate function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 files reviewed, 3 unresolved discussions (waiting on @lukedirtwalker)
go/lib/snet/udpaddr.go, line 70 at r2 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
Just use
net.ResolveUDPAddr(...)
here then we can remove the code below.
Done.
go/lib/snet/udpaddr.go, line 151 at r2 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
I
lower case start of error message
Done.
go/lib/snet/udpaddr.go, line 165 at r2 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
I think the bracket checks could be done separately in the beginning as a validation function. If any of those 2 conditions fail, it is an error and the format is wrong. SplitHostPort will also fail. hostOnly is really only the last line of this function, at which point I don't see the need for a separate function.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @oncilla)
go/lib/snet/udpaddr.go, line 157 at r3 (raw file):
// hostOnly parses the input in the case it only contains a host. // If the input is invalid, or also contains a port, nil is returned. func hostOnly(s string) net.IP {
remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @lukedirtwalker)
go/lib/snet/udpaddr.go, line 157 at r3 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
remove?
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r4.
Reviewable status: complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved
Allow :port without [] for IPv4.
Use net library functions instead of manual parsing.
Fixes #3647
based on #3648
This change is