display ssr link
This commit is contained in:
parent
50b11fff02
commit
45584dc4f5
2 changed files with 15 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
# Config
|
# Config
|
||||||
TRANSFER_MUL = 1.0
|
TRANSFER_MUL = 1.0
|
||||||
NODE_ID = 1
|
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)
|
API_INTERFACE = 'sspanelv2' #mudbjson, sspanelv2, sspanelv3, sspanelv3ssr, muapiv2(not support)
|
||||||
|
|
||||||
#mudb
|
#mudb
|
||||||
|
|
|
@ -8,6 +8,7 @@ import random
|
||||||
import getopt
|
import getopt
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
import base64
|
||||||
|
|
||||||
class MuJsonLoader(object):
|
class MuJsonLoader(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -26,8 +27,17 @@ class MuJsonLoader(object):
|
||||||
class MuMgr(object):
|
class MuMgr(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config_path = get_config().MUDB_FILE
|
self.config_path = get_config().MUDB_FILE
|
||||||
|
self.server_addr = get_config().SERVER_PUB_ADDR
|
||||||
self.data = MuJsonLoader()
|
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):
|
def userinfo(self, user):
|
||||||
ret = ""
|
ret = ""
|
||||||
for key in user.keys():
|
for key in user.keys():
|
||||||
|
@ -38,15 +48,16 @@ class MuMgr(object):
|
||||||
ret += " %s : %s" % (key, val)
|
ret += " %s : %s" % (key, val)
|
||||||
elif val / 1024**2 < 4:
|
elif val / 1024**2 < 4:
|
||||||
val /= float(1024)
|
val /= float(1024)
|
||||||
ret += " %s : %s K bytes" % (key, val)
|
ret += " %s : %s K Bytes" % (key, val)
|
||||||
elif val / 1024**3 < 4:
|
elif val / 1024**3 < 4:
|
||||||
val /= float(1024**2)
|
val /= float(1024**2)
|
||||||
ret += " %s : %s M bytes" % (key, val)
|
ret += " %s : %s M Bytes" % (key, val)
|
||||||
else:
|
else:
|
||||||
val /= float(1024**3)
|
val /= float(1024**3)
|
||||||
ret += " %s : %s G bytes" % (key, val)
|
ret += " %s : %s G Bytes" % (key, val)
|
||||||
else:
|
else:
|
||||||
ret += " %s : %s" % (key, user[key])
|
ret += " %s : %s" % (key, user[key])
|
||||||
|
ret += "\n " + self.ssrlink(user)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def rand_pass(self):
|
def rand_pass(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue