chg: [pdns-import] clean-up

pull/3/head v0.1
Alexandre Dulaunoy 2019-04-05 09:35:20 +02:00
parent 389b034893
commit 771718b7f7
No known key found for this signature in database
GPG Key ID: 09E2CD4944E6CBCD
1 changed files with 44 additions and 48 deletions

View File

@ -62,7 +62,6 @@ stats = True
for v in rtype:
dnstype[(v['type'])] = v['value']
while (True):
expiration = None
if not (args.filetoimport):
parser.print_help()
@ -71,9 +70,6 @@ while (True):
records = json.load(dnsimport)
print (records)
if records is False:
logger.debug('Parsing of passive DNS line failed: {}'.format(l.strip()))
continue
for rdns in records:
logger.debug("parsed record: {}".format(r))
if 'rrname' not in rdns:
@ -96,7 +92,7 @@ while (True):
r.sadd(query, rdns['v'])
res = "v:{}:{}".format(rdns['v'], rdns['type'])
logger.debug('redis sadd: {} -> {}'.format(res,rdns['rrname']))
r.sadd(res, rdns['q'])
r.sadd(res, rdns['rrname'])
firstseen = "s:{}:{}:{}".format(rdns['rrname'], rdns['v'], rdns['type'])
if not r.exists(firstseen):
@ -106,7 +102,7 @@ while (True):
lastseen = "l:{}:{}:{}".format(rdns['rrname'], rdns['v'], rdns['type'])
last = r.get(lastseen)
if last is None or int(last) < int(rdns['timestamp']):
if last is None or int(last) < int(rdns['time_last']):
r.set(lastseen, rdns['time_last'])
logger.debug('redis set: {} -> {}'.format(lastseen, rdns['time_last']))