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
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@pierre-emmanuelJ
Copy link

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
Member

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

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

@toothrot
Copy link
Contributor

@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

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
Member

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

@toothrot
Copy link
Contributor

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

@toothrot toothrot added this to the Backlog milestone Mar 13, 2020
@toothrot toothrot added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Mar 13, 2020
@gopherbot
Copy link

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.)

@golang golang locked and limited conversation to collaborators Apr 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants