+ dns: respond to PTR requests for internal IP addresses from DHCP

Close #1682

Squashed commit of the following:

commit 2fad3544bf8853b1f8f19ad8b7bc8a490c96e533
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Mon Jun 22 17:32:45 2020 +0300

    minor

commit 7c17992424702d95e6de91f30e8ae2dfcd8de257
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Mon Jun 22 16:09:34 2020 +0300

    build

commit 16a52e11a015a97d3cbf30362482a4abd052192b
Merge: 7b6a73c8 2c47053c
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Mon Jun 22 16:08:32 2020 +0300

    Merge remote-tracking branch 'origin/master' into 1682-dhcp-resolve

commit 7b6a73c84b5cb9a073a9dfb7d7bdecd22e1e1318
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Mon Jun 22 16:01:34 2020 +0300

    tests

commit c2654abb2e5e7b7e3a04e4ddb8e1064b37613929
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Mon Jun 1 15:15:13 2020 +0300

    + dnsforward: respond to PTR requests for internal IP addresses

    {[IP] => "host"} <- DNSforward <-(leases)-- DHCP
This commit is contained in:
Simon Zolin
2020-06-23 12:13:13 +03:00
parent 2c47053cfe
commit 49a92605b8
9 changed files with 236 additions and 89 deletions

View File

@@ -92,7 +92,7 @@ type Server struct {
conf ServerConfig
// Called when the leases DB is modified
onLeaseChanged onLeaseChangedT
onLeaseChanged []onLeaseChangedT
}
// Print information about the available network interfaces
@@ -146,14 +146,16 @@ func (s *Server) Init(config ServerConfig) error {
// SetOnLeaseChanged - set callback
func (s *Server) SetOnLeaseChanged(onLeaseChanged onLeaseChangedT) {
s.onLeaseChanged = onLeaseChanged
s.onLeaseChanged = append(s.onLeaseChanged, onLeaseChanged)
}
func (s *Server) notify(flags int) {
if s.onLeaseChanged == nil {
if len(s.onLeaseChanged) == 0 {
return
}
s.onLeaseChanged(flags)
for _, f := range s.onLeaseChanged {
f(flags)
}
}
// WriteDiskConfig - write configuration