Skip to content

Commit

Permalink
v1.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
qwj authored Aug 13, 2018
1 parent dfed055 commit 8496633
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 9 additions & 2 deletions pproxy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import argparse, time, re, asyncio, functools, urllib.parse
import argparse, time, re, asyncio, functools, base64, urllib.parse
from pproxy import proto

__title__ = 'pproxy'
__version__ = "1.6.3"
__version__ = "1.6.4"
__description__ = "Proxy server that can tunnel among remote servers by regex rules."
__author__ = "Qian Wenjie"
__license__ = "MIT License"
Expand Down Expand Up @@ -155,6 +155,13 @@ def compile(cls, uri, relay=None):
cipher, _, loc = url.netloc.rpartition('@')
if cipher:
from pproxy.cipher import get_cipher
if ':' not in cipher:
try:
cipher = base64.b64decode(cipher).decode()
except Exception:
pass
if ':' not in cipher:
raise argparse.ArgumentTypeError('userinfo must be "cipher:key"')
err_str, cipher = get_cipher(cipher)
if err_str:
raise argparse.ArgumentTypeError(err_str)
Expand Down
4 changes: 1 addition & 3 deletions pproxy/cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,8 @@ def setup(self):

def get_cipher(cipher_key):
from pproxy.cipherpy import MAP as MAP_PY
cipher, _, key = cipher_key.partition(':')
cipher, key = cipher_key.split(':')
cipher_name, ota, _ = cipher.partition('!')
if not key:
return 'empty key', None
if cipher_name not in MAP and cipher_name not in MAP_PY and not (cipher_name.endswith('-py') and cipher_name[:-3] in MAP_PY):
return f'existing ciphers: {sorted(set(MAP)|set(MAP_PY))}', None
key, ota = key.encode(), bool(ota) if ota else False
Expand Down

0 comments on commit 8496633

Please sign in to comment.