Improved debug and manual query
Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
parent
a458460cec
commit
708e4b7075
Binary file not shown.
33
plugin.py
33
plugin.py
@ -81,11 +81,12 @@ class SnoParser(callbacks.Plugin):
|
|||||||
whois = IPWhois(sourceip)
|
whois = IPWhois(sourceip)
|
||||||
whoisres = whois.lookup_rdap(depth=1,retry_count=0)
|
whoisres = whois.lookup_rdap(depth=1,retry_count=0)
|
||||||
results = whoisres
|
results = whoisres
|
||||||
|
if self.registryValue('whois.debug'):
|
||||||
print(results)
|
print(results)
|
||||||
asn = whoisres['asn_registry']
|
asn = whoisres['asn_registry']
|
||||||
country = whoisres['asn_country_code']
|
country = whoisres['asn_country_code']
|
||||||
description = whoisres['asn_description']
|
description = whoisres['asn_description']
|
||||||
whoisout = '# ' + asn + ' ' + country + ' ' + description
|
whoisout = asn + ' ' + country + ' ' + description
|
||||||
except ipwhois.exceptions.IPDefinedError:
|
except ipwhois.exceptions.IPDefinedError:
|
||||||
whoisout = 'RFC 4291 (Local)'
|
whoisout = 'RFC 4291 (Local)'
|
||||||
|
|
||||||
@ -114,29 +115,29 @@ class SnoParser(callbacks.Plugin):
|
|||||||
data = self.whois_get_cache(key=sourceip)
|
data = self.whois_get_cache(key=sourceip)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
#data["cache"] = True
|
if self.registryValue('whois.debug'):
|
||||||
print("DEBUG - CACHE: TRUE")
|
print("SNOPARSER DEBUG - WHOIS_RUN WITH CACHE: TRUE")
|
||||||
print(data)
|
print(data)
|
||||||
print(sourceip)
|
print(sourceip)
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
data = self.whois_fresh(sourceip)
|
data = self.whois_fresh(sourceip)
|
||||||
print("DEBUG - ELSE WHOIS_FRESH CALLED")
|
if self.registryValue('whois.debug'):
|
||||||
|
print("SNOPARSER DEBUG - WHOIS_RUN WITH CACHE: FALSE")
|
||||||
print(data)
|
print(data)
|
||||||
print(sourceip)
|
print(sourceip)
|
||||||
if data.startswith("#"):
|
if data.startswith:
|
||||||
#data["cache"] = False
|
if self.registryValue('whois.debug'):
|
||||||
print("DEBUG - CACHE: FALSE")
|
print("SNOPARSER DEBUG - WHOIS_RUN WITH CACHE: FALSE AND CORRECT STARTING CHARACTER")
|
||||||
|
print(data)
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
state = self.whois_set_cache(key=sourceip, value=data)
|
state = self.whois_set_cache(key=sourceip, value=data)
|
||||||
|
|
||||||
print(data)
|
|
||||||
print(sourceip)
|
|
||||||
|
|
||||||
if state is True:
|
if state is True:
|
||||||
return json.loads(data)
|
return json.loads(data)
|
||||||
else:
|
else:
|
||||||
print("Data does not start with correct string")
|
if self.registryValue('whois.debug'):
|
||||||
|
print("SNOPARSER DEBUG _ WHOIS_RUN WITH CACHE: FALSE AND WRONG STARTING CHARACTER")
|
||||||
print(data)
|
print(data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -146,11 +147,11 @@ class SnoParser(callbacks.Plugin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
data = self.whois_get_cache(key=ipaddress)
|
data = self.whois_get_cache(key=ipaddress)
|
||||||
ttl = self.redis_client.get(ipaddress)
|
decoded = data.decode('utf-8')
|
||||||
|
ttl = self.redis_client.ttl(ipaddress)
|
||||||
|
|
||||||
print(data, ' ', ttl)
|
print('SnoParser manual query: ', data, ' ', ttl)
|
||||||
#irc.reply(str(data), ' Remaining: ', int(ttl), 's')
|
irc.reply(f'{decoded} - Remaining: {ttl}s')
|
||||||
irc.reply(data, ttl)
|
|
||||||
|
|
||||||
query = wrap(query, ['anything'])
|
query = wrap(query, ['anything'])
|
||||||
|
|
||||||
@ -174,8 +175,6 @@ class SnoParser(callbacks.Plugin):
|
|||||||
realname = couple.group(5)
|
realname = couple.group(5)
|
||||||
ip_seen = 0
|
ip_seen = 0
|
||||||
nick_seen = 0
|
nick_seen = 0
|
||||||
asn = 0
|
|
||||||
subnet = ''
|
|
||||||
|
|
||||||
whoisout = self.whois_run(sourceip=ip)
|
whoisout = self.whois_run(sourceip=ip)
|
||||||
DictFromSnotice = {'notice': 'connect', 'nickname': nickname, 'username': username, 'host': host, 'ip': ip, 'realname': realname, 'ipCount': ip_seen, 'nickCount': nick_seen}
|
DictFromSnotice = {'notice': 'connect', 'nickname': nickname, 'username': username, 'host': host, 'ip': ip, 'realname': realname, 'ipCount': ip_seen, 'nickCount': nick_seen}
|
||||||
|
Loading…
Reference in New Issue
Block a user