Allow gaps in relay numbering

This commit is contained in:
2022-08-11 19:22:09 +01:00
parent 4c8b584ef4
commit 502b45cda5
8 changed files with 86 additions and 40 deletions

View File

@@ -6,7 +6,7 @@ from klein import Klein
from twisted.web.server import Request
import main
from modules import chankeep, provision, userinfo
from modules import chankeep, helpers, provision, userinfo
from modules.network import Network
from utils.logging.log import warn
@@ -473,10 +473,8 @@ class API(object):
def irc_list_network(self, request, net):
if net not in main.network.keys():
return dumps({"success": False, "reason": "no such net."})
if 1 not in main.network[net].relays.keys():
return dumps({"success": False, "reason": f"no first relay on {net}"})
name = f"{net}1"
if name not in main.IRCPool.keys():
return dumps({"success": False, "reason": f"first relay not active for {net}"})
main.IRCPool[name].list()
return dumps({"success": True, "message": f"requested list with first instance of {net}"})
first_relay = helpers.get_first_relay(net)
if not first_relay:
return dumps({"success": False, "reason": f"could not get first relay for {net}"})
first_relay.list()
return dumps({"success": True, "message": f"requested list with instance {first_relay.num} of {net}"})