diff --git a/db_transfer.py b/db_transfer.py index b4d596e..18423e1 100644 --- a/db_transfer.py +++ b/db_transfer.py @@ -129,6 +129,10 @@ class DbTransfer(object): if name in row: cfg[name] = row[name] + for name in cfg.keys(): + if hasattr(cfg[name], 'encode'): + cfg[name] = cfg[name].encode('utf-8') + if port not in cur_servers: cur_servers[port] = passwd else: @@ -141,13 +145,13 @@ class DbTransfer(object): ServerPool.get_instance().cb_del_server(port) else: cfgchange = False - if (port in ServerPool.get_instance().tcp_servers_pool): + if port in ServerPool.get_instance().tcp_servers_pool: relay = ServerPool.get_instance().tcp_servers_pool[port] for name in ['password', 'method', 'obfs', 'protocol']: if name in cfg and cfg[name] != relay._config[name]: cfgchange = True break; - if (port in ServerPool.get_instance().tcp_ipv6_servers_pool): + if not cfgchange and port in ServerPool.get_instance().tcp_ipv6_servers_pool: relay = ServerPool.get_instance().tcp_ipv6_servers_pool[port] for name in ['password', 'method', 'obfs', 'protocol']: if name in cfg and cfg[name] != relay._config[name]: @@ -162,7 +166,7 @@ class DbTransfer(object): elif allow and ServerPool.get_instance().server_run_status(port) is False: #new_servers[port] = passwd logging.info('db start server at port [%s] pass [%s]' % (port, passwd)) - ServerPool.get_instance().new_server(port, passwd, cfg) + ServerPool.get_instance().new_server(port, cfg) for row in last_rows: if row['port'] in cur_servers: @@ -177,7 +181,7 @@ class DbTransfer(object): for port in new_servers.keys(): passwd, cfg = new_servers[port] logging.info('db start server at port [%s] pass [%s]' % (port, passwd)) - ServerPool.get_instance().new_server(port, passwd, cfg) + ServerPool.get_instance().new_server(port, cfg) @staticmethod def del_servers(): diff --git a/server_pool.py b/server_pool.py index f0529a5..63a8f16 100644 --- a/server_pool.py +++ b/server_pool.py @@ -106,7 +106,7 @@ class ServerPool(object): return False return True - def new_server(self, port, password, user_config): + def new_server(self, port, user_config): ret = True port = int(port) ipv6_ok = False @@ -122,7 +122,6 @@ class ServerPool(object): a_config['server_ipv6'] = a_config['server_ipv6'][1:-1] a_config['server'] = a_config['server_ipv6'] a_config['server_port'] = port - a_config['password'] = password a_config['max_connect'] = 128 try: logging.info("starting server at [%s]:%d" % (a_config['server'], port)) @@ -148,7 +147,6 @@ class ServerPool(object): a_config = self.config.copy() a_config.update(user_config) a_config['server_port'] = port - a_config['password'] = password a_config['max_connect'] = 128 try: logging.info("starting server at %s:%d" % (a_config['server'], port))