Implement migrating networks
This commit is contained in:
@@ -60,6 +60,7 @@ def getChanFree(net, new):
|
||||
return False
|
||||
return (chanfree, chanlimits.pop())
|
||||
|
||||
|
||||
def getTotalChans(net):
|
||||
total = 0
|
||||
for i in getActiveRelays(net):
|
||||
@@ -307,4 +308,4 @@ def chankeep_handler(net, num, listinfo, chanlimit):
|
||||
:param chanlimit:
|
||||
:return:
|
||||
"""
|
||||
listinfo, mean, sigrelay, relay = _initialList(net, num, listinfo, chanlimit)
|
||||
listinfo, mean, sigrelay, relay = _initialList(net, num, listinfo, chanlimit)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from copy import deepcopy
|
||||
|
||||
from twisted.internet import reactor
|
||||
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
||||
|
||||
@@ -11,6 +13,31 @@ from utils.get import getRelay
|
||||
from utils.logging.log import log
|
||||
|
||||
|
||||
def migrate():
|
||||
existing = deepcopy(main.network)
|
||||
log("Migrating network configuration")
|
||||
log(f"Existing network configuration: {existing}")
|
||||
for net, net_inst in existing.items():
|
||||
log(f"Migrating network {net}")
|
||||
net = net_inst.net
|
||||
host = net_inst.host
|
||||
port = net_inst.port
|
||||
security = net_inst.security
|
||||
auth = net_inst.auth
|
||||
last = net_inst.last
|
||||
relays = net_inst.relays
|
||||
aliases = net_inst.aliases
|
||||
|
||||
new_net = Network(net, host, port, security, auth)
|
||||
log(f"New network for {net}: {new_net}")
|
||||
new_net.last = last
|
||||
new_net.relays = relays
|
||||
new_net.aliases = aliases
|
||||
main.network[net] = new_net
|
||||
main.saveConf("network")
|
||||
log("Finished migrating network configuration")
|
||||
|
||||
|
||||
class Network:
|
||||
def __init__(self, net, host, port, security, auth):
|
||||
self.net = net
|
||||
@@ -18,6 +45,7 @@ class Network:
|
||||
self.port = port
|
||||
self.security = security
|
||||
self.auth = auth
|
||||
self.chanlimit = None
|
||||
|
||||
self.last = 1
|
||||
self.relays = {}
|
||||
|
||||
@@ -9,11 +9,6 @@ from utils.logging.log import warn
|
||||
def provisionUserNetworkData(
|
||||
num, nick, altnick, ident, realname, emails, network, host, port, security, auth, password
|
||||
):
|
||||
print("nick", nick)
|
||||
print("altnick", altnick)
|
||||
print("emails", emails)
|
||||
print("ident", ident)
|
||||
print("realname", realname)
|
||||
commands = {}
|
||||
stage2commands = {}
|
||||
stage2commands["status"] = []
|
||||
|
||||
Reference in New Issue
Block a user