From 08b5dc06f00ac990990dff838652dc331c1d4ab1 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 2 Nov 2020 20:14:02 +0000 Subject: [PATCH] Implement relay-independent join --- commands/join.py | 10 +++++++++- modules/chankeep.py | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/commands/join.py b/commands/join.py index ff912bc..02067c7 100644 --- a/commands/join.py +++ b/commands/join.py @@ -1,4 +1,5 @@ import main +import modules.chankeep class JoinCommand: def __init__(self, *args): @@ -6,7 +7,14 @@ class JoinCommand: def join(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length): if authed: - if length == 4: + if length == 3: + if not spl[1] in main.network.keys(): + failure("Network does not exist: %s" % spl[1]) + return + modules.chankeep.joinSingle(spl[1], spl[2]) + success("Joined %s" % spl[2]) + + elif length == 4: if not spl[1] in main.network.keys(): failure("Network does not exist: %s" % spl[1]) return diff --git a/modules/chankeep.py b/modules/chankeep.py index 3de11b0..1cc70c0 100644 --- a/modules/chankeep.py +++ b/modules/chankeep.py @@ -111,6 +111,17 @@ def keepChannels(net, listinfo, mean, sigrelay, relay): populateChans(net, siglist, sigrelay, newNums) notifyJoin(net) +def joinSingle(net, channel): + if allRelaysActive(net): + chanfree = getChanFree(net, []) + print("chanfree", chanfree) + for i in chanfree[0]: + if chanfree[0][i] < 0: + print("JOIN CHAN") + else: + error("All relays for %s are not active" % net) + return False + def nukeNetwork(net): #purgeRecords(net) #p = main.g.pipeline()