avoid making mudb.json empty
test more encryptor add rc4-md5-6
This commit is contained in:
parent
45584dc4f5
commit
cd6dab188c
4 changed files with 32 additions and 11 deletions
|
@ -250,8 +250,9 @@ class MuJsonTransfer(DbTransfer):
|
||||||
|
|
||||||
if rows:
|
if rows:
|
||||||
output = json.dumps(rows, sort_keys=True, indent=4, separators=(',', ': '))
|
output = json.dumps(rows, sort_keys=True, indent=4, separators=(',', ': '))
|
||||||
with open(config_path, 'w') as f:
|
with open(config_path, 'r+') as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
|
f.truncate()
|
||||||
|
|
||||||
def pull_db_all_user(self):
|
def pull_db_all_user(self):
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: UTF-8 -*-
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
from shadowsocks import shell
|
from shadowsocks import shell, common
|
||||||
from configloader import load_config, get_config
|
from configloader import load_config, get_config
|
||||||
import random
|
import random
|
||||||
import getopt
|
import getopt
|
||||||
|
@ -21,8 +21,9 @@ class MuJsonLoader(object):
|
||||||
def save(self, path):
|
def save(self, path):
|
||||||
if self.json:
|
if self.json:
|
||||||
output = json.dumps(self.json, sort_keys=True, indent=4, separators=(',', ': '))
|
output = json.dumps(self.json, sort_keys=True, indent=4, separators=(',', ': '))
|
||||||
with open(path, 'w') as f:
|
with open(path, 'r+') as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
|
f.truncate()
|
||||||
|
|
||||||
class MuMgr(object):
|
class MuMgr(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -35,8 +36,8 @@ class MuMgr(object):
|
||||||
obfs = user.get('obfs', '')
|
obfs = user.get('obfs', '')
|
||||||
protocol = protocol.replace("_compatible", "")
|
protocol = protocol.replace("_compatible", "")
|
||||||
obfs = obfs.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']))
|
link = "%s:%s:%s:%s:%s:%s" % (self.server_addr, user['port'], protocol, user['method'], obfs, common.to_str(base64.urlsafe_b64encode(common.to_bytes(user['passwd']))))
|
||||||
return "ssr://" + base64.urlsafe_b64encode(link)
|
return "ssr://" + common.to_str(base64.urlsafe_b64encode(common.to_bytes(link)))
|
||||||
|
|
||||||
def userinfo(self, user):
|
def userinfo(self, user):
|
||||||
ret = ""
|
ret = ""
|
||||||
|
|
|
@ -35,6 +35,7 @@ def create_cipher(alg, key, iv, op, key_as_bytes=0, d=None, salt=None,
|
||||||
|
|
||||||
ciphers = {
|
ciphers = {
|
||||||
'rc4-md5': (16, 16, create_cipher),
|
'rc4-md5': (16, 16, create_cipher),
|
||||||
|
'rc4-md5-6': (16, 6, create_cipher),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,18 @@ from shadowsocks.crypto import openssl
|
||||||
from shadowsocks.crypto import sodium
|
from shadowsocks.crypto import sodium
|
||||||
from shadowsocks.crypto import table
|
from shadowsocks.crypto import table
|
||||||
|
|
||||||
|
def run(func):
|
||||||
|
try:
|
||||||
|
func()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def run_n(func, name):
|
||||||
|
try:
|
||||||
|
func(name)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("\n""rc4_md5")
|
print("\n""rc4_md5")
|
||||||
rc4_md5.test()
|
rc4_md5.test()
|
||||||
|
@ -19,14 +31,20 @@ def main():
|
||||||
openssl.test_aes_256_cfb()
|
openssl.test_aes_256_cfb()
|
||||||
print("\n""aes-128-cfb")
|
print("\n""aes-128-cfb")
|
||||||
openssl.test_aes_128_cfb()
|
openssl.test_aes_128_cfb()
|
||||||
print("\n""rc4")
|
print("\n""bf-cfb")
|
||||||
openssl.test_rc4()
|
run(openssl.test_bf_cfb)
|
||||||
|
print("\n""camellia-128-cfb")
|
||||||
|
run_n(openssl.run_method, "camellia-128-cfb")
|
||||||
|
print("\n""cast5-cfb")
|
||||||
|
run_n(openssl.run_method, "cast5-cfb")
|
||||||
|
print("\n""idea-cfb")
|
||||||
|
run_n(openssl.run_method, "idea-cfb")
|
||||||
|
print("\n""seed-cfb")
|
||||||
|
run_n(openssl.run_method, "seed-cfb")
|
||||||
print("\n""salsa20")
|
print("\n""salsa20")
|
||||||
sodium.test_salsa20()
|
run(sodium.test_salsa20)
|
||||||
print("\n""chacha20")
|
print("\n""chacha20")
|
||||||
sodium.test_chacha20()
|
run(sodium.test_chacha20)
|
||||||
print("\n""table")
|
|
||||||
table.test_encryption()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue