from dnstest.test import Test
from dnstest.module import ModGeoip
from dnstest.utils import *
-from subprocess import Popen, PIPE
import random
-import re
-
-def check_mmdb():
- '''Checks the server binary for the MMDB_open function'''
-
- try:
- proc = Popen(ModGeoip._check_cmd(), stdout=PIPE, stderr=PIPE,
- universal_newlines=True)
- (out, err) = proc.communicate()
- if re.search("MMDB_open", out):
- return
- raise Skip()
- except:
- raise Skip("libmaxminddb not detected")
t = Test(address=4, stress=False)
knot = t.server("knot")
t.link(zone, knot)
ModGeoip.check()
-check_mmdb()
-mod_geoip = ModGeoip(t.data_dir + "geo.conf", "geodb", t.data_dir + "db.mmdb", ["country/iso_code", "(id)city/geoname_id"])
+mod_geoip = ModGeoip(t.data_dir + "geo.conf", "geodb", t.data_dir + "db.mmdb",
+ ["country/iso_code", "(id)city/geoname_id"])
knot.add_module(zone, mod_geoip);
t.start()
class ModQueryacl(KnotModule):
'''Query ACL module'''
-
+
mod_name = "queryacl"
def __init__(self, address=None, interface=None):
def get_conf(self, conf=None):
if not conf:
conf = dnstest.config.KnotConf()
-
+
conf.begin(self.conf_name)
conf.id_item("id", self.conf_id)
if self.address:
self.geodb_file = geodb_file
self.geodb_key = geodb_key
+ @classmethod
+ def check(self):
+ '''Extended module check by libmaxminddb dependency check'''
+ super().check()
+
+ try:
+ proc = Popen(self._check_cmd(), stdout=PIPE, stderr=PIPE,
+ universal_newlines=True)
+ (out, err) = proc.communicate()
+ if re.search("MMDB_open", out):
+ return
+ raise Skip()
+ except:
+ raise Skip("Library 'maxminddb' not detected")
+
def get_conf(self, conf=None):
if not conf:
conf = dnstest.config.KnotConf()