local function rpz_parse(action, path)
local rules = {}
local new_actions = {}
+ local origin = '.'
local action_map = {
-- RPZ Policy Actions
['\0'] = action,
local name = ffi.string(parser.r_owner, parser.r_owner_length)
local rdata = ffi.string(parser.r_data, parser.r_data_length)
+ if (parser.r_type == kres.type.SOA) then
+ -- parser return \0 if SOA use @ as owner
+ origin = (name == '\0') and origin or name
+ goto continue
+ end
+
+ name = (name == origin) and name or name:gsub('%'..origin, '')
+
if parser.r_type == kres.type.CNAME then
if action_map[rdata] then
rules[name] = action_map[rdata]
end
end
end
+
+ ::continue::
end
collectgarbage()
for k, v in pairs(new_actions) do
'rpzpassthru.', kres.type.A, kres.rcode.NOERROR, '127.0.0.9')
check_answer('"A 192.168.55.5" return local A rrset',
'rra.', kres.type.A, kres.rcode.NOERROR, '192.168.55.5')
+ check_answer('"A 192.168.66.6" with suffixed zone name in owner return local A rrset',
+ 'rra-zonename-suffix.', kres.type.A, kres.rcode.NOERROR, '192.168.66.6')
check_answer('non existing AAAA on rra domain return NODATA',
'rra.', kres.type.AAAA, kres.rcode.NOERROR)
end
$TTL 30
-@ SOA nonexistent.nodomain.none. dummy.nodomain.none. 1 12h 15m 3w 2h
- NS nonexistant.nodomain.none.
+testdomain. SOA nonexistent.testdomain. testdomain. 1 12h 15m 3w 2h
+ NS nonexistant.testdomain.
-nxdomain. CNAME .
-nodata. CNAME *.
-rpzdrop. CNAME rpz-drop.
-rpzpassthru. CNAME rpz-passthru.
-rra. A 192.168.55.5
+nxdomain. CNAME .
+nodata. CNAME *.
+rpzdrop. CNAME rpz-drop.
+rpzpassthru. CNAME rpz-passthru.
+rra. A 192.168.55.5
+rra-zonename-suffix.testdomain. A 192.168.66.6