Browse Source

detect cfg modification

dev
BreakWa11 9 years ago
parent
commit
4af9472986
  1. 23
      db_transfer.py

23
db_transfer.py

@ -124,7 +124,7 @@ class DbTransfer(object):
port = row['port']
passwd = common.to_bytes(row['passwd'])
cfg = {}
cfg = {'password': passwd}
for name in ['method', 'obfs', 'protocol']:
if name in row:
cfg[name] = row[name]
@ -139,10 +139,23 @@ class DbTransfer(object):
if not allow:
logging.info('db stop server at port [%s]' % (port,))
ServerPool.get_instance().cb_del_server(port)
elif (port in ServerPool.get_instance().tcp_servers_pool and ServerPool.get_instance().tcp_servers_pool[port]._config['password'] != passwd) \
or (port in ServerPool.get_instance().tcp_ipv6_servers_pool and ServerPool.get_instance().tcp_ipv6_servers_pool[port]._config['password'] != passwd):
#password changed
logging.info('db stop server at port [%s] reason: password changed' % (port,))
else:
cfgchange = False
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):
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]:
cfgchange = True
break;
#config changed
if cfgchange:
logging.info('db stop server at port [%s] reason: config changed: %s' % (port, cfg))
ServerPool.get_instance().cb_del_server(port)
new_servers[port] = (passwd, cfg)

Loading…
Cancel
Save