detect cfg modification
This commit is contained in:
parent
7f26f43f88
commit
4af9472986
1 changed files with 20 additions and 7 deletions
|
@ -124,7 +124,7 @@ class DbTransfer(object):
|
||||||
|
|
||||||
port = row['port']
|
port = row['port']
|
||||||
passwd = common.to_bytes(row['passwd'])
|
passwd = common.to_bytes(row['passwd'])
|
||||||
cfg = {}
|
cfg = {'password': passwd}
|
||||||
for name in ['method', 'obfs', 'protocol']:
|
for name in ['method', 'obfs', 'protocol']:
|
||||||
if name in row:
|
if name in row:
|
||||||
cfg[name] = row[name]
|
cfg[name] = row[name]
|
||||||
|
@ -139,10 +139,23 @@ class DbTransfer(object):
|
||||||
if not allow:
|
if not allow:
|
||||||
logging.info('db stop server at port [%s]' % (port,))
|
logging.info('db stop server at port [%s]' % (port,))
|
||||||
ServerPool.get_instance().cb_del_server(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) \
|
else:
|
||||||
or (port in ServerPool.get_instance().tcp_ipv6_servers_pool and ServerPool.get_instance().tcp_ipv6_servers_pool[port]._config['password'] != passwd):
|
cfgchange = False
|
||||||
#password changed
|
if (port in ServerPool.get_instance().tcp_servers_pool):
|
||||||
logging.info('db stop server at port [%s] reason: password changed' % (port,))
|
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)
|
ServerPool.get_instance().cb_del_server(port)
|
||||||
new_servers[port] = (passwd, cfg)
|
new_servers[port] = (passwd, cfg)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue