Pull request: 5035-dhcp-hosts-netip-addr

Updates #5035.

Squashed commit of the following:

commit 3a272842f738da322abb2bc5306aed94da79304b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Oct 26 20:34:49 2022 +0300

    dnsforward: imp docs, tests

commit b442ca9b57d730be3af14c68759c706f1742e4c4
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Oct 26 19:51:21 2022 +0300

    dnsforward: imp code, tests

commit 8fca6de93edb8cfdb0ff5a940d08f8700e12a423
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Oct 26 16:38:27 2022 +0300

    dnsforward: mv dhcp hosts to netip.Addr
This commit is contained in:
Ainar Garipov
2022-10-26 21:12:51 +03:00
parent bf10f157ab
commit 8a935d4ffb
7 changed files with 107 additions and 107 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net"
"net/http"
"net/netip"
"runtime"
"strings"
"sync"
@@ -26,8 +27,6 @@ import (
"github.com/miekg/dns"
)
//lint:file-ignore SA1019 TODO(a.garipov): Replace [*netutil.IPMap].
// DefaultTimeout is the default upstream timeout
const DefaultTimeout = 10 * time.Second
@@ -46,8 +45,13 @@ var defaultBlockedHosts = []string{"version.bind", "id.server", "hostname.bind"}
var webRegistered bool
// hostToIPTable is an alias for the type of Server.tableHostToIP.
type hostToIPTable = map[string]net.IP
// hostToIPTable is a convenient type alias for tables of host names to an IP
// address.
type hostToIPTable = map[string]netip.Addr
// ipToHostTable is a convenient type alias for tables of IP addresses to their
// host names. For example, for use with PTR queries.
type ipToHostTable = map[netip.Addr]string
// Server is the main way to start a DNS server.
//
@@ -84,8 +88,7 @@ type Server struct {
tableHostToIP hostToIPTable
tableHostToIPLock sync.Mutex
// TODO(e.burkov): Use map[netip.Addr]struct{} instead.
tableIPToHost *netutil.IPMap
tableIPToHost ipToHostTable
tableIPToHostLock sync.Mutex
// clientIDCache is a temporary storage for ClientIDs that were extracted