def main(): args = parse_args() splitter = dnssplitter.DNSSplitter() splitter.init_tree(0) splitter.split_fsdb(args.input_file, args.output_file, args.name_keys)
def main(): args = parse_args() splitter = dnssplitter.DNSSplitter() splitter.init_tree(0) for name in args.dns_names: results = splitter.search_tree(name) print(name + ":") if results: print(" Prefix: " + results[0]) print(" Domain: " + results[1]) print(" Reg Point: " + results[2]) else: print( " Error: failed to break the domain down (not a real name?)")
def test_fsdb_splitter(self): import dnssplitter psl = dnssplitter.DNSSplitter() input_stream = io.StringIO( "#fsdb -F t one two\nwww.example.com\t2\nabc.def.example.co.uk\t1\naoeu.bogusss\t3\n" ) output_stream = io.StringIO() output_stream.close = noop psl.split_fsdb(input_stream, output_stream, ['one']) self.assertEqual( output_stream.getvalue(), "#fsdb -F t one two one_prefix one_domain one_suffix\nwww.example.com\t2\twww\texample.com\tcom\nabc.def.example.co.uk\t1\tabc.def\texample.co.uk\tco.uk\naoeu.bogusss\t3\t\t\t\n# | setup.py test\n", "output headers are correct")
def checkPublicSuffix(self, domain, expected_output): global psl if not psl: import dnssplitter psl = dnssplitter.DNSSplitter() #psl.load_psl_file('/home/hardaker/src/public-suffix-list/public_suffix_list.dat') if not domain: return None results = psl.search_tree(domain) if not results: teststr = ("domain of %s correctly should be '%s'; got: '%s'" % (domain, expected_output, None)) self.assertEqual(expected_output, results, teststr) else: teststr = ("domain of %s correctly should be '%s'; got: '%s'" % (domain, expected_output, results[1])) if results[1] == '': results[ 1] = None # we return an empty string for an exact TLD match self.assertEqual(expected_output, results[1], teststr)
def __init__(self, conf, search_index, dataset, is_binary, loader=None): super().__init__(conf, search_index, dataset, is_binary, loader) self._splitter = dnssplitter.DNSSplitter() self._splitter.init_tree()