weakboson revisou este gist 3 months ago. Ir para a revisão
1 file changed, 6 insertions, 3 deletions
parse-ss-url.py
| @@ -4,8 +4,11 @@ def parse_url(url): | |||
| 4 | 4 | return None | |
| 5 | 5 | secret, addr = loc.split("@") | |
| 6 | 6 | if ":" not in secret: | |
| 7 | - | secret = base64.urlsafe_b64decode(secret) | |
| 8 | - | cipher, key = secret.split(":") | |
| 7 | + | secret = base64.urlsafe_b64decode(secret).decode("ascii") | |
| 8 | + | cipher, key = secret.split(":", 1) | |
| 9 | + | else: | |
| 10 | + | cipher, key = secret.split(":", 1) | |
| 11 | + | key = unquote(key) | |
| 9 | 12 | host, port = addr.split(":") | |
| 10 | 13 | frag = unquote(frag) | |
| 11 | - | return host, port, cipher, key, frag | |
| 14 | + | return host, port, cipher, key, frag | |
weakboson revisou este gist 3 months ago. Ir para a revisão
1 file changed, 2 insertions, 2 deletions
parse-ss-url.py
| @@ -1,9 +1,9 @@ | |||
| 1 | 1 | def parse_url(url): | |
| 2 | 2 | scheme, loc, path, query, frag = urlsplit(url) | |
| 3 | - | if not scheme == "ss": | |
| 3 | + | if scheme != "ss": | |
| 4 | 4 | return None | |
| 5 | 5 | secret, addr = loc.split("@") | |
| 6 | - | if not ":" in secret: | |
| 6 | + | if ":" not in secret: | |
| 7 | 7 | secret = base64.urlsafe_b64decode(secret) | |
| 8 | 8 | cipher, key = secret.split(":") | |
| 9 | 9 | host, port = addr.split(":") | |
weakboson revisou este gist 3 months ago. Ir para a revisão
1 file changed, 11 insertions
parse-ss-url.py(arquivo criado)
| @@ -0,0 +1,11 @@ | |||
| 1 | + | def parse_url(url): | |
| 2 | + | scheme, loc, path, query, frag = urlsplit(url) | |
| 3 | + | if not scheme == "ss": | |
| 4 | + | return None | |
| 5 | + | secret, addr = loc.split("@") | |
| 6 | + | if not ":" in secret: | |
| 7 | + | secret = base64.urlsafe_b64decode(secret) | |
| 8 | + | cipher, key = secret.split(":") | |
| 9 | + | host, port = addr.split(":") | |
| 10 | + | frag = unquote(frag) | |
| 11 | + | return host, port, cipher, key, frag | |