diff --git a/lib/network.py b/lib/network.py index 95afaef4a..4c3b3ac9e 100644 --- a/lib/network.py +++ b/lib/network.py @@ -308,15 +308,6 @@ class Network(util.DaemonThread): def set_parameters(self, host, port, protocol, proxy, auto_connect): - proxy_str = serialize_proxy(proxy) - server_str = serialize_server(host, port, protocol) - self.config.set_key('auto_cycle', auto_connect, True) - self.config.set_key("proxy", proxy_str, True) - self.config.set_key("server", server_str, True) - # abort if changes were not allowed by config - if self.config.get('server') != server_str or self.config.get('proxy') != proxy_str: - return - if self.proxy != proxy or self.protocol != protocol: self.print_error('restarting network') for i in self.interfaces.values(): @@ -336,6 +327,7 @@ class Network(util.DaemonThread): if self.server_is_lagging(): self.stop_interface() else: + server_str = serialize_server(host, port, protocol) self.set_server(server_str) @@ -352,7 +344,6 @@ class Network(util.DaemonThread): server = interface.server self.print_error("switching to", server) self.interface = interface - self.config.set_key('server', server, False) self.default_server = server self.send_subscriptions() self.set_status('connected') @@ -378,7 +369,6 @@ class Network(util.DaemonThread): self.set_status('connecting') # start interface self.default_server = server - self.config.set_key("server", server, True) if server in self.interfaces.keys(): self.switch_to_interface( self.interfaces[server] ) diff --git a/lib/network_proxy.py b/lib/network_proxy.py index 2365c41fe..a5f5af76c 100644 --- a/lib/network_proxy.py +++ b/lib/network_proxy.py @@ -30,6 +30,7 @@ from network import Network from util import print_error, print_stderr, parse_json from simple_config import SimpleConfig from daemon import NetworkServer +from network import serialize_proxy, serialize_server @@ -205,8 +206,17 @@ class NetworkProxy(util.DaemonThread): def get_parameters(self): return self.synchronous_get([('network.get_parameters', [])])[0] - def set_parameters(self, *args): - return self.synchronous_get([('network.set_parameters', args)])[0] + def set_parameters(self, host, port, protocol, proxy, auto_connect): + proxy_str = serialize_proxy(proxy) + server_str = serialize_server(host, port, protocol) + self.config.set_key('auto_cycle', auto_connect, True) + self.config.set_key("proxy", proxy_str, True) + self.config.set_key("server", server_str, True) + # abort if changes were not allowed by config + if self.config.get('server') != server_str or self.config.get('proxy') != proxy_str: + return + + return self.synchronous_get([('network.set_parameters', (host, port, protocol, proxy, auto_connect))])[0] def stop_daemon(self): return self.send([('daemon.stop',[])], None)