Compare commits
4 Commits
f6b887eda9
...
2b0207d12b
Author | SHA1 | Date | |
---|---|---|---|
2b0207d12b | |||
58f1e22dde | |||
3ba723b111 | |||
4d13d704dc |
51
config.py
51
config.py
@ -104,20 +104,10 @@ conf.registerGlobalValue(
|
|||||||
# REDIS related settings below:
|
# REDIS related settings below:
|
||||||
###
|
###
|
||||||
conf.registerGroup(SnoParser, "redis")
|
conf.registerGroup(SnoParser, "redis")
|
||||||
|
conf.registerGroup(SnoParser.redis, "db")
|
||||||
conf.registerGlobalValue(
|
conf.registerGlobalValue(
|
||||||
SnoParser.redis,
|
SnoParser.redis.db,
|
||||||
"db1",
|
"ips",
|
||||||
registry.Integer(
|
|
||||||
1,
|
|
||||||
"""
|
|
||||||
Redis: Database number for counting of NICKNAMES.
|
|
||||||
""",
|
|
||||||
private=True,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
conf.registerGlobalValue(
|
|
||||||
SnoParser.redis,
|
|
||||||
"db2",
|
|
||||||
registry.Integer(
|
registry.Integer(
|
||||||
2,
|
2,
|
||||||
"""
|
"""
|
||||||
@ -126,11 +116,33 @@ conf.registerGlobalValue(
|
|||||||
private=True,
|
private=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
conf.registerGlobalValue(
|
||||||
|
SnoParser.redis.db,
|
||||||
|
"nicks",
|
||||||
|
registry.Integer(
|
||||||
|
1,
|
||||||
|
"""
|
||||||
|
Redis: Database number for counting of NICKNAMES.
|
||||||
|
""",
|
||||||
|
private=True,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
conf.registerGlobalValue(
|
||||||
|
SnoParser.redis.db,
|
||||||
|
"whois",
|
||||||
|
registry.Integer(
|
||||||
|
0,
|
||||||
|
"""
|
||||||
|
Redis: Database number for WHOIS query caching.
|
||||||
|
""",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
conf.registerGlobalValue(
|
conf.registerGlobalValue(
|
||||||
SnoParser.redis,
|
SnoParser.redis,
|
||||||
"host",
|
"host",
|
||||||
registry.String(
|
registry.String(
|
||||||
"127.0.0.1",
|
"localhost",
|
||||||
"""
|
"""
|
||||||
Redis: IP address or hostname.
|
Redis: IP address or hostname.
|
||||||
""",
|
""",
|
||||||
@ -218,16 +230,5 @@ conf.registerGlobalValue(
|
|||||||
private=True,
|
private=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
conf.registerGroup(SnoParser.whois, "redis")
|
|
||||||
conf.registerGlobalValue(
|
|
||||||
SnoParser.whois.redis,
|
|
||||||
"db",
|
|
||||||
registry.Integer(
|
|
||||||
0,
|
|
||||||
"""
|
|
||||||
Redis: Database number for WHOIS query caching.
|
|
||||||
""",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||||
|
14
plugin.py
14
plugin.py
@ -183,7 +183,7 @@ class SnoParser(callbacks.Plugin):
|
|||||||
def ip_run(self, ipaddress: str) -> dict:
|
def ip_run(self, ipaddress: str) -> dict:
|
||||||
"""Tracks IP addresses"""
|
"""Tracks IP addresses"""
|
||||||
|
|
||||||
data = self._get_from_cache("ips", ipaddresses)
|
data = self._get_from_cache("ips", ipaddress)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
if self.registryValue("debug"):
|
if self.registryValue("debug"):
|
||||||
print("SNOPARSER DEBUG - IP_RUN, SEEN: TRUE")
|
print("SNOPARSER DEBUG - IP_RUN, SEEN: TRUE")
|
||||||
@ -212,13 +212,15 @@ class SnoParser(callbacks.Plugin):
|
|||||||
Queries the cache for an address.
|
Queries the cache for an address.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
data = self.redis_clients['whois'].get(sourceip)
|
data = self.redis_clients['whois'].get(ipaddress)
|
||||||
decoded_data = data.decode("utf-8")
|
if data is not None:
|
||||||
|
data = data.decode("utf-8")
|
||||||
ttl = self.redis_clients['whois'].ttl(ipaddress)
|
ttl = self.redis_clients['whois'].ttl(ipaddress)
|
||||||
count = self.redis_clients['ips'].get(ipaddress)
|
count = self.redis_clients['ips'].get(ipaddress)
|
||||||
decoded_count = count.decode("utf-8")
|
if count is not None:
|
||||||
|
count = count.decode("utf-8")
|
||||||
print("SnoParser manual query: ", data, " ", ttl)
|
print("SnoParser manual query: ", data, " ", ttl)
|
||||||
irc.reply(f"{decoded_data} - Count: {decoded_count} - Remaining: {ttl}s")
|
irc.reply(f"{data} - Count: {count} - Remaining: {ttl}s")
|
||||||
|
|
||||||
ipquery = wrap(ipquery, ["ip"])
|
ipquery = wrap(ipquery, ["ip"])
|
||||||
|
|
||||||
@ -386,7 +388,7 @@ class SnoParser(callbacks.Plugin):
|
|||||||
self._sendSnotice(irc, msg, repl)
|
self._sendSnotice(irc, msg, repl)
|
||||||
|
|
||||||
if "OPER" in text and "Client opered up" in text:
|
if "OPER" in text and "Client opered up" in text:
|
||||||
operregex = "^-OPER- Client opered up \[(.*)\, \ (.*)\]$"
|
operregex = "^-OPER- Client opered up \[(.*), (.*)\]$"
|
||||||
couple = re.match(operregex, text)
|
couple = re.match(operregex, text)
|
||||||
hostmask = couple.group(1)
|
hostmask = couple.group(1)
|
||||||
oper = couple.group(2)
|
oper = couple.group(2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user