Commit f62a0913 authored by Mark Karpilovskij's avatar Mark Karpilovskij

mod-geoip: fix subnet default case and test for it

parent 5df67dae
......@@ -732,6 +732,9 @@ static knotd_in_state_t geoip_process(knotd_in_state_t state, knot_pkt_t *pkt,
int (* cmp)(const void *, const void *) = (ctx->mode == MODE_GEODB) ?
geodb_view_cmp : subnet_view_cmp;
int idx = geo_bin_search(data->views, data->count, &dummy, cmp);
if (idx == -1) { // There is no suitable view.
return state;
}
if (cmp(&dummy, &data->views[idx]) != 0) {
idx = data->views[idx].prev;
while (!view_strictly_in_view(&dummy, &data->views[idx], ctx->mode)) {
......
......@@ -78,13 +78,18 @@ for i in range(1, 1000):
resp = knot.dig("d" + str(random.randint(1, dname_count)) + ".example.com", "A", source=random_client)
resp.check(rcode="NOERROR", rdata=random_client)
# Test subnet-dependent answers.
# Restart with subnet module.
knot.clear_modules(None)
knot.add_module(zone, mod_subnet);
knot.gen_confile()
knot.reload()
knot.zone_wait(zone)
# Test default answer again.
resp = knot.dig("foo.example.com", "A")
resp.check(rcode="NOERROR", rdata="192.0.2.4")
# Test subnet-dependent answers.
for i in range(1, 1000):
random_client = "127.255." + str(random.randint(1, iso_count)) + ".0"
resp = knot.dig("d" + str(random.randint(1, dname_count)) + ".example.com", "A", source=random_client)
......
Markdown is supported
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