]> git.ipfire.org Git - location/libloc.git/blobdiff - src/python/location-query.in
location-query: Add output for ipset
[location/libloc.git] / src / python / location-query.in
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,