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

net: SplitHostPort() doesn't respect RFC5952 section 6 #37817

Closed
pierre-emmanuelJ opened this issue Mar 12, 2020 · 7 comments
Closed

net: SplitHostPort() doesn't respect RFC5952 section 6 #37817

pierre-emmanuelJ opened this issue Mar 12, 2020 · 7 comments

Comments

@pierre-emmanuelJ
Copy link

@pierre-emmanuelJ pierre-emmanuelJ commented Mar 12, 2020

go version go1.13.1 linux/amd64

repreduced with latest stable version of GO
https://play.golang.org/p/O2OIUNDXPZ_9

go env Output
$ go env
GO111MODULE="off"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ubuntu/.cache/go-build"
GOENV="/home/ubuntu/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ubuntu/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build274095054=/tmp/go-build -gno-record-gcc-switches"

What did you do?

to repreduce the issue:

According to the following screenshot of the RFC5952 section 6, net.SplitHostPort() doesn't respect it.
the function doesn't support <ipv6>:<port> parsing and support only[<ipv6>]:<port>.

image

https://play.golang.org/p/O2OIUNDXPZ_9

What did you expect to see?

2a04:c44:e00:147a:441:aaff:fe00:1d2:8080 parsed to ip=2a04:c44:e00:147a:441:aaff:fe00:1d2 port=8080

What did you see instead?

error output: too many colons in address

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Mar 12, 2020

This RFC is for host/port in text, net works with URIs, which the RFC says MUST follow RFC3986, which specifies the square brackets must be included

@AlexDyukov
Copy link

@AlexDyukov AlexDyukov commented Mar 12, 2020

godoc :
A literal IPv6 address in hostport must be enclosed in square brackets, as in "[::1]:80", "[::1%lo0]:80".

@toothrot
Copy link
Contributor

@toothrot toothrot commented Mar 13, 2020

@pierre-emmanuelJ I agree with the above comments that this seems to be working as intended.

Are you proposing that this should be changed? Are you intending to use the value for Dial, or something else?

@pierre-emmanuelJ
Copy link
Author

@pierre-emmanuelJ pierre-emmanuelJ commented Mar 13, 2020

If you think it's a good idea to add this feature, I'm not against 😃. If I have time I'll add my contribution

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Mar 13, 2020

How are you proposing to handle the ambiguity in addresses that have a ::?

@toothrot
Copy link
Contributor

@toothrot toothrot commented Mar 13, 2020

@pierre-emmanuelJ It would help to know how you intend to use the value, or why you would need this kind of change.

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 13, 2020

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.