diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2021-04-25 17:16:44 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2021-08-09 19:35:18 +0100 |
commit | 427d11cea22a049c2369be32de0decb1157134fe (patch) | |
tree | 410cf5f03bfd80d43d3057acf44513353e5f7011 /netboot | |
parent | 1cac67f12b1e213c50139310d4490dd3a4e6cce6 (diff) |
netboot: DNS not mandatory
Diffstat (limited to 'netboot')
-rw-r--r-- | netboot/netconf.go | 12 | ||||
-rw-r--r-- | netboot/netconf_test.go | 29 |
2 files changed, 2 insertions, 39 deletions
diff --git a/netboot/netconf.go b/netboot/netconf.go index 7fc38e2..85cfafb 100644 --- a/netboot/netconf.go +++ b/netboot/netconf.go @@ -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 { @@ -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() diff --git a/netboot/netconf_test.go b/netboot/netconf_test.go index 8b1f5f7..e2541cd 100644 --- a/netboot/netconf_test.go +++ b/netboot/netconf_test.go @@ -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{ @@ -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)), |