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:
parent
a4b7bd50b1
commit
488d81dac8
|
@ -2,7 +2,7 @@ import main
|
||||||
|
|
||||||
class Load:
|
class Load:
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
self.list(*args)
|
self.load(*args)
|
||||||
|
|
||||||
def load(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
def load(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||||
if authed:
|
if authed:
|
||||||
|
|
|
@ -16,23 +16,12 @@ def startBot(name):
|
||||||
certFN = main.certPath+main.config["Certificate"]
|
certFN = main.certPath+main.config["Certificate"]
|
||||||
contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"),
|
contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"),
|
||||||
certFN.encode("utf-8", "replace"))
|
certFN.encode("utf-8", "replace"))
|
||||||
if "bind" in main.relay[relay].keys():
|
bot = IRCBotFactory(name)
|
||||||
bot = IRCBotFactory(name)
|
rct = reactor.connectSSL(host,
|
||||||
rct = reactor.connectSSL(host,
|
port,
|
||||||
port,
|
bot, contextFactory)
|
||||||
bot, contextFactory,
|
|
||||||
bindAddress=main.relay[relay]["bind"])
|
|
||||||
|
|
||||||
main.ReactorPool[name] = rct
|
main.ReactorPool[name] = rct
|
||||||
main.FactoryPool[name] = bot
|
main.FactoryPool[name] = bot
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
bot = IRCBotFactory(name)
|
|
||||||
rct = reactor.connectSSL(host,
|
|
||||||
port,
|
|
||||||
bot, contextFactory)
|
|
||||||
|
|
||||||
main.ReactorPool[name] = rct
|
|
||||||
main.FactoryPool[name] = bot
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ def provisionUserData(relay, alias, nick, altnick, ident, realname, password):
|
||||||
def provisionNetworkData(relay, alias, network, host, port, security, auth, password):
|
def provisionNetworkData(relay, alias, network, host, port, security, auth, password):
|
||||||
commands = {}
|
commands = {}
|
||||||
stage2commands = {}
|
stage2commands = {}
|
||||||
|
stage3commands = {}
|
||||||
commands["controlpanel"] = []
|
commands["controlpanel"] = []
|
||||||
commands["controlpanel"].append("AddNetwork %s %s" % (alias, network))
|
commands["controlpanel"].append("AddNetwork %s %s" % (alias, network))
|
||||||
if security == "ssl":
|
if security == "ssl":
|
||||||
|
@ -35,7 +36,12 @@ def provisionNetworkData(relay, alias, network, host, port, security, auth, pass
|
||||||
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)
|
||||||
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
|
return
|
||||||
|
|
||||||
def provisionRelayForAlias(relay, alias):
|
def provisionRelayForAlias(relay, alias):
|
||||||
|
@ -54,7 +60,7 @@ def provisionRelayForAlias(relay, alias):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def provisionRelayForNetwork(relay, alias, network):
|
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"]:
|
if network in main.relay[relay]["networks"] and alias in main.relay[relay]["users"]:
|
||||||
return "PROVISIONED"
|
return "PROVISIONED"
|
||||||
else:
|
else:
|
||||||
|
@ -87,8 +93,6 @@ def provisionRelayForNetwork(relay, alias, network):
|
||||||
main.saveConf("pool")
|
main.saveConf("pool")
|
||||||
if main.config["ConnectOnCreate"]:
|
if main.config["ConnectOnCreate"]:
|
||||||
startBot(network+i)
|
startBot(network+i)
|
||||||
else:
|
|
||||||
deliverRelayCommands(relay, {"status": ["Disconnect"]}, user=alias+"/"+network)
|
|
||||||
|
|
||||||
storedNetwork = True
|
storedNetwork = True
|
||||||
return network+i
|
return network+i
|
||||||
|
|
|
@ -6,8 +6,8 @@ import commands
|
||||||
from main import CommandMap
|
from main import CommandMap
|
||||||
|
|
||||||
def loadCommands():
|
def loadCommands():
|
||||||
for filename in listdir('commands'):
|
for filename in listdir("commands"):
|
||||||
if filename.endswith('.py') and filename != "__init__.py":
|
if filename.endswith(".py") and filename != "__init__.py":
|
||||||
commandName = filename[0:-3]
|
commandName = filename[0:-3]
|
||||||
className = commandName.capitalize()
|
className = commandName.capitalize()
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue