diff --git a/clash/clash-darwin-amd b/clash/clash-darwin-amd index 00c876e26..fb554740c 100644 Binary files a/clash/clash-darwin-amd and b/clash/clash-darwin-amd differ diff --git a/clash/clash-darwin-arm b/clash/clash-darwin-arm index fce8cee91..78beffae9 100644 Binary files a/clash/clash-darwin-arm and b/clash/clash-darwin-arm differ diff --git a/clash/clash-linux-amd b/clash/clash-linux-amd index 505181f20..cf641f63a 100644 Binary files a/clash/clash-linux-amd and b/clash/clash-linux-amd differ diff --git a/clash/clash-linux-arm b/clash/clash-linux-arm index 82c1a2613..2a899bd52 100644 Binary files a/clash/clash-linux-arm and b/clash/clash-linux-arm differ diff --git a/clash/clash-windows-amd.exe b/clash/clash-windows-amd.exe index ce13a72db..6000cf166 100644 Binary files a/clash/clash-windows-amd.exe and b/clash/clash-windows-amd.exe differ diff --git a/subscribe/clash.py b/subscribe/clash.py index 9aef017c1..5e9f6f00e 100644 --- a/subscribe/clash.py +++ b/subscribe/clash.py @@ -33,6 +33,14 @@ EXTERNAL_CONTROLLER = "127.0.0.1:9090" +class QuotedStr(str): + pass + + +def quoted_scalar(dumper, data): + return dumper.represent_scalar("tag:yaml.org,2002:str", data, style='"') + + def generate_config(path: str, proxies: list, filename: str) -> list: os.makedirs(path, exist_ok=True) external_config = filter_proxies(proxies) @@ -45,6 +53,10 @@ def generate_config(path: str, proxies: list, filename: str) -> list: config.update(external_config) with open(os.path.join(path, filename), "w+", encoding="utf8") as f: + # avoid mihomo error: invalid REALITY short ID see: https://github.com/MetaCubeX/mihomo/blob/Meta/adapter/outbound/reality.go#L35 + yaml.add_representer(QuotedStr, quoted_scalar) + + # write to file yaml.dump(config, f, allow_unicode=True) return config.get("proxies", []) @@ -498,7 +510,7 @@ def verify(item: dict, mihomo: bool = True) -> bool: if len(short_id) != 8 or not is_hex(short_id): return False - reality_opts["short-id"] = short_id + reality_opts["short-id"] = QuotedStr(short_id) elif item["type"] == "tuic": # mihomo: https://wiki.metacubex.one/config/proxies/tuic token = wrap(item.get("token", "")) diff --git a/subscribe/process.py b/subscribe/process.py index 7b4ff5d0c..564484158 100644 --- a/subscribe/process.py +++ b/subscribe/process.py @@ -642,6 +642,7 @@ def aggregate(args: argparse.Namespace) -> None: source_file, data = "config.yaml", {"proxies": nochecks} filepath = os.path.join(PATH, "subconverter", source_file) with open(filepath, "w+", encoding="utf8") as f: + yaml.add_representer(clash.QuotedStr, clash.quoted_scalar) yaml.dump(data, f, allow_unicode=True) targets = group_conf.get("targets", {})