Resolve hostname to localhost

This commit is contained in:
Daniel
2021-11-18 16:28:26 +01:00
parent 8794d72318
commit e092ab9831
2 changed files with 11 additions and 2 deletions

View File

@@ -19,6 +19,8 @@ import (
"github.com/miekg/dns"
)
var hostname string
func handleRequestAsWorker(w dns.ResponseWriter, query *dns.Msg) {
err := module.RunWorker("dns request", func(ctx context.Context) error {
return handleRequest(ctx, w, query)
@@ -87,8 +89,8 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, request *dns.Msg)
return reply(nsutil.Refused("unsupported qclass"))
}
// Handle request for localhost.
if strings.HasSuffix(q.FQDN, "localhost.") {
// Handle request for localhost and the hostname.
if strings.HasSuffix(q.FQDN, "localhost.") || q.FQDN == hostname {
tracer.Tracef("nameserver: returning localhost records")
return reply(nsutil.Localhost())
}