Browse Source

display ssr link

dev
BreakWa11 8 years ago
parent
commit
45584dc4f5
  1. 2
      apiconfig.py
  2. 17
      mujson_mgr.py

2
apiconfig.py

@ -1,7 +1,7 @@
# Config
TRANSFER_MUL = 1.0
NODE_ID = 1
SERVER_PUB_ADDR = '127.0.0.1'
SERVER_PUB_ADDR = '127.0.0.1' # mujson_mgr need this to generate ssr link
API_INTERFACE = 'sspanelv2' #mudbjson, sspanelv2, sspanelv3, sspanelv3ssr, muapiv2(not support)
#mudb

17
mujson_mgr.py

@ -8,6 +8,7 @@ import random
import getopt
import sys
import json
import base64
class MuJsonLoader(object):
def __init__(self):
@ -26,8 +27,17 @@ class MuJsonLoader(object):
class MuMgr(object):
def __init__(self):
self.config_path = get_config().MUDB_FILE
self.server_addr = get_config().SERVER_PUB_ADDR
self.data = MuJsonLoader()
def ssrlink(self, user):
protocol = user.get('protocol', '')
obfs = user.get('obfs', '')
protocol = protocol.replace("_compatible", "")
obfs = obfs.replace("_compatible", "")
link = "%s:%s:%s:%s:%s:%s" % (self.server_addr, user['port'], protocol, user['method'], obfs, base64.urlsafe_b64encode(user['passwd']))
return "ssr://" + base64.urlsafe_b64encode(link)
def userinfo(self, user):
ret = ""
for key in user.keys():
@ -38,15 +48,16 @@ class MuMgr(object):
ret += " %s : %s" % (key, val)
elif val / 1024**2 < 4:
val /= float(1024)
ret += " %s : %s K bytes" % (key, val)
ret += " %s : %s K Bytes" % (key, val)
elif val / 1024**3 < 4:
val /= float(1024**2)
ret += " %s : %s M bytes" % (key, val)
ret += " %s : %s M Bytes" % (key, val)
else:
val /= float(1024**3)
ret += " %s : %s G bytes" % (key, val)
ret += " %s : %s G Bytes" % (key, val)
else:
ret += " %s : %s" % (key, user[key])
ret += "\n " + self.ssrlink(user)
return ret
def rand_pass(self):

Loading…
Cancel
Save