Skip to content
Snippets Groups Projects
Verified Commit 8289094d authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

view.addr(): throw error on bad subnet

It's more consistent with what we do.  Now it will look like:
[system] error while loading config: .../lib/knot-resolver/kres_modules/view.lua:28: failed to parse subnet [::1]/128 (workdir '/foo/bar')
parent 1c73d6ae
Branches
Tags
1 merge request!1112view tweaks
Knot Resolver 5.2.2 (2021-0m-dd)
================================
Bugfixes
--------
- view: fail config if bad subnet is specified (!1112)
Knot Resolver 5.2.1 (2020-12-09)
================================
......
......@@ -24,6 +24,9 @@ function view.addr(_, subnet, rules, dst)
local subnet_cd = ffi.new('char[16]')
local family = C.kr_straddr_family(subnet)
local bitlen = C.kr_straddr_subnet(subnet_cd, subnet)
if bitlen < 0 then
error(string.format('failed to parse subnet %s', subnet))
end
local t = {family, subnet_cd, bitlen, rules}
table.insert(dst and view.dst or view.src, t)
return t
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment