Fix a race condition in disabling networks post-creation, remove redundant bindhost code and fix a minor bug in the load command

This commit is contained in:
Mark Veidemanis 2019-03-16 17:05:16 +00:00
parent a4b7bd50b1
commit 488d81dac8
4 changed files with 18 additions and 25 deletions

View File

@ -2,7 +2,7 @@ import main
class Load:
def __init__(self, *args):
self.list(*args)
self.load(*args)
def load(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
if authed:

View File

@ -16,23 +16,12 @@ def startBot(name):
certFN = main.certPath+main.config["Certificate"]
contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"),
certFN.encode("utf-8", "replace"))
if "bind" in main.relay[relay].keys():
bot = IRCBotFactory(name)
rct = reactor.connectSSL(host,
port,
bot, contextFactory,
bindAddress=main.relay[relay]["bind"])
bot = IRCBotFactory(name)
rct = reactor.connectSSL(host,
port,
bot, contextFactory)
main.ReactorPool[name] = rct
main.FactoryPool[name] = bot
return
else:
bot = IRCBotFactory(name)
rct = reactor.connectSSL(host,
port,
bot, contextFactory)
main.ReactorPool[name] = rct
main.FactoryPool[name] = bot
return
main.ReactorPool[name] = rct
main.FactoryPool[name] = bot
return

View File

@ -17,6 +17,7 @@ def provisionUserData(relay, alias, nick, altnick, ident, realname, password):
def provisionNetworkData(relay, alias, network, host, port, security, auth, password):
commands = {}
stage2commands = {}
stage3commands = {}
commands["controlpanel"] = []
commands["controlpanel"].append("AddNetwork %s %s" % (alias, network))
if security == "ssl":
@ -35,7 +36,12 @@ def provisionNetworkData(relay, alias, network, host, port, security, auth, pass
stage2commands["nickserv"] = []
stage2commands["status"].append("LoadMod NickServ")
stage2commands["nickserv"].append("Set %s" % password)
deliverRelayCommands(relay, commands, stage2=[[alias+"/"+network, stage2commands]])
if not main.config["ConnectOnCreate"]:
stage3commands["status"] = []
stage3commands["status"].append("Disconnect")
deliverRelayCommands(relay, commands,
stage2=[[alias+"/"+network, stage2commands],
[alias+"/"+network, stage3commands]])
return
def provisionRelayForAlias(relay, alias):
@ -54,7 +60,7 @@ def provisionRelayForAlias(relay, alias):
return True
def provisionRelayForNetwork(relay, alias, network):
if all([x in ["users", "networks"] for x in main.relay[relay].keys() if x in ["users", "networks"]]):
if set(["users", "networks"]).issubset(main.relay[relay].keys()):
if network in main.relay[relay]["networks"] and alias in main.relay[relay]["users"]:
return "PROVISIONED"
else:
@ -87,8 +93,6 @@ def provisionRelayForNetwork(relay, alias, network):
main.saveConf("pool")
if main.config["ConnectOnCreate"]:
startBot(network+i)
else:
deliverRelayCommands(relay, {"status": ["Disconnect"]}, user=alias+"/"+network)
storedNetwork = True
return network+i

View File

@ -6,8 +6,8 @@ import commands
from main import CommandMap
def loadCommands():
for filename in listdir('commands'):
if filename.endswith('.py') and filename != "__init__.py":
for filename in listdir("commands"):
if filename.endswith(".py") and filename != "__init__.py":
commandName = filename[0:-3]
className = commandName.capitalize()
try: