diff --git a/db_transfer.py b/db_transfer.py index 0da6fe4..7ed02c4 100644 --- a/db_transfer.py +++ b/db_transfer.py @@ -250,8 +250,9 @@ class MuJsonTransfer(DbTransfer): if rows: 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.truncate() def pull_db_all_user(self): import json diff --git a/mujson_mgr.py b/mujson_mgr.py index ff99ac2..741c44c 100644 --- a/mujson_mgr.py +++ b/mujson_mgr.py @@ -2,7 +2,7 @@ # -*- coding: UTF-8 -*- import traceback -from shadowsocks import shell +from shadowsocks import shell, common from configloader import load_config, get_config import random import getopt @@ -21,8 +21,9 @@ class MuJsonLoader(object): def save(self, path): if self.json: 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.truncate() class MuMgr(object): def __init__(self): @@ -35,8 +36,8 @@ class MuMgr(object): 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) + 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://" + common.to_str(base64.urlsafe_b64encode(common.to_bytes(link))) def userinfo(self, user): ret = "" diff --git a/shadowsocks/crypto/rc4_md5.py b/shadowsocks/crypto/rc4_md5.py index 1f07a82..b0105ec 100644 --- a/shadowsocks/crypto/rc4_md5.py +++ b/shadowsocks/crypto/rc4_md5.py @@ -35,6 +35,7 @@ def create_cipher(alg, key, iv, op, key_as_bytes=0, d=None, salt=None, ciphers = { 'rc4-md5': (16, 16, create_cipher), + 'rc4-md5-6': (16, 6, create_cipher), } diff --git a/shadowsocks/encrypt_test.py b/shadowsocks/encrypt_test.py index 0121d63..d5e5077 100644 --- a/shadowsocks/encrypt_test.py +++ b/shadowsocks/encrypt_test.py @@ -12,6 +12,18 @@ from shadowsocks.crypto import openssl from shadowsocks.crypto import sodium from shadowsocks.crypto import table +def run(func): + try: + func() + except: + pass + +def run_n(func, name): + try: + func(name) + except: + pass + def main(): print("\n""rc4_md5") rc4_md5.test() @@ -19,14 +31,20 @@ def main(): openssl.test_aes_256_cfb() print("\n""aes-128-cfb") openssl.test_aes_128_cfb() - print("\n""rc4") - openssl.test_rc4() + print("\n""bf-cfb") + 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") - sodium.test_salsa20() + run(sodium.test_salsa20) print("\n""chacha20") - sodium.test_chacha20() - print("\n""table") - table.test_encryption() + run(sodium.test_chacha20) if __name__ == '__main__': main()