mirror of
https://github.com/adulau/ptr-db.git
synced 2024-12-22 00:35:57 +00:00
Initial import of ptr-db
This commit is contained in:
commit
49954da366
2 changed files with 48 additions and 0 deletions
11
README.md
Normal file
11
README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
ptr-db - PTR DNS records database
|
||||
=================================
|
||||
|
||||
A ptr-db is a database to store, index and lookup large set of PTR DNS records.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
- Python 3
|
||||
- Python [redis](https://pypi.python.org/pypi/redis/) client
|
||||
- Redis [LevelDB server](https://github.com/KDr2/redis-leveldb)
|
37
bin/ptr-import.py
Normal file
37
bin/ptr-import.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/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"))
|
Loading…
Reference in a new issue