More debugging for reg tests and getstr command
This commit is contained in:
parent
39059084ef
commit
0b20a05b19
|
@ -0,0 +1,33 @@
|
||||||
|
import main
|
||||||
|
|
||||||
|
from utils.get import getRelay
|
||||||
|
|
||||||
|
class GetstrCommand:
|
||||||
|
def __init__(self, *args):
|
||||||
|
self.getstr(*args)
|
||||||
|
|
||||||
|
def getstr(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
|
if authed:
|
||||||
|
if length == 3:
|
||||||
|
net = spl[1]
|
||||||
|
num = spl[2]
|
||||||
|
if not net in main.network.keys():
|
||||||
|
failure("Network does not exist: %s" % net)
|
||||||
|
return
|
||||||
|
if not num.isdigit():
|
||||||
|
failure("Must be a number, not %s" % num)
|
||||||
|
return
|
||||||
|
num = int(num)
|
||||||
|
alias = main.alias[num]["nick"].lower()
|
||||||
|
host, port = getRelay(num)
|
||||||
|
password = main.config["Relay"]["Password"]
|
||||||
|
connstr = f"/connect -ssl {host} {port}"
|
||||||
|
authstr = f"/quote PASS {alias}/{net}:{password}"
|
||||||
|
obj.send(connstr)
|
||||||
|
obj.send(authstr)
|
||||||
|
|
||||||
|
else:
|
||||||
|
incUsage("getstr")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
incUsage(None)
|
|
@ -33,5 +33,6 @@
|
||||||
"authcheck": "authcheck [<network>]",
|
"authcheck": "authcheck [<network>]",
|
||||||
"recheckauth": "recheckauth [<network>]",
|
"recheckauth": "recheckauth [<network>]",
|
||||||
"blacklist": "blacklist <network> <channel>",
|
"blacklist": "blacklist <network> <channel>",
|
||||||
"email": "email <add|del|list> [(domain)|<num>] [<email>]"
|
"email": "email <add|del|list> [(domain)|<num>] [<email>]",
|
||||||
|
"getstr": "getstr <net> <num>"
|
||||||
}
|
}
|
||||||
|
|
13
core/bot.py
13
core/bot.py
|
@ -480,6 +480,8 @@ class IRCBot(IRCClient):
|
||||||
chankeep.initialList(self.net, self.num, listinfo)
|
chankeep.initialList(self.net, self.num, listinfo)
|
||||||
|
|
||||||
def recheckList(self):
|
def recheckList(self):
|
||||||
|
if not main.config["ChanKeep"]["Enabled"]:
|
||||||
|
return
|
||||||
allRelays = chankeep.allRelaysActive(self.net)
|
allRelays = chankeep.allRelaysActive(self.net)
|
||||||
debug(f"recheckList() all relays for {self.net} {allRelays}")
|
debug(f"recheckList() all relays for {self.net} {allRelays}")
|
||||||
if allRelays:
|
if allRelays:
|
||||||
|
@ -526,10 +528,11 @@ class IRCBot(IRCClient):
|
||||||
if net_inst_chanlimit:
|
if net_inst_chanlimit:
|
||||||
if self.chanlimit > net_inst_chanlimit:
|
if self.chanlimit > net_inst_chanlimit:
|
||||||
self.chanlimit = net_inst_chanlimit
|
self.chanlimit = net_inst_chanlimit
|
||||||
warn(f"Chanlimit on {self.net} too high, setting to {self.chanlimit}")
|
# warn(f"Chanlimit on {self.net} too high, setting to {self.chanlimit}")
|
||||||
|
|
||||||
if not regproc.needToRegister(self.net): # if we need to register, only recheck on auth confirmation
|
if not regproc.needToRegister(self.net): # if we need to register, only recheck on auth confirmation
|
||||||
self.recheckList()
|
if main.config["ChanKeep"]["Enabled"]:
|
||||||
|
self.recheckList()
|
||||||
|
|
||||||
def seed_prefix(self, prefix):
|
def seed_prefix(self, prefix):
|
||||||
prefix = prefix.replace(")", "")
|
prefix = prefix.replace(")", "")
|
||||||
|
@ -618,6 +621,8 @@ class IRCBot(IRCClient):
|
||||||
def regPing(self, negativepass=None):
|
def regPing(self, negativepass=None):
|
||||||
if self.authenticated:
|
if self.authenticated:
|
||||||
return
|
return
|
||||||
|
if not regproc.needToRegister(self.net):
|
||||||
|
self.authenticated = True
|
||||||
sinst = regproc.substitute(self.net, self.num)
|
sinst = regproc.substitute(self.net, self.num)
|
||||||
if not sinst:
|
if not sinst:
|
||||||
error(f"regPing() {self.net}: registration ping failed for {self.num}")
|
error(f"regPing() {self.net}: registration ping failed for {self.num}")
|
||||||
|
@ -630,7 +635,7 @@ class IRCBot(IRCClient):
|
||||||
if negativepass is True:
|
if negativepass is True:
|
||||||
if self._negativePass is None:
|
if self._negativePass is None:
|
||||||
self._negativePass = True
|
self._negativePass = True
|
||||||
debug(f"regPing() {self.net}: positive registration check - {self.num}")
|
debug(f"regPing() {self.net}: negpass:True positive registration check - {self.num}")
|
||||||
if sinst["ping"]:
|
if sinst["ping"]:
|
||||||
debug("Sending ping - %s - %i" % (self.net, self.num))
|
debug("Sending ping - %s - %i" % (self.net, self.num))
|
||||||
self.msg(sinst["entity"], sinst["pingmsg"])
|
self.msg(sinst["entity"], sinst["pingmsg"])
|
||||||
|
@ -644,11 +649,13 @@ class IRCBot(IRCClient):
|
||||||
if sinst["negative"]:
|
if sinst["negative"]:
|
||||||
self._negativePass = None
|
self._negativePass = None
|
||||||
self.msg(sinst["entity"], sinst["negativemsg"])
|
self.msg(sinst["entity"], sinst["negativemsg"])
|
||||||
|
debug(f"regPing() {self.net}: sent negativemsg '{sinst['negativemsg']}' to {sinst['entity']} - {self.num}")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self._negativePass = True
|
self._negativePass = True
|
||||||
if sinst["ping"]:
|
if sinst["ping"]:
|
||||||
self.msg(sinst["entity"], sinst["pingmsg"])
|
self.msg(sinst["entity"], sinst["pingmsg"])
|
||||||
|
debug(f"regPing() {self.net}: sent ping '{sinst['pingmsg']}' to {sinst['entity']} - {self.num}")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.authenticated = True
|
self.authenticated = True
|
||||||
|
|
|
@ -16,7 +16,7 @@ def getEnabledRelays(net):
|
||||||
:return: list of enabled relay numbers
|
:return: list of enabled relay numbers
|
||||||
"""
|
"""
|
||||||
enabledRelays = [x for x in main.network[net].relays.keys() if main.network[net].relays[x]["enabled"]]
|
enabledRelays = [x for x in main.network[net].relays.keys() if main.network[net].relays[x]["enabled"]]
|
||||||
debug(f"getEnabledRelays() {net}: {enabledRelays}")
|
# debug(f"getEnabledRelays() {net}: {enabledRelays}")
|
||||||
return enabledRelays
|
return enabledRelays
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ def getConnectedRelays(net):
|
||||||
if name in main.IRCPool.keys():
|
if name in main.IRCPool.keys():
|
||||||
if main.IRCPool[name].isconnected:
|
if main.IRCPool[name].isconnected:
|
||||||
connectedRelays.append(i)
|
connectedRelays.append(i)
|
||||||
debug(f"getConnectedRelays() {net}: {connectedRelays}")
|
# debug(f"getConnectedRelays() {net}: {connectedRelays}")
|
||||||
return connectedRelays
|
return connectedRelays
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,15 +50,15 @@ def getActiveRelays(net):
|
||||||
for i in enabledRelays:
|
for i in enabledRelays:
|
||||||
name = net + str(i)
|
name = net + str(i)
|
||||||
if name in main.IRCPool.keys():
|
if name in main.IRCPool.keys():
|
||||||
debug(
|
# debug(
|
||||||
(
|
# (
|
||||||
f"getActiveRelays() {net}: {i} auth:{main.IRCPool[name].authenticated} "
|
# f"getActiveRelays() {net}: {i} auth:{main.IRCPool[name].authenticated} "
|
||||||
f"conn:{main.IRCPool[name].isconnected}"
|
# f"conn:{main.IRCPool[name].isconnected}"
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
if main.IRCPool[name].authenticated and main.IRCPool[name].isconnected:
|
if main.IRCPool[name].authenticated and main.IRCPool[name].isconnected:
|
||||||
activeRelays.append(i)
|
activeRelays.append(i)
|
||||||
debug(f"getActiveRelays() {net}: {activeRelays}")
|
# debug(f"getActiveRelays() {net}: {activeRelays}")
|
||||||
return activeRelays
|
return activeRelays
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ def allRelaysActive(net):
|
||||||
activeRelays = getActiveRelays(net)
|
activeRelays = getActiveRelays(net)
|
||||||
enabledRelays = getEnabledRelays(net)
|
enabledRelays = getEnabledRelays(net)
|
||||||
relaysActive = len(activeRelays) == len(enabledRelays)
|
relaysActive = len(activeRelays) == len(enabledRelays)
|
||||||
debug(f"allRelaysActive() {net}: {relaysActive} ({activeRelays}/{enabledRelays})")
|
# debug(f"allRelaysActive() {net}: {relaysActive} ({activeRelays}/{enabledRelays})")
|
||||||
return relaysActive
|
return relaysActive
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,16 @@ def get_first_relay(net):
|
||||||
"""
|
"""
|
||||||
cur_relay = 0
|
cur_relay = 0
|
||||||
max_relay = len(main.network[net].relays.keys()) + 1
|
max_relay = len(main.network[net].relays.keys()) + 1
|
||||||
debug(f"get_first_relay() {net}: max_relay:{max_relay}")
|
# debug(f"get_first_relay() {net}: max_relay:{max_relay}")
|
||||||
activeRelays = chankeep.getActiveRelays(net)
|
activeRelays = chankeep.getActiveRelays(net)
|
||||||
debug(f"get_first_relay() {net}: activeRelays:{activeRelays}")
|
# debug(f"get_first_relay() {net}: activeRelays:{activeRelays}")
|
||||||
while cur_relay != max_relay:
|
while cur_relay != max_relay:
|
||||||
cur_relay += 1
|
cur_relay += 1
|
||||||
if cur_relay not in activeRelays:
|
if cur_relay not in activeRelays:
|
||||||
continue
|
continue
|
||||||
name = net + str(cur_relay)
|
name = net + str(cur_relay)
|
||||||
if name in main.IRCPool.keys():
|
if name in main.IRCPool.keys():
|
||||||
debug(f"get_first_relay() {net}: found relay {name}")
|
# debug(f"get_first_relay() {net}: found relay {name}")
|
||||||
return main.IRCPool[name]
|
return main.IRCPool[name]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,8 @@ def get_unregistered_relays(net=None):
|
||||||
def registerTest(c):
|
def registerTest(c):
|
||||||
sinst = substitute(c["net"], c["num"])
|
sinst = substitute(c["net"], c["num"])
|
||||||
name = c["net"] + str(c["num"])
|
name = c["net"] + str(c["num"])
|
||||||
|
net = c["net"]
|
||||||
|
num = c["num"]
|
||||||
if sinst["check"] is False:
|
if sinst["check"] is False:
|
||||||
return
|
return
|
||||||
if "msg" in c.keys() and not c["msg"] is None:
|
if "msg" in c.keys() and not c["msg"] is None:
|
||||||
|
@ -157,24 +159,28 @@ def registerTest(c):
|
||||||
confirmRegistration(
|
confirmRegistration(
|
||||||
c["net"], c["num"], negativepass=False
|
c["net"], c["num"], negativepass=False
|
||||||
) # Not passed negative check, report back
|
) # Not passed negative check, report back
|
||||||
|
debug(f"registerTest() {net} - {num} not passed negative:checknegativemsg check, {sinst['checknegativemsg']} present in message")
|
||||||
return
|
return
|
||||||
if sinst["checkendnegative"] in c["msg"]:
|
if sinst["checkendnegative"] in c["msg"]:
|
||||||
confirmRegistration(
|
confirmRegistration(
|
||||||
c["net"], c["num"], negativepass=True
|
c["net"], c["num"], negativepass=True
|
||||||
) # Passed the negative check, report back
|
) # Passed the negative check, report back
|
||||||
|
debug(f"registerTest() {net} - {num} passed negative:checkendnegative check, {sinst['checkendnegative']} present in message")
|
||||||
return
|
return
|
||||||
if sinst["ping"]:
|
if sinst["ping"]:
|
||||||
if sinst["checkmsg2"] in c["msg"] and c["nick"] == sinst["entity"]:
|
if sinst["checkmsg2"] in c["msg"] and c["nick"] == sinst["entity"]:
|
||||||
confirmRegistration(c["net"], c["num"])
|
confirmRegistration(c["net"], c["num"])
|
||||||
|
debug(f"registerTest() {net} - {num} passed ping:checkmsg2 check, {sinst['checkmsg2']} present in message")
|
||||||
return
|
return
|
||||||
if sinst["checktype"] == "msg":
|
if sinst["checktype"] == "msg":
|
||||||
if "msg" in c.keys():
|
|
||||||
if sinst["checkmsg"] in c["msg"]:
|
if sinst["checkmsg"] in c["msg"]:
|
||||||
confirmRegistration(c["net"], c["num"])
|
confirmRegistration(c["net"], c["num"])
|
||||||
|
debug(f"registerTest() {net} - {num} passed checktype:msg:checkmsg check, {sinst['checkmsg']} present in message")
|
||||||
return
|
return
|
||||||
elif sinst["checktype"] == "mode":
|
elif sinst["checktype"] == "mode":
|
||||||
if c["type"] == "self":
|
if c["type"] == "self":
|
||||||
if c["mtype"] == "mode":
|
if c["mtype"] == "mode":
|
||||||
if sinst["checkmode"] in c["mode"] and c["status"] is True:
|
if sinst["checkmode"] in c["mode"] and c["status"] is True:
|
||||||
confirmRegistration(c["net"], c["num"])
|
confirmRegistration(c["net"], c["num"])
|
||||||
|
debug(f"registerTest() {net} - {num} passed checktype:mode:checkmost check, {sinst['checkmode']} present in mode")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue