Browse Source

fix char set

dev
BreakWa11 9 years ago
parent
commit
825aece219
  1. 12
      db_transfer.py
  2. 4
      server_pool.py

12
db_transfer.py

@ -129,6 +129,10 @@ class DbTransfer(object):
if name in row: if name in row:
cfg[name] = row[name] 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: if port not in cur_servers:
cur_servers[port] = passwd cur_servers[port] = passwd
else: else:
@ -141,13 +145,13 @@ class DbTransfer(object):
ServerPool.get_instance().cb_del_server(port) ServerPool.get_instance().cb_del_server(port)
else: else:
cfgchange = False 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] relay = ServerPool.get_instance().tcp_servers_pool[port]
for name in ['password', 'method', 'obfs', 'protocol']: for name in ['password', 'method', 'obfs', 'protocol']:
if name in cfg and cfg[name] != relay._config[name]: if name in cfg and cfg[name] != relay._config[name]:
cfgchange = True cfgchange = True
break; 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] relay = ServerPool.get_instance().tcp_ipv6_servers_pool[port]
for name in ['password', 'method', 'obfs', 'protocol']: for name in ['password', 'method', 'obfs', 'protocol']:
if name in cfg and cfg[name] != relay._config[name]: 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: elif allow and ServerPool.get_instance().server_run_status(port) is False:
#new_servers[port] = passwd #new_servers[port] = passwd
logging.info('db start server at port [%s] pass [%s]' % (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: for row in last_rows:
if row['port'] in cur_servers: if row['port'] in cur_servers:
@ -177,7 +181,7 @@ class DbTransfer(object):
for port in new_servers.keys(): for port in new_servers.keys():
passwd, cfg = new_servers[port] passwd, cfg = new_servers[port]
logging.info('db start server at port [%s] pass [%s]' % (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)
@staticmethod @staticmethod
def del_servers(): def del_servers():

4
server_pool.py

@ -106,7 +106,7 @@ class ServerPool(object):
return False return False
return True return True
def new_server(self, port, password, user_config): def new_server(self, port, user_config):
ret = True ret = True
port = int(port) port = int(port)
ipv6_ok = False ipv6_ok = False
@ -122,7 +122,6 @@ class ServerPool(object):
a_config['server_ipv6'] = a_config['server_ipv6'][1:-1] a_config['server_ipv6'] = a_config['server_ipv6'][1:-1]
a_config['server'] = a_config['server_ipv6'] a_config['server'] = a_config['server_ipv6']
a_config['server_port'] = port a_config['server_port'] = port
a_config['password'] = password
a_config['max_connect'] = 128 a_config['max_connect'] = 128
try: try:
logging.info("starting server at [%s]:%d" % (a_config['server'], port)) 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 = self.config.copy()
a_config.update(user_config) a_config.update(user_config)
a_config['server_port'] = port a_config['server_port'] = port
a_config['password'] = password
a_config['max_connect'] = 128 a_config['max_connect'] = 128
try: try:
logging.info("starting server at %s:%d" % (a_config['server'], port)) logging.info("starting server at %s:%d" % (a_config['server'], port))

Loading…
Cancel
Save