]> git.ipfire.org Git - location/libloc.git/commitdiff
location-query: Add output for ipset
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 Nov 2019 14:22:35 +0000 (14:22 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 Nov 2019 14:22:35 +0000 (14:22 +0000)
Fixes: #12202
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
man/location-query.txt
src/python/location-query.in

index ed6f4e586504962dec468cd27fc018cadd6f0ab1..ad129ede5231f15984c99451335040d25c48279e 100644 (file)
@@ -50,6 +50,7 @@ or countries.
        directly loaded into other software. The following options are available:
        +
        * 'list' (default): Just lists all networks, one per line
+       * 'ipset': For ipset
        * 'nftables': For nftables
        * 'xt_geoip': Returns a list of networks to be loaded into the xt_geoip
          kernel module
index 83f23ee1209a0e243a4609ee747e3f705d257d65..72b7c25041acb8fd51cd697df2b2890874da8b03 100644 (file)
@@ -69,6 +69,17 @@ class OutputFormatter(object):
                print(network)
 
 
+class IpsetOutputFormatter(OutputFormatter):
+       """
+               For nftables
+       """
+       def open(self):
+               print("create %s hash:net family inet hashsize 1024 maxelem 65536" % self.name)
+
+       def network(self, network):
+               print("add %s %s" % (self.name, network))
+
+
 class NftablesOutputFormatter(OutputFormatter):
        """
                For nftables
@@ -102,6 +113,7 @@ class XTGeoIPOutputFormatter(OutputFormatter):
 
 class CLI(object):
        output_formats = {
+               "ipset"    : IpsetOutputFormatter,
                "list"     : OutputFormatter,
                "nftables" : NftablesOutputFormatter,
                "xt_geoip" : XTGeoIPOutputFormatter,