Implement migrating networks

This commit is contained in:
2022-08-12 23:32:00 +01:00
parent 14967f662c
commit edfb3f15eb
6 changed files with 55 additions and 16 deletions

View File

@@ -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 = {}