Pull request: fix zero-length ip addresses list bug

Merge in DNS/adguard-home from 2304-fix-panic to master

Updates #2304.

Squashed commit of the following:

commit bd7742eb144b46e16c751f98f6a4a6f15fbfa60e
Merge: 26313926e 7d1d87d6e
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Wed Dec 2 14:29:37 2020 +0300

    Merge branch 'master' into 2304-fix-panic

commit 26313926e827d1f5ceb4eec744b814ce7c32663d
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Wed Dec 2 14:09:16 2020 +0300

    all: add gitignore rule

commit 5a8521bd9b4014972107e8de352e20144f8187fb
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Wed Dec 2 14:03:26 2020 +0300

    dhcpd: fix zero-length ip addresses list bug
This commit is contained in:
Eugene Burkov 2020-12-02 14:42:59 +03:00
parent 7d1d87d6ec
commit ab8defdb08
3 changed files with 11 additions and 0 deletions

1
.gitignore vendored
View file

@ -12,6 +12,7 @@
/querylog.json
/querylog.json.1
coverage.txt
leases.db
# Test output
dnsfilter/tests/top-1m.csv

View file

@ -581,6 +581,11 @@ func (s *v4Server) Start() error {
return fmt.Errorf("dhcpv4: interface %s: %w", ifaceName, err)
}
if len(dnsIPAddrs) == 0 {
// No available IP addresses which may appear later.
return nil
}
s.conf.dnsIPAddrs = dnsIPAddrs
laddr := &net.UDPAddr{

View file

@ -579,6 +579,11 @@ func (s *v6Server) Start() error {
return fmt.Errorf("dhcpv6: interface %s: %w", ifaceName, err)
}
if len(dnsIPAddrs) == 0 {
// No available IP addresses which may appear later.
return nil
}
s.conf.dnsIPAddrs = dnsIPAddrs
err = s.initRA(iface)