From 75f79cf07213fead14f12ed3209b56913047e2cf Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Fri, 29 Jul 2022 17:28:09 +0100 Subject: [PATCH] Fix joining channels with inactive relays --- modules/chankeep.py | 25 ++++++++++++------------- modules/network.py | 2 ++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/modules/chankeep.py b/modules/chankeep.py index 59c0e0d..dfd334d 100644 --- a/modules/chankeep.py +++ b/modules/chankeep.py @@ -38,6 +38,10 @@ def getChanFree(net, new): if i in new: continue name = net + str(i) + if name not in main.IRCPool.keys(): + continue + if not main.IRCPool[name].isconnected: + continue chanfree[i] = main.IRCPool[name].chanlimit - len(main.IRCPool[name].channels) chanlimits.add(main.IRCPool[name].chanlimit) if not len(chanlimits) == 1: @@ -131,20 +135,15 @@ def keepChannels(net, listinfo, mean, sigrelay, relay): def joinSingle(net, channel): - if allRelaysActive(net): - # Use the algorithm to allocate our channel to a relay - eca = emptyChanAllocate(net, [channel], None, []) - if not len(eca.keys()) == 1: - return False - num = list(eca.keys())[0] - name = f"{net}{num}" - if name not in main.IRCPool: - return False - main.IRCPool[name].join(channel) - return num - else: - error("All relays for %s are not active" % net) + eca = emptyChanAllocate(net, [channel], None, []) + if not len(eca.keys()) == 1: return False + num = list(eca.keys())[0] + name = f"{net}{num}" + if name not in main.IRCPool: + return False + main.IRCPool[name].join(channel) + return num def partSingle(net, channel): diff --git a/modules/network.py b/modules/network.py index ccfbb32..7aea0b1 100644 --- a/modules/network.py +++ b/modules/network.py @@ -24,6 +24,8 @@ class Network: self.aliases = {} def add_relay(self, num=None): + # Grrrrrrrrrr + self.last = int(self.last) if not num: num = self.last self.last += 1