From 8b2f26c08e892be9ace578eae5e3358bb3c94ec3 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Thu, 23 May 2013 12:10:31 +0800 Subject: [PATCH] more robust --- encrypt.py | 12 +++++++++++- local.py | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/encrypt.py b/encrypt.py index 79be657..a7adb14 100644 --- a/encrypt.py +++ b/encrypt.py @@ -60,7 +60,11 @@ def init_table(key, method=None): encrypt_table = ''.join(get_table(key)) decrypt_table = string.maketrans(encrypt_table, string.maketrans('', '')) else: - Encryptor(key, method) # make an Encryptor to test if the settings if OK + try: + Encryptor(key, method) # make an Encryptor to test if the settings if OK + except Exception as e: + logging.error(e) + sys.exit(1) def EVP_BytesToKey(password, key_len, iv_len): @@ -88,9 +92,15 @@ method_supported = { 'aes-192-cfb': (24, 16), 'aes-256-cfb': (32, 16), 'bf-cfb': (16, 8), + 'camellia-128-cfb': (16, 16), + 'camellia-192-cfb': (24, 16), + 'camellia-256-cfb': (32, 16), 'cast5-cfb': (16, 8), 'des-cfb': (8, 8), + 'idea-cfb': (16, 8), + 'rc2-cfb': (8, 8), 'rc4': (16, 0), + 'seed-cfb': (16, 16), } diff --git a/local.py b/local.py index b8dcb55..515832f 100755 --- a/local.py +++ b/local.py @@ -179,11 +179,11 @@ if __name__ == '__main__': elif key == '-m': METHOD = value - encrypt.init_table(KEY, METHOD) - logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d %H:%M:%S', filemode='a+') + encrypt.init_table(KEY, METHOD) + try: server = ThreadingTCPServer(('', PORT), Socks5Server) logging.info("starting server at port %d ..." % PORT)