Fixes to auth detection and message parsing

* don't check authentication if the network doesn't need to
  register
* don't pass through muser for ZNC type messages
* avoid duplicate message for queries containing highlights
* make a copy of the cast for metadata analysis to avoid poisoning it
* set up callback for when the instance is authenticated, so we can
  request a LIST immediately if so desired
* separate out seeding functions to populate CHANLIMIT to ease future
  work involving other options, such as PREFIX
This commit is contained in:
2020-06-07 17:26:53 +01:00
parent 2a9869d0f9
commit 3acf182171
5 changed files with 116 additions and 85 deletions

View File

@@ -12,7 +12,7 @@ def allRelaysActive(net):
for i in main.network[net].relays.keys():
name = net+str(i)
if name in main.IRCPool.keys():
if main.IRCPool[name].authenticated and main.network[net].relays[i]["registered"]:
if main.IRCPool[name].authenticated:
existNum += 1
if existNum == relayNum:
return True

View File

@@ -11,13 +11,9 @@ order = ["type", "net", "num", "channel", "msg", "nick",
"ident", "host", "mtype", "user", "mode", "modearg",
"realname", "server", "status", "time"]
def event(numName, c): # yes I'm using a short variable because otherwise it goes off the screen
def parsemeta(numName, c):
if not "channel" in c.keys():
c["channel"] = None
if dedup(numName, c):
return
regproc.registerTest(c)
# metadata scraping
# need to check if this was received from a relay
# in which case, do not do this
@@ -39,7 +35,13 @@ def event(numName, c): # yes I'm using a short variable because otherwise it goe
if c["mtype"] == "nick":
userinfo.renameUser(c["net"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"])
def event(numName, c): # yes I'm using a short variable because otherwise it goes off the screen
if dedup(numName, c):
return
# make a copy of the object with dict() to prevent sending notifications with channel of None
parsemeta(numName, dict(c))
if "muser" in c.keys():
del c["muser"]
sendRelayNotification({k: c[k] for k in order if k in c}) # Sort dict keys according to order

View File

@@ -3,6 +3,7 @@ import json
from modules import alias
from modules.chankeep import nukeNetwork
from modules.regproc import needToRegister
from twisted.internet import reactor
from core.bot import IRCBot, IRCBotFactory
import main
@@ -28,13 +29,10 @@ class Network:
elif num == self.last:
self.last += 1
registered = False
if self.net in main.irc.keys():
if "register" in main.irc[self.net].keys():
if not main.irc[self.net]["register"]:
registered = True
# Don't need to register if it's been disabled in definitions,
# so we'll pretend we already did
if not needToRegister(self.net):
registered = True
# Don't need to register if it's been disabled in definitions,
# so we'll pretend we already did
self.relays[num] = {
"enabled": main.config["ConnectOnCreate"],
"net": self.net,

View File

@@ -4,6 +4,14 @@ from utils.logging.log import *
from utils.logging.debug import *
from copy import deepcopy
def needToRegister(net):
inst = selectInst(net)
if "register" in inst.keys():
if inst["register"]:
return True
else:
return False
def selectInst(net):
if net in main.irc.keys():
inst = deepcopy(main.irc[net])
@@ -48,6 +56,7 @@ def confirmRegistration(net, num):
if name in main.IRCPool.keys():
debug("Relay authenticated: %s - %i" %(net, num))
main.IRCPool[name].authenticated = True
main.IRCPool[name].recheckList()
if obj.relays[num]["registered"]:
return
if name in main.IRCPool.keys():
@@ -78,7 +87,8 @@ def registerTest(c):
confirmRegistration(c["net"], c["num"])
return
elif inst["checktype"] == "mode":
if c["type"] == "mode":
if inst["checkmode"] in c["modes"] and c["status"] == True:
confirmRegistration(c["net"], c["num"])
return
if c["type"] == "self":
if c["mtype"] == "mode":
if inst["checkmode"] in c["mode"] and c["status"] == True:
confirmRegistration(c["net"], c["num"])
return