]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
policy: change the localhost. domain
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 11 Jul 2017 14:18:18 +0000 (16:18 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 11 Jul 2017 14:18:18 +0000 (16:18 +0200)
The RFC seems to read that resolvers should reply with address records
even for foo.bar.localhost.  Note: Unbound-1.6.4 does NOT do that.
https://tools.ietf.org/html/rfc6761#section-6.3

modules/policy/policy.lua

index 1183883f2462bc51aa9c2d1b1d781448e418c164..05c1099a51a37c12b6187d37cb88f38727fe39e4 100644 (file)
@@ -145,25 +145,18 @@ local function localhost(state, req)
        ffi.C.kr_pkt_make_auth_header(answer)
 
        local is_exact = ffi.C.knot_dname_is_equal(qry.sname, dname_localhost)
-       if not is_exact then
-               answer:rcode(kres.rcode.NXDOMAIN)
-               answer:begin(kres.section.AUTHORITY)
-               mkauth_soa(answer, dname_localhost)
-               return kres.DONE
-       end
 
        answer:rcode(kres.rcode.NOERROR)
        answer:begin(kres.section.ANSWER)
        if qry.stype == kres.type.AAAA then
-               answer:put(dname_localhost, 900, answer:qclass(), kres.type.AAAA,
+               answer:put(qry.sname, 900, answer:qclass(), kres.type.AAAA,
                        '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1')
        elseif qry.stype == kres.type.A then
-               answer:put(dname_localhost, 900, answer:qclass(), kres.type.A, '\127\0\0\1')
-       elseif qry.stype == kres.type.SOA then
+               answer:put(qry.sname, 900, answer:qclass(), kres.type.A, '\127\0\0\1')
+       elseif is_exact and qry.stype == kres.type.SOA then
                mkauth_soa(answer, dname_localhost)
-       elseif qry.stype == kres.type.NS then
-               answer:put(dname_localhost, 900, answer:qclass(), kres.type.NS,
-                       dname_localhost)
+       elseif is_exact and qry.stype == kres.type.NS then
+               answer:put(dname_localhost, 900, answer:qclass(), kres.type.NS, dname_localhost)
        else
                answer:begin(kres.section.AUTHORITY)
                mkauth_soa(answer, dname_localhost)