Implement authentication detection
* pending command to see which instances have never authenticated * authcheck command to see which instances are not currently authenticated
This commit is contained in:
@@ -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].isconnected and main.network[net].relays[i]["registered"]:
|
||||
if main.IRCPool[name].authenticated and main.network[net].relays[i]["registered"]:
|
||||
existNum += 1
|
||||
if existNum == relayNum:
|
||||
return True
|
||||
|
||||
@@ -5,6 +5,7 @@ from datetime import datetime
|
||||
import main
|
||||
from core.relay import sendRelayNotification
|
||||
from modules import userinfo
|
||||
from modules import regproc
|
||||
from utils.dedup import dedup
|
||||
|
||||
order = ["type", "net", "num", "channel", "msg", "nick",
|
||||
@@ -63,6 +64,7 @@ def event(numName, c): # yes I'm using a short variable because otherwise it goe
|
||||
|
||||
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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
from modules import provision
|
||||
from utils.logging.log import *
|
||||
from utils.logging.debug import *
|
||||
from copy import deepcopy
|
||||
|
||||
def selectInst(net):
|
||||
@@ -11,11 +12,10 @@ def selectInst(net):
|
||||
inst[i] = main.irc["_"][i]
|
||||
else:
|
||||
inst = main.irc["_"]
|
||||
print(inst)
|
||||
print("hello")
|
||||
return inst
|
||||
|
||||
def registerAccount(net, num):
|
||||
debug("Attempting to register: %s - %i" % (net, num))
|
||||
alias = main.alias[num]
|
||||
nickname = alias["nick"]
|
||||
username = nickname+"/"+net
|
||||
@@ -42,17 +42,43 @@ def confirmAccount(net, num, token):
|
||||
main.IRCPool[name].msg(entity, cmd)
|
||||
enableAuthentication(net, num)
|
||||
|
||||
def confirmRegistration(net, num):
|
||||
obj = main.network[net]
|
||||
name = net+str(num)
|
||||
if name in main.IRCPool.keys():
|
||||
debug("Relay authenticated: %s - %i" %(net, num))
|
||||
main.IRCPool[name].authenticated = True
|
||||
if obj.relays[num]["registered"]:
|
||||
return
|
||||
if name in main.IRCPool.keys():
|
||||
if main.IRCPool[name]._regAttempt:
|
||||
main.IRCPool[name]._regAttempt.cancel()
|
||||
obj.relays[num]["registered"] = True
|
||||
main.saveConf("network")
|
||||
|
||||
def enableAuthentication(net, num):
|
||||
obj = main.network[net]
|
||||
nick = main.alias[num]["nick"]
|
||||
security = obj.security
|
||||
auth = obj.auth
|
||||
password = obj.aliases[num]["password"]
|
||||
|
||||
uname = main.alias[num]["nick"]+"/"+net
|
||||
provision.provisionAuthenticationData(num, nick, net, security, auth, password) # Set up for auth
|
||||
if obj.relays[num]["registered"]:
|
||||
warn("Authentication already enabled: %s - %i" % (net, num))
|
||||
obj.relays[num]["registered"] = True
|
||||
main.saveConf("network")
|
||||
main.IRCPool[net+str(num)].msg(main.config["Tweaks"]["ZNC"]["Prefix"]+"status", "Jump")
|
||||
if selectInst(net)["check"] == False:
|
||||
confirmRegistration(net, num)
|
||||
|
||||
def registerTest(c):
|
||||
inst = selectInst(c["net"])
|
||||
if inst["check"] == False:
|
||||
return
|
||||
if inst["checktype"] == "msg":
|
||||
if c["type"] == "query":
|
||||
if inst["checkmsg"] in c["msg"] and c["nick"] == inst["entity"]:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user