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: decide details of Zone API for Go 1.1 #4501

Closed
rsc opened this issue Dec 7, 2012 · 10 comments
Closed

net: decide details of Zone API for Go 1.1 #4501

rsc opened this issue Dec 7, 2012 · 10 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Dec 7, 2012

Adding Zone to all these net structs is quite disruptive. Even though the Go 1
compatibility doc says people should be using TCPAddr{IP: ip, Port: port}, there are
lots of instances of TCPAddr{ip, port} in people's code. Once the dust has settled we
need to look at the benefits and decide they are worth the cost.
@rsc
Copy link
Contributor Author

rsc commented Dec 10, 2012

Comment 1:

Labels changed: added size-l.

@rsc
Copy link
Contributor Author

rsc commented Mar 13, 2013

Comment 3:

Time to decide. 
In the same 8-million-line corpus that I used for the return analysis, I looked for
literals using net types. There are hardly any, and most do use tags correctly. 6 of 15
net.IPAddr literals are missing field tags, 9 of 40 net.TCPAddr literals, and 44 of 89
net.UDPAddr literals. I think this is minor enough that we can add the zone to these
structs.
That is, Zone makes the cut.
Here's what I think should change / stay the same. I created this list without reference
to Mikio's CL; we should discuss the ones that disagree.
Functions that do accept address+zone strings.
dial.go:188: func Dial(net, addr string) (Conn, error) {
dial.go:195: func DialOpt(addr string, opts ...DialOption) (Conn, error) {
dial.go:235: func DialTimeout(net, addr string, timeout time.Duration) (Conn, error) {
dial.go:295: func Listen(net, laddr string) (Listener, error) {
dial.go:312: func ListenPacket(net, laddr string) (PacketConn, error) {
iprawsock.go:28: func ResolveIPAddr(net, addr string) (*IPAddr, error) {
ipsock.go:74: func SplitHostPort(hostport string) (host, port string, err error) {
ipsock.go:141: func JoinHostPort(host, port string) string {
tcpsock.go:31: func ResolveTCPAddr(net, addr string) (*TCPAddr, error) {
udpsock.go:35: func ResolveUDPAddr(net, addr string) (*UDPAddr, error) {
Functions that do not accept address+zone strings.
dial.go:55: func Network(net string) DialOption {
interface.go:112: func InterfaceByName(name string) (*Interface, error) {
ip.go:618: func ParseIP(s string) IP {
iprawsock_plan9.go:70: func DialIP(netProto string, laddr, raddr *IPAddr) (*IPConn,
error) {
iprawsock_plan9.go:82: func ListenIP(netProto string, laddr *IPAddr) (*IPConn, error) {
iprawsock_posix.go:164: func DialIP(netProto string, laddr, raddr *IPAddr) (*IPConn,
error) {
iprawsock_posix.go:192: func ListenIP(netProto string, laddr *IPAddr) (*IPConn, error) {
lookup.go:13: func LookupHost(host string) (addrs []string, err error) {
lookup.go:56: func LookupIP(host string) (addrs []IP, err error) {
lookup.go:61: func LookupPort(network, service string) (port int, err error) {
lookup.go:69: func LookupCNAME(name string) (cname string, err error) {
lookup.go:82: func LookupSRV(service, proto, name string) (cname string, addrs []*SRV,
err error) {
lookup.go:87: func LookupMX(name string) (mx []*MX, err error) {
lookup.go:92: func LookupNS(name string) (ns []*NS, err error) {
lookup.go:97: func LookupTXT(name string) (txt []string, err error) {
lookup.go:103: func LookupAddr(addr string) (name []string, err error) {
mac.go:39: func ParseMAC(s string) (hw HardwareAddr, err error) {
tcpsock_plan9.go:81: func DialTCP(net string, laddr, raddr *TCPAddr) (*TCPConn, error) {
tcpsock_plan9.go:170: func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) {
tcpsock_posix.go:140: func DialTCP(net string, laddr, raddr *TCPAddr) (*TCPConn, error) {
tcpsock_posix.go:279: func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) {
udpsock_plan9.go:115: func DialUDP(net string, laddr, raddr *UDPAddr) (*UDPConn, error) {
udpsock_plan9.go:170: func ListenUDP(net string, laddr *UDPAddr) (*UDPConn, error) {
udpsock_plan9.go:198: func ListenMulticastUDP(net string, ifi *Interface, gaddr
*UDPAddr) (*UDPConn, error) {
udpsock_posix.go:163: func DialUDP(net string, laddr, raddr *UDPAddr) (*UDPConn, error) {
udpsock_posix.go:187: func ListenUDP(net string, laddr *UDPAddr) (*UDPConn, error) {
udpsock_posix.go:207: func ListenMulticastUDP(net string, ifi *Interface, gaddr
*UDPAddr) (*UDPConn, error) {
unixsock.go:37: func ResolveUnixAddr(net, addr string) (*UnixAddr, error) {
unixsock_plan9.go:82: func DialUnix(net string, laddr, raddr *UnixAddr) (*UnixConn,
error) {
unixsock_plan9.go:97: func ListenUnix(net string, laddr *UnixAddr) (*UnixListener,
error) {
unixsock_plan9.go:139: func ListenUnixgram(net string, laddr *UnixAddr) (*UnixConn,
error) {
unixsock_posix.go:228: func DialUnix(net string, laddr, raddr *UnixAddr) (*UnixConn,
error) {
unixsock_posix.go:255: func ListenUnix(net string, laddr *UnixAddr) (*UnixListener,
error) {
unixsock_posix.go:344: func ListenUnixgram(net string, laddr *UnixAddr) (*UnixConn,
error) {
Types without explicit zone.
dial.go:13: type DialOption interface {
dial_test.go:150: type DialErrorTest struct {
dnsclient.go:13: type DNSError struct {
dnsclient.go:166: type SRV struct {
dnsclient.go:225: type MX struct {
dnsclient.go:249: type NS struct {
interface.go:20: type Interface struct {
interface.go:28: type Flags uint
ip.go:30: type IP []byte
ip.go:33: type IPMask []byte
ip.go:594: type ParseError struct {
iprawsock_plan9.go:16: type IPConn struct {
iprawsock_posix.go:56: type IPConn struct {
ipsock.go:65: type InvalidAddrError string
mac.go:14: type HardwareAddr []byte
net.go:55: type Addr interface {
net.go:63: type Conn interface {
net.go:210: type Error interface {
net.go:219: type PacketConn interface {
net.go:265: type Listener interface {
net.go:282: type OpError struct {
net.go:343: type AddrError struct {
net.go:367: type UnknownNetworkError string
net.go:374: type DNSConfigError struct {
tcpsock_plan9.go:18: type TCPConn struct {
tcpsock_plan9.go:106: type TCPListener struct {
tcpsock_posix.go:63: type TCPConn struct {
tcpsock_posix.go:222: type TCPListener struct {
udpsock_plan9.go:18: type UDPConn struct {
udpsock_posix.go:56: type UDPConn struct {
unixsock.go:10: type UnixAddr struct {
unixsock_plan9.go:17: type UnixConn struct {
unixsock_plan9.go:93: type UnixListener struct{}
unixsock_posix.go:107: type UnixConn struct {
unixsock_posix.go:248: type UnixListener struct {
Types with explicit zone.
iprawsock.go:10: type IPAddr struct {
tcpsock.go:10: type TCPAddr struct {
udpsock.go:14: type UDPAddr struct {
Not yet decided.
ip.go:36: type IPNet struct {
ip.go:632: func ParseCIDR(s string) (IP, *IPNet, error) {
In the case of ParseCIDR and IPNet, you've proposed to add zone there, but I don't
understand what it means. Why is it important? How should a caller use the IPNet if a
Zone is involved? The purpose of the IPNet struct is to provide a Contains method, and
yet the Contains method cannot use the Zone to make its decision. Is there any document
explaining the syntax of CIDR addresses with zones and what they mean?

@mikioh
Copy link
Contributor

mikioh commented Mar 15, 2013

Comment 4:

With regard to IPNet,  RFC 4007 describes "Combinations of Delimiter Characters".
One use case would be InterfaceAddrs that returns a slice of IPNet. Let's say when 
an IPv6 node has two links but assignes the same link-local address like below,
  fe80::1%em0/64
  fe80::1%em1/64
literal IPv6 address w/ zone identifier might be helpful to distinguish each other.

@mikioh
Copy link
Contributor

mikioh commented Mar 15, 2013

Comment 5:

References:
IPv6 Scoped Address Architecture
http://tools.ietf.org/html/rfc4007
Representing IPv6 Zone Identifiers in Address Literals and Uniform Resource Identifiers
http://tools.ietf.org/html/rfc6874

@mikioh
Copy link
Contributor

mikioh commented Mar 15, 2013

Comment 6:

One concern. Perhaps we should postpone supporting literal IPv6 address 
w/ zone-id to both SplitHostPort and JoinHostPort because I'm not sure 
whether
  host, port, err := net.SplitHostPort(url.URL.Host)
is preferable. Should the "host" in net package be equivalent to the "host" 
in url package?

@rsc
Copy link
Contributor Author

rsc commented Mar 15, 2013

Comment 7:

I was hoping SplitHostPort and JoinHostPort would just work unaltered. We
could make the % make SplitHostPort fail, but we can't do anything about
JoinHostPort.
% cannot occur in the host of a URL, so I think it's not much of an issue
there.

@rsc
Copy link
Contributor Author

rsc commented Mar 15, 2013

Comment 8:

I suggest doing everything but IPNet and then worrying about IPNet.

@mikioh
Copy link
Contributor

mikioh commented Mar 15, 2013

Comment 9:

Do you want to revert IPNet stuff temporally at tip?

@rsc
Copy link
Contributor Author

rsc commented Mar 15, 2013

Comment 10:

Sure, let's do that.

@mikioh
Copy link
Contributor

mikioh commented Mar 23, 2013

Comment 11:

This issue was closed by revision aa0dda7.

Status changed to Fixed.

@rsc rsc added fixed labels Mar 23, 2013
@rsc rsc self-assigned this Mar 23, 2013
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants