|
@ -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): |
|
|