pull/632/head
Mr Chen 5 months ago
parent d36b36e1d3
commit 16e312bbe7
  1. 2
      plugins/mtproxy/index.py
  2. 36
      plugins/xui/index.py

@ -162,7 +162,7 @@ def restart():
def reload(): def reload():
return redisOp('reload') return mtOp('reload')
def initdStatus(): def initdStatus():

@ -109,6 +109,10 @@ def delPort():
return True return True
def pSqliteDb(dbname='databases'):
conn = mw.M(dbname).dbPos('/etc/x-ui', 'x-ui')
return conn
def initDreplace(): def initDreplace():
envTpl = getConfEnvTpl() envTpl = getConfEnvTpl()
@ -136,12 +140,12 @@ def initDreplace():
return 'ok' return 'ok'
def mtOp(method): def xuiOp(method):
file = initDreplace() file = initDreplace()
if not mw.isAppleSystem(): if not mw.isAppleSystem():
mw.execShell('systemctl daemon-reload') mw.execShell('systemctl daemon-reload')
data = mw.execShell('systemctl ' + method + ' mtproxy') data = mw.execShell('systemctl ' + method + ' xui')
if data[1] == '': if data[1] == '':
return 'ok' return 'ok'
return data[1] return data[1]
@ -150,15 +154,15 @@ def mtOp(method):
def start(): def start():
return mtOp('start') return xuiOp('start')
def stop(): def stop():
return mtOp('stop') return xuiOp('stop')
def restart(): def restart():
return mtOp('restart') return xuiOp('restart')
def reload(): def reload():
@ -189,26 +193,18 @@ def initdUinstall():
return 'ok' return 'ok'
def getMtproxyUrl(): def getMtproxyUrl():
conf = getConfEnv()
content = mw.readFile(conf)
rep = r'bind-to\s*=\s*(.*)' user = pSqliteDb('users')
tmp = re.search(rep, content)
bind_to = tmp.groups()[0].strip()
bind_to = bind_to.strip('"')
rep = r'secret\s*=\s*(.*)' info = user.field('username,password').where("id=?", (1,)).find()
tmp = re.search(rep, content)
secret = tmp.groups()[0].strip()
secret = secret.strip('"')
info = bind_to.split(":") setting = pSqliteDb('setting')
ip = mw.getLocalIp() setting_data = setting.where("key=?", ('webPort',)).find()
url = 'tg://proxy?server={0}&port={1}&secret={2}'.format(ip, info[1], secret) print(info)
return mw.returnJson(True, 'ok', url) print(setting_data)
return mw.returnJson(True, 'ok', '')
def installPreInspection(): def installPreInspection():
sys = mw.execShell("cat /etc/*-release | grep PRETTY_NAME |awk -F = '{print $2}' | awk -F '\"' '{print $2}'| awk '{print $1}'") sys = mw.execShell("cat /etc/*-release | grep PRETTY_NAME |awk -F = '{print $2}' | awk -F '\"' '{print $2}'| awk '{print $1}'")

Loading…
Cancel
Save