Separate provisioning into user and auth info

This commit is contained in:
Mark Veidemanis 2019-12-28 17:51:03 +00:00
parent 97a25334aa
commit f4e5d248d5
1 changed files with 15 additions and 4 deletions

View File

@ -13,7 +13,19 @@ def provisionUserData(num, nick, altnick, ident, realname, unused): # last field
commands["controlpanel"].append("Set Ident %s %s" % (nick, ident)) commands["controlpanel"].append("Set Ident %s %s" % (nick, ident))
commands["controlpanel"].append("Set RealName %s %s" % (nick, realname)) commands["controlpanel"].append("Set RealName %s %s" % (nick, realname))
deliverRelayCommands(num, commands) deliverRelayCommands(num, commands)
return
def provisionAuthenticationData(num, nick, network, security, auth, password):
commands = {}
if auth == "sasl":
commands["sasl"] = []
commands["status"].append("LoadMod sasl")
commands["sasl"].append("Mechanism plain")
commands["sasl"].append("Set %s %s" % (nick, password))
elif auth == "ns":
commands["nickserv"] = []
commands["status"].append("LoadMod nickserv")
commands["nickserv"].append("Set %s" % password)
deliverRelayCommands(num, commands, user=nick+"/"+network)
def provisionNetworkData(num, nick, network, host, port, security, auth, password): def provisionNetworkData(num, nick, network, host, port, security, auth, password):
commands = {} commands = {}
@ -26,6 +38,7 @@ def provisionNetworkData(num, nick, network, host, port, security, auth, passwor
commands["controlpanel"].append("AddServer %s %s %s +%s" % (nick, network, host, port)) commands["controlpanel"].append("AddServer %s %s %s +%s" % (nick, network, host, port))
elif security == "plain": elif security == "plain":
commands["controlpanel"].append("AddServer %s %s %s %s" % (nick, network, host, port)) commands["controlpanel"].append("AddServer %s %s %s %s" % (nick, network, host, port))
# Remove below and use provisionAuthenticationData() when registration implemented
if auth == "sasl": if auth == "sasl":
stage2commands["sasl"] = [] stage2commands["sasl"] = []
stage2commands["status"].append("LoadMod sasl") stage2commands["status"].append("LoadMod sasl")
@ -35,6 +48,7 @@ def provisionNetworkData(num, nick, network, host, port, security, auth, passwor
stage2commands["nickserv"] = [] stage2commands["nickserv"] = []
stage2commands["status"].append("LoadMod nickserv") stage2commands["status"].append("LoadMod nickserv")
stage2commands["nickserv"].append("Set %s" % password) stage2commands["nickserv"].append("Set %s" % password)
# End
if not main.config["ConnectOnCreate"]: if not main.config["ConnectOnCreate"]:
stage2commands["status"].append("Disconnect") stage2commands["status"].append("Disconnect")
if main.config["Toggles"]["CycleChans"]: if main.config["Toggles"]["CycleChans"]:
@ -42,7 +56,6 @@ def provisionNetworkData(num, nick, network, host, port, security, auth, passwor
stage2commands["status"].append("LoadMod chansaver") stage2commands["status"].append("LoadMod chansaver")
deliverRelayCommands(num, commands, deliverRelayCommands(num, commands,
stage2=[[nick+"/"+network, stage2commands]]) stage2=[[nick+"/"+network, stage2commands]])
return
def provisionRelayForNetwork(num, alias, network): def provisionRelayForNetwork(num, alias, network):
provisionNetworkData(num, alias, network, provisionNetworkData(num, alias, network,
@ -51,7 +64,6 @@ def provisionRelayForNetwork(num, alias, network):
main.network[network].security, main.network[network].security,
main.network[network].auth, main.network[network].auth,
main.network[network].aliases[num]["password"]) main.network[network].aliases[num]["password"])
return
def provisionRelay(num, network): def provisionRelay(num, network):
aliasObj = main.alias[num] aliasObj = main.alias[num]
@ -60,7 +72,6 @@ def provisionRelay(num, network):
reactor.callLater(5, provisionRelayForNetwork, num, alias, network) reactor.callLater(5, provisionRelayForNetwork, num, alias, network)
if main.config["ConnectOnCreate"]: if main.config["ConnectOnCreate"]:
reactor.callLater(10, main.network[network].start_bot, num) reactor.callLater(10, main.network[network].start_bot, num)
return
def provisionMultipleRelays(net, relaysNeeded): def provisionMultipleRelays(net, relaysNeeded):
numsProvisioned = [] numsProvisioned = []