Skip to content

Commit

Permalink
add new shadowsocks cipher
Browse files Browse the repository at this point in the history
  • Loading branch information
wzdnzd committed Aug 8, 2024
1 parent 39c1b91 commit c45261e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
36 changes: 30 additions & 6 deletions subscribe/clash.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def proxies_exists(proxy: dict, hosts: dict) -> bool:
return False


SS_SUPPORTED_CIPHERS = [
COMMON_SS_SUPPORTED_CIPHERS = [
"aes-128-gcm",
"aes-192-gcm",
"aes-256-gcm",
Expand All @@ -199,7 +199,31 @@ def proxies_exists(proxy: dict, hosts: dict) -> bool:
"2022-blake3-chacha20-poly1305": 32,
}

MIHOMO_SS_SUPPORTED_CIPHERS = list(MIHOMO_SS_SUPPORTED_CIPHERS_SALT_LEN.keys())
MIHOMO_SS_SUPPORTED_CIPHERS = (
COMMON_SS_SUPPORTED_CIPHERS
+ list(MIHOMO_SS_SUPPORTED_CIPHERS_SALT_LEN.keys())
+ [
"aes-128-ccm",
"aes-192-ccm",
"aes-256-ccm",
"aes-128-gcm-siv",
"aes-256-gcm-siv",
"chacha20",
"chacha8-ietf-poly1305",
"xchacha8-ietf-poly1305",
"lea-128-gcm",
"lea-192-gcm",
"lea-256-gcm",
"rabbit128-poly1305",
"aegis-128l",
"aegis-256",
"aez-384",
"deoxys-ii-256-128",
"none",
]
)

SSR_SUPPORTED_CIPHERS = COMMON_SS_SUPPORTED_CIPHERS + ["dummy", "none"]

SSR_SUPPORTED_OBFS = [
"plain",
Expand Down Expand Up @@ -303,7 +327,7 @@ def verify(item: dict, mihomo: bool = True) -> bool:
authentication = "password"

if item["type"] == "ss":
ciphers = set(SS_SUPPORTED_CIPHERS if not mihomo else SS_SUPPORTED_CIPHERS + MIHOMO_SS_SUPPORTED_CIPHERS)
ciphers = COMMON_SS_SUPPORTED_CIPHERS if not mihomo else MIHOMO_SS_SUPPORTED_CIPHERS
if item["cipher"] not in ciphers:
return False

Expand Down Expand Up @@ -339,7 +363,7 @@ def verify(item: dict, mihomo: bool = True) -> bool:
):
return False
elif item["type"] == "ssr":
if item["cipher"] not in SS_SUPPORTED_CIPHERS:
if item["cipher"] not in SSR_SUPPORTED_CIPHERS:
return False
if item["obfs"] not in SSR_SUPPORTED_OBFS:
return False
Expand All @@ -360,7 +384,7 @@ def verify(item: dict, mihomo: bool = True) -> bool:
return False

# mihomo: https://wiki.metacubex.one/config/proxies/vmess/#cipher
ciphers = set(VMESS_SUPPORTED_CIPHERS + ["zero"] if mihomo else VMESS_SUPPORTED_CIPHERS)
ciphers = VMESS_SUPPORTED_CIPHERS + ["zero"] if mihomo else VMESS_SUPPORTED_CIPHERS
if item["cipher"] not in ciphers:
return False
if "alterId" not in item or not utils.is_number(item["alterId"]):
Expand Down Expand Up @@ -621,7 +645,7 @@ def verify(item: dict, mihomo: bool = True) -> bool:
return False

if utils.is_number(item[authentication]):
item[authentication] = str(item[authentication])
item[authentication] = QuotedStr(item[authentication])

return True
except:
Expand Down
3 changes: 3 additions & 0 deletions subscribe/scripts/v2rayse.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from origin import Origin

import subconverter
from clash import QuotedStr, quoted_scalar

# outbind type
SUPPORT_TYPE = ["ss", "ssr", "vmess", "trojan", "snell", "vless", "hysteria2", "hysteria", "http", "socks5"]
Expand Down Expand Up @@ -293,6 +294,7 @@ def fetch(params: dict) -> list:
generate = os.path.join(datapath, "generate.ini")

with open(filepath, "w+", encoding="utf8") as f:
yaml.add_representer(QuotedStr, quoted_scalar)
yaml.dump(data, f, allow_unicode=True)

if os.path.exists(generate) and os.path.isfile(generate):
Expand All @@ -301,6 +303,7 @@ def fetch(params: dict) -> list:
success = subconverter.generate_conf(generate, artifact, source, dest, "mixed")
if not success:
logger.error(f"[V2RaySE] cannot generate subconverter config file")
yaml.add_representer(QuotedStr, quoted_scalar)
content = yaml.dump(data=data, allow_unicode=True)
else:
_, program = which_bin()
Expand Down

0 comments on commit c45261e

Please sign in to comment.