Commit 5ccb7691 authored by Mikio Hara's avatar Mikio Hara

cmd/fix: revert IPv6 scoped address zone support of IPNet

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7554051
parent 24f47640
......@@ -14,7 +14,7 @@ var netipv6zoneFix = fix{
"netipv6zone",
"2012-11-26",
netipv6zone,
`Adapt element key to IPNet, IPAddr, UDPAddr or TCPAddr composite literals.
`Adapt element key to IPAddr, UDPAddr or TCPAddr composite literals.
https://codereview.appspot.com/6849045/
`,
......@@ -39,7 +39,7 @@ func netipv6zone(f *ast.File) bool {
return
}
switch ss := se.Sel.String(); ss {
case "IPNet", "IPAddr", "UDPAddr", "TCPAddr":
case "IPAddr", "UDPAddr", "TCPAddr":
for i, e := range cl.Elts {
if _, ok := e.(*ast.KeyValueExpr); ok {
break
......@@ -51,21 +51,13 @@ func netipv6zone(f *ast.File) bool {
Value: e,
}
case 1:
if ss == "IPNet" {
if e.(*ast.BasicLit).Value == "0" {
cl.Elts = append(cl.Elts[:i], cl.Elts[i+1:]...)
} else {
cl.Elts[i] = &ast.KeyValueExpr{
Key: ast.NewIdent("Mask"),
Key: ast.NewIdent("Port"),
Value: e,
}
} else {
if e.(*ast.BasicLit).Value == "0" {
cl.Elts = append(cl.Elts[:i], cl.Elts[i+1:]...)
} else {
cl.Elts[i] = &ast.KeyValueExpr{
Key: ast.NewIdent("Port"),
Value: e,
}
}
}
}
fixed = true
......
......@@ -15,18 +15,11 @@ var netipv6zoneTests = []testCase{
import "net"
var a = []struct {
*net.IPNet
}{
&net.IPNet{net.ParseIP("2001:DB8::"), net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
}
func f() net.Addr {
b := net.IPNet{net.IPv4(127, 0, 0, 1), net.IPv4Mask(255, 0, 0, 0)}
c := &net.IPAddr{ip1}
a := &net.IPAddr{ip1}
sub(&net.UDPAddr{ip2, 12345})
d := &net.TCPAddr{IP: ip3, Port: 54321}
e := &net.TCPAddr{ip4, 0}
c := &net.TCPAddr{IP: ip3, Port: 54321}
d := &net.TCPAddr{ip4, 0}
return &net.TCPAddr{ip5}, nil
}
`,
......@@ -34,18 +27,11 @@ func f() net.Addr {
import "net"
var a = []struct {
*net.IPNet
}{
&net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
}
func f() net.Addr {
b := net.IPNet{IP: net.IPv4(127, 0, 0, 1), Mask: net.IPv4Mask(255, 0, 0, 0)}
c := &net.IPAddr{IP: ip1}
a := &net.IPAddr{IP: ip1}
sub(&net.UDPAddr{IP: ip2, Port: 12345})
d := &net.TCPAddr{IP: ip3, Port: 54321}
e := &net.TCPAddr{IP: ip4}
c := &net.TCPAddr{IP: ip3, Port: 54321}
d := &net.TCPAddr{IP: ip4}
return &net.TCPAddr{IP: ip5}, nil
}
`,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment