Skip to content

Commit

Permalink
Merge branch 'master' into macos
Browse files Browse the repository at this point in the history
  • Loading branch information
pmazzini authored Aug 9, 2021
2 parents d7b9d8b + 427d11c commit 737e322
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
12 changes: 2 additions & 10 deletions netboot/netconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ func GetNetConfFromPacketv6(d *dhcpv6.Message) (*NetConf, error) {
})
}
// get DNS configuration
dns := d.Options.DNS()
if len(dns) == 0 {
return nil, errors.New("no option DNS Recursive Name Servers found")
}
netconf.DNSServers = dns
netconf.DNSServers = d.Options.DNS()

domains := d.Options.DomainSearchList()
if domains != nil {
Expand Down Expand Up @@ -110,11 +106,7 @@ func GetNetConfFromPacketv4(d *dhcpv4.DHCPv4) (*NetConf, error) {
})

// get DNS configuration
dnsServers := d.DNS()
if len(dnsServers) == 0 {
return nil, errors.New("no dns servers options in response packet")
}
netconf.DNSServers = dnsServers
netconf.DNSServers = d.DNS()

// get domain search list
dnsSearchList := d.DomainSearch()
Expand Down
29 changes: 0 additions & 29 deletions netboot/netconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,6 @@ func TestGetNetConfFromPacketv6Invalid(t *testing.T) {
require.Error(t, err)
}

func TestGetNetConfFromPacketv6NoAddrsNoDNS(t *testing.T) {
adv := getAdv(dhcpv6.WithIANA())
_, err := GetNetConfFromPacketv6(adv)
require.Error(t, err)
}

func TestGetNetConfFromPacketv6NoDNS(t *testing.T) {
addrs := []dhcpv6.OptIAAddress{
dhcpv6.OptIAAddress{
IPv6Addr: net.ParseIP("::1"),
PreferredLifetime: 3600 * time.Second,
ValidLifetime: 5200 * time.Second,
},
}
adv := getAdv(dhcpv6.WithIANA(addrs...))
_, err := GetNetConfFromPacketv6(adv)
require.Error(t, err)
}

func TestGetNetConfFromPacketv6NoSearchList(t *testing.T) {
addrs := []dhcpv6.OptIAAddress{
dhcpv6.OptIAAddress{
Expand Down Expand Up @@ -129,16 +110,6 @@ func TestGetNetConfFromPacketv4NoLeaseTime(t *testing.T) {
require.Error(t, err)
}

func TestGetNetConfFromPacketv4NoDNS(t *testing.T) {
d, _ := dhcpv4.New(
dhcpv4.WithNetmask(net.IPv4Mask(255, 255, 255, 0)),
dhcpv4.WithLeaseTime(uint32(0)),
dhcpv4.WithYourIP(net.ParseIP("10.0.0.1")),
)
_, err := GetNetConfFromPacketv4(d)
require.Error(t, err)
}

func TestGetNetConfFromPacketv4EmptyDNSList(t *testing.T) {
d, _ := dhcpv4.New(
dhcpv4.WithNetmask(net.IPv4Mask(255, 255, 255, 0)),
Expand Down

0 comments on commit 737e322

Please sign in to comment.