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: clean up port parsing #15326

Closed
bradfitz opened this issue Apr 15, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@bradfitz
Copy link
Member

commented Apr 15, 2016

https://go-review.googlesource.com/#/c/19720/ updated the parsing of port numbers, but now it accepts
stuff starting with a `+' sign, like:

   net.Dial("tcp", "foo.com:+80")

Nobody ever told me why that should be allowed, but the CL was submitted anyway. Or I missed it, but I can't find it.

Investigate and ideally fix.

/cc @mikioh @msiebuhr

@bradfitz bradfitz self-assigned this Apr 15, 2016

@bradfitz bradfitz added this to the Go1.7 milestone Apr 15, 2016

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2016

Yes, I will send a followup CL for better consistency. FWIW, unfortunately the following snippet works w/ CGO_ENABLED=1 older versions or GODEBUG=netdns=cgo newer versions.

package main

import "net"

func main() {
    for _, arg := range []string{"127.0.0.1:+0", "127.0.0.1:-0"} {
        ln, err := net.Listen("tcp", arg)
        if err != nil {
            println(err.Error())
            continue
        }
        println(ln.Addr().String())
        ln.Close()
    }
}

Probably we should make consistent representation on transport service names and literal port numbers in ABNF for Dial/Listen APIs before Go 1.

@bradfitz bradfitz removed this from the Go1.7 milestone May 5, 2016

@bradfitz

This comment has been minimized.

Copy link
Member Author

commented May 5, 2016

Okay, if +n worked before, we don't need to do anything here. Still weird, but yay compatibility.

@bradfitz bradfitz closed this May 5, 2016

@golang golang locked and limited conversation to collaborators May 5, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.