mirror of
https://github.com/adulau/ptr-db.git
synced 2024-12-22 08:45:58 +00:00
37 lines
974 B
Python
37 lines
974 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
#
|
|
# Tool to import and index PTR records
|
|
#
|
|
# Software is free software released under the "Modified BSD license"
|
|
#
|
|
# Copyright (c) 2013-2014 Alexandre Dulaunoy - a@foo.be
|
|
|
|
import redis
|
|
import argparse
|
|
|
|
argParser = argparse.ArgumentParser(description='ptr-db: Import and Index PTR records')
|
|
argParser.add_argument('-r', action='append', help='Input file in IP,PTR format')
|
|
args = argParser.parse_args()
|
|
|
|
def terms(host=None):
|
|
if host is None:
|
|
return False
|
|
p = host.split('.')
|
|
return p
|
|
|
|
# LevelDB backend using Redis protocol https://github.com/KDr2/redis-leveldb
|
|
r = redis.StrictRedis(host='localhost', port=8323)
|
|
|
|
if args.r:
|
|
for x in args.r:
|
|
with open(x) as f:
|
|
for l in f:
|
|
(ip, ptr) = l.rstrip().split(',')
|
|
print (terms(ptr))
|
|
r.set(ip,ptr)
|
|
else:
|
|
argParser.print_help()
|
|
exit(1)
|
|
#r.set("foo", "bar")
|
|
print (r.get("74.15.53.16"))
|