Browse Source

add sspanelv3 interface, read the 'method' row

dev
BreakWa11 9 years ago
parent
commit
c7864acc37
  1. 2
      apiconfig.py
  2. 12
      db_transfer.py
  3. 4
      server_pool.py
  4. 10
      switchrule.py

2
apiconfig.py

@ -1,7 +1,7 @@
# Config # Config
TRANSFER_MUL = 1.0 TRANSFER_MUL = 1.0
NODE_ID = 1 NODE_ID = 1
API_INTERFACE = 'sspanelv2' #sspanelv2, muapiv2 API_INTERFACE = 'sspanelv2' #sspanelv2, sspanelv3, muapiv2
# Mysql # Mysql
MYSQL_HOST = 'mdss.mengsky.net' MYSQL_HOST = 'mdss.mengsky.net'

12
db_transfer.py

@ -124,6 +124,10 @@ class DbTransfer(object):
port = row['port'] port = row['port']
passwd = common.to_bytes(row['passwd']) passwd = common.to_bytes(row['passwd'])
cfg = {}
for name in ['method', 'obfs', 'protocol']:
if name in row:
cfg[name] = row[name]
if port not in cur_servers: if port not in cur_servers:
cur_servers[port] = passwd cur_servers[port] = passwd
@ -140,12 +144,12 @@ class DbTransfer(object):
#password changed #password changed
logging.info('db stop server at port [%s] reason: password changed' % (port,)) logging.info('db stop server at port [%s] reason: password changed' % (port,))
ServerPool.get_instance().cb_del_server(port) ServerPool.get_instance().cb_del_server(port)
new_servers[port] = passwd new_servers[port] = (passwd, cfg)
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) ServerPool.get_instance().new_server(port, passwd, cfg)
for row in last_rows: for row in last_rows:
if row['port'] in cur_servers: if row['port'] in cur_servers:
@ -158,9 +162,9 @@ class DbTransfer(object):
from shadowsocks import eventloop from shadowsocks import eventloop
DbTransfer.get_instance().event.wait(eventloop.TIMEOUT_PRECISION) DbTransfer.get_instance().event.wait(eventloop.TIMEOUT_PRECISION)
for port in new_servers.keys(): for port in new_servers.keys():
passwd = 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) ServerPool.get_instance().new_server(port, passwd, 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): def new_server(self, port, password, user_config):
ret = True ret = True
port = int(port) port = int(port)
ipv6_ok = False ipv6_ok = False
@ -117,6 +117,7 @@ class ServerPool(object):
return 'this port server is already running' return 'this port server is already running'
else: else:
a_config = self.config.copy() a_config = self.config.copy()
a_config.update(user_config)
if len(a_config['server_ipv6']) > 2 and a_config['server_ipv6'][0] == "[" and a_config['server_ipv6'][-1] == "]": if len(a_config['server_ipv6']) > 2 and a_config['server_ipv6'][0] == "[" and a_config['server_ipv6'][-1] == "]":
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']
@ -145,6 +146,7 @@ class ServerPool(object):
return 'this port server is already running' return 'this port server is already running'
else: else:
a_config = self.config.copy() a_config = self.config.copy()
a_config.update(user_config)
a_config['server_port'] = port a_config['server_port'] = port
a_config['password'] = password a_config['password'] = password
a_config['max_connect'] = 128 a_config['max_connect'] = 128

10
switchrule.py

@ -1,6 +1,12 @@
from configloader import load_config, get_config
def getKeys(): def getKeys():
return ['port', 'u', 'd', 'transfer_enable', 'passwd', 'enable' ] load_config()
#return ['port', 'u', 'd', 'transfer_enable', 'passwd', 'enable', 'plan' ] # append the column name 'plan' key_list = ['port', 'u', 'd', 'transfer_enable', 'passwd', 'enable' ]
if get_config().API_INTERFACE == 'sspanelv3':
key_list += ['method']
return key_list
#return key_list + ['plan'] # append the column name 'plan'
def isTurnOn(row): def isTurnOn(row):
return True return True

Loading…
Cancel
Save