+ dhcpv6 server; rewrite dhcpv4 server; changed API

This commit is contained in:
Simon Zolin
2020-07-03 18:20:01 +03:00
parent c3123473cf
commit a3317c08c4
27 changed files with 2384 additions and 1280 deletions

View File

@@ -1018,9 +1018,22 @@ func TestMatchDNSName(t *testing.T) {
assert.True(t, !matchDNSName(dnsNames, "*.host2"))
}
type testDHCP struct {
}
func (d *testDHCP) Leases(flags int) []dhcpd.Lease {
l := dhcpd.Lease{}
l.IP = net.ParseIP("127.0.0.1").To4()
l.HWAddr, _ = net.ParseMAC("aa:aa:aa:aa:aa:aa")
l.Hostname = "localhost"
return []dhcpd.Lease{l}
}
func (d *testDHCP) SetOnLeaseChanged(onLeaseChanged dhcpd.OnLeaseChangedT) {
return
}
func TestPTRResponse(t *testing.T) {
dhcp := &dhcpd.Server{}
dhcp.IPpool = make(map[[4]byte]net.HardwareAddr)
dhcp := &testDHCP{}
c := dnsfilter.Config{}
f := dnsfilter.New(&c, nil)
@@ -1033,12 +1046,6 @@ func TestPTRResponse(t *testing.T) {
assert.True(t, err == nil)
assert.Nil(t, s.Start())
l := dhcpd.Lease{}
l.IP = net.ParseIP("127.0.0.1").To4()
l.HWAddr, _ = net.ParseMAC("aa:aa:aa:aa:aa:aa")
l.Hostname = "localhost"
dhcp.AddStaticLease(l)
addr := s.dnsProxy.Addr(proxy.ProtoUDP)
req := createTestMessage("1.0.0.127.in-addr.arpa.")
req.Question[0].Qtype = dns.TypePTR