]> git.ipfire.org Git - people/ms/libloc.git/commit
export.py: fix exporting IP networks for crappy xt_geoip module
authorPeter Müller <peter.mueller@ipfire.org>
Wed, 21 Oct 2020 14:47:38 +0000 (14:47 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Oct 2020 17:31:38 +0000 (17:31 +0000)
commit28c73fa3f4257e0a41e52af8a9643da414a6cb6f
tree4755cb10103af96e8028bef8733f3b889b03f319
parent002deb6b42ac0b3624c07e3352cebd72dc0685a2
export.py: fix exporting IP networks for crappy xt_geoip module

In contrast to the location database itself, the xt_geoip module
consumes a list of IP networks for each country, and returns after the
first match.

We therefore need to...

(a) sort IP networks by their size, allow as precise matches as possible
(b) export _any_ IP networks - including inverted subnets - to prevent
    undefined overlaps
(c) do the entire thing as fast as possible, consuming as less disk
    space as possible, which is why we can't just iterate over all /24
    chunks

Partially fixes: #12499

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/export.py