network: do not assign gateway for DigitalOcean anchor IP address

This commit is contained in:
Matt Layher 2015-10-27 10:49:05 -04:00
parent 8847a471c5
commit 1fd780befc
2 changed files with 4 additions and 23 deletions

View File

@ -127,7 +127,7 @@ func parseInterface(iface digitalocean.Interface, nameservers []net.IP, useRoute
}
}
if iface.AnchorIPv4 != nil {
var ip, mask, gateway net.IP
var ip, mask net.IP
if ip = net.ParseIP(iface.AnchorIPv4.IPAddress); ip == nil {
return nil, fmt.Errorf("could not parse %q as anchor IPv4 address", iface.AnchorIPv4.IPAddress)
}
@ -140,15 +140,11 @@ func parseInterface(iface digitalocean.Interface, nameservers []net.IP, useRoute
})
if useRoute {
if gateway = net.ParseIP(iface.AnchorIPv4.Gateway); gateway == nil {
return nil, fmt.Errorf("could not parse %q as anchor IPv4 gateway", iface.AnchorIPv4.Gateway)
}
routes = append(routes, route{
destination: net.IPNet{
IP: net.IPv4zero,
Mask: net.IPMask(net.IPv4zero),
},
gateway: gateway,
})
}
}

View File

@ -281,19 +281,6 @@ func TestParseInterface(t *testing.T) {
nss: []net.IP{},
err: errors.New("could not parse \"bad\" as anchor IPv4 mask"),
},
{
cfg: digitalocean.Interface{
MAC: "01:23:45:67:89:AB",
AnchorIPv4: &digitalocean.Address{
IPAddress: "1.2.3.4",
Netmask: "255.255.0.0",
Gateway: "bad",
},
},
useRoute: true,
nss: []net.IP{},
err: errors.New("could not parse \"bad\" as anchor IPv4 gateway"),
},
{
cfg: digitalocean.Interface{
MAC: "01:23:45:67:89:AB",
@ -305,7 +292,6 @@ func TestParseInterface(t *testing.T) {
AnchorIPv4: &digitalocean.Address{
IPAddress: "7.8.9.10",
Netmask: "255.255.0.0",
Gateway: "11.12.13.14",
},
},
useRoute: true,
@ -326,12 +312,11 @@ func TestParseInterface(t *testing.T) {
nameservers: []net.IP{},
routes: []route{
{
net.IPNet{IP: net.IPv4zero, Mask: net.IPMask(net.IPv4zero)},
net.ParseIP("5.6.7.8"),
destination: net.IPNet{IP: net.IPv4zero, Mask: net.IPMask(net.IPv4zero)},
gateway: net.ParseIP("5.6.7.8"),
},
{
net.IPNet{IP: net.IPv4zero, Mask: net.IPMask(net.IPv4zero)},
net.ParseIP("11.12.13.14"),
destination: net.IPNet{IP: net.IPv4zero, Mask: net.IPMask(net.IPv4zero)},
},
},
},