mirror of
https://github.com/adulau/DomainClassifier.git
synced 2024-11-07 11:56:25 +00:00
fix: [DomClassifier] fix redis cache
This commit is contained in:
parent
6c9d8b5350
commit
1aa700642e
1 changed files with 35 additions and 35 deletions
|
@ -217,45 +217,45 @@ class Extract:
|
||||||
self.vdomain.append(out)
|
self.vdomain.append(out)
|
||||||
else:
|
else:
|
||||||
self.vdomain.add(out)
|
self.vdomain.add(out)
|
||||||
else:
|
continue
|
||||||
|
|
||||||
for dnstype in rtype:
|
for dnstype in rtype:
|
||||||
try:
|
try:
|
||||||
answers = self.presolver.query(domain, dnstype)
|
answers = self.presolver.query(domain, dnstype)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# Passive DNS output
|
# Passive DNS output
|
||||||
# timestamp||dns-client ||dns-server||RR class||Query||Query Type||Answer||TTL||Count
|
# timestamp||dns-client ||dns-server||RR class||Query||Query Type||Answer||TTL||Count
|
||||||
if passive_dns:
|
if passive_dns:
|
||||||
rrset = answers.rrset.to_text().splitlines()
|
rrset = answers.rrset.to_text().splitlines()
|
||||||
for dns_resp in rrset:
|
for dns_resp in rrset:
|
||||||
dns_resp = dns_resp.split()
|
dns_resp = dns_resp.split()
|
||||||
passive_dns_out = (
|
passive_dns_out = (
|
||||||
'{}||127.0.0.1||{}||{}||{}||{}||{}||{}||1\n'.format(
|
'{}||127.0.0.1||{}||{}||{}||{}||{}||{}||1\n'.format(
|
||||||
time.time(),
|
time.time(),
|
||||||
self.presolver.nameservers[0],
|
self.presolver.nameservers[0],
|
||||||
dns_resp[2],
|
dns_resp[2],
|
||||||
domain,
|
domain,
|
||||||
dnstype,
|
dnstype,
|
||||||
dns_resp[4],
|
dns_resp[4],
|
||||||
answers.ttl,
|
answers.ttl,
|
||||||
)
|
|
||||||
)
|
)
|
||||||
self.vdomain.add((passive_dns_out))
|
)
|
||||||
if self.redis:
|
self.vdomain.add((passive_dns_out))
|
||||||
self.redis.sadd('dom_class:cache:{}'.format(domain), passive_dns_out)
|
|
||||||
self.redis.expire('dom_class:cache:{}'.format(domain), self.expire_time)
|
|
||||||
elif extended:
|
|
||||||
self.vdomain.append((domain, dnstype, answers[0]))
|
|
||||||
if self.redis:
|
if self.redis:
|
||||||
self.redis.sadd('dom_class:cache:{}'.format(domain), '{}[^]{}[^]{}'.format(domain, dnstype, answers[0]))
|
self.redis.sadd('dom_class:cache:{}'.format(domain), passive_dns_out)
|
||||||
self.redis.expire('dom_class:cache:{}'.format(domain), self.expire_time)
|
|
||||||
else:
|
|
||||||
self.vdomain.add((domain))
|
|
||||||
if self.redis:
|
|
||||||
self.redis.sadd('dom_class:cache:{}'.format(domain), domain)
|
|
||||||
self.redis.expire('dom_class:cache:{}'.format(domain), self.expire_time)
|
self.redis.expire('dom_class:cache:{}'.format(domain), self.expire_time)
|
||||||
|
elif extended:
|
||||||
|
self.vdomain.append((domain, dnstype, answers[0]))
|
||||||
|
if self.redis:
|
||||||
|
self.redis.sadd('dom_class:cache:{}'.format(domain), '{}[^]{}[^]{}'.format(domain, dnstype, answers[0]))
|
||||||
|
self.redis.expire('dom_class:cache:{}'.format(domain), self.expire_time)
|
||||||
|
else:
|
||||||
|
self.vdomain.add((domain))
|
||||||
|
if self.redis:
|
||||||
|
self.redis.sadd('dom_class:cache:{}'.format(domain), domain)
|
||||||
|
self.redis.expire('dom_class:cache:{}'.format(domain), self.expire_time)
|
||||||
return self.vdomain
|
return self.vdomain
|
||||||
|
|
||||||
"""ipaddress method extracts from the domain list the valid IPv4 addresses"""
|
"""ipaddress method extracts from the domain list the valid IPv4 addresses"""
|
||||||
|
|
Loading…
Reference in a new issue