Improved ipcounting
Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
parent
78161bda7f
commit
c5a37126bc
Binary file not shown.
Binary file not shown.
@ -140,6 +140,13 @@ conf.registerGlobalValue(SnoParser.whois, 'sample',
|
|||||||
"""
|
"""
|
||||||
, private=True
|
, private=True
|
||||||
))
|
))
|
||||||
|
conf.registerGlobalValue(SnoParser.whois, 'ttl',
|
||||||
|
registry.Integer('3600',
|
||||||
|
"""
|
||||||
|
SnoParser: How long to cache WHOIS entries for.
|
||||||
|
"""
|
||||||
|
, private=True
|
||||||
|
))
|
||||||
conf.registerGroup(SnoParser.whois, 'redis')
|
conf.registerGroup(SnoParser.whois, 'redis')
|
||||||
conf.registerGlobalValue(SnoParser.whois.redis, 'db',
|
conf.registerGlobalValue(SnoParser.whois.redis, 'db',
|
||||||
registry.Integer('0',
|
registry.Integer('0',
|
||||||
|
@ -141,7 +141,8 @@ class SnoParser(callbacks.Plugin):
|
|||||||
def whois_set_cache(self, key: str, value: str) -> bool:
|
def whois_set_cache(self, key: str, value: str) -> bool:
|
||||||
"""Data to Redis."""
|
"""Data to Redis."""
|
||||||
|
|
||||||
state = self.redis_client_whois.setex(key, timedelta(seconds=3600), value=value,)
|
duration = self.registryValue('whois.ttl')
|
||||||
|
state = self.redis_client_whois.setex(key, timedelta(seconds=duration), value=value,)
|
||||||
return state
|
return state
|
||||||
|
|
||||||
def whois_run(self, sourceip: str) -> dict:
|
def whois_run(self, sourceip: str) -> dict:
|
||||||
@ -238,12 +239,13 @@ class SnoParser(callbacks.Plugin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
data = self.whois_get_cache(key=ipaddress)
|
data = self.whois_get_cache(key=ipaddress)
|
||||||
decoded = data.decode('utf-8')
|
decoded_data = data.decode('utf-8')
|
||||||
ttl = self.redis_client_whois.ttl(ipaddress)
|
ttl = self.redis_client_whois.ttl(ipaddress)
|
||||||
count = self.redis_client_ips.get(ipaddress)
|
count = self.redis_client_ips.get(ipaddress)
|
||||||
|
decoded_count = count.decode('utf-8')
|
||||||
|
|
||||||
print('SnoParser manual query: ', data, ' ', ttl)
|
print('SnoParser manual query: ', data, ' ', ttl)
|
||||||
irc.reply(f'{decoded} - Count: {count} - Remaining: {ttl}s')
|
irc.reply(f'{decoded_data} - Count: {decoded_count} - Remaining: {ttl}s')
|
||||||
|
|
||||||
ipquery = wrap(ipquery, ['anything'])
|
ipquery = wrap(ipquery, ['anything'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user