Sfoglia il codice sorgente

change: remove v2ray paths and vmess link tooling

Remove v2ray rendering from the updater, drop v2ray config blocks, delete the vmess link updater script, and align README/workflow/CLAUDE docs to the Sub-Store-only flow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dew-OF-Aurora 6 giorni fa
parent
commit
3eb89e330f
7 ha cambiato i file con 4 aggiunte e 229 eliminazioni
  1. 0 23
      CLAUDE.md
  2. 2 36
      README.md
  3. 0 5
      config.router.json
  4. 0 5
      config.server.json
  5. 1 24
      scripts/domain_updater.py
  6. 0 131
      scripts/update_vmess_links.py
  7. 1 5
      workflow.md

+ 0 - 23
CLAUDE.md

@@ -26,7 +26,6 @@ The old `config.json` and `config.example.json` are deprecated and should not be
 
 ```bash
 env PYTHONPYCACHEPREFIX=/tmp/pycache python3 -m py_compile scripts/domain_updater.py
-env PYTHONPYCACHEPREFIX=/tmp/pycache python3 -m py_compile scripts/update_vmess_links.py
 bash -n scripts/run_update_and_commit.sh
 bash -n scripts/install_debian.sh
 bash -n scripts/uninstall_debian.sh
@@ -67,26 +66,6 @@ bash scripts/run_update_and_commit.sh --force-commit config.server.json
 GIT_FORCE_COMMIT=1 bash scripts/run_update_and_commit.sh config.server.json
 ```
 
-### Update VMess links from selected value
-
-Server mode:
-
-```bash
-python3 scripts/update_vmess_links.py \
-  --input ./nodes.txt \
-  --output ./nodes.updated.txt \
-  --domain-file ./runtime/current_domain.txt
-```
-
-Router mode:
-
-```bash
-python3 scripts/update_vmess_links.py \
-  --input ./nodes.txt \
-  --output ./nodes.updated.txt \
-  --domain-file ./cfip_runtime/current_ip.txt
-```
-
 ### BusyBox router mode
 
 ```bash
@@ -180,7 +159,6 @@ Main blocks:
 - `healthcheck`
 - `selection`
 - `output`
-- `v2ray`
 - `notify`
 
 ### `config.router.json`
@@ -193,7 +171,6 @@ Main blocks:
 - `healthcheck`
 - `selection`
 - `output`
-- `v2ray`
 - `notify`
 
 ### `router_local.conf`

+ 2 - 36
README.md

@@ -29,8 +29,6 @@
   BusyBox `sh` 路由器入口,执行 `cfst` 并写出 `cfip_runtime`
 - `scripts/router_local_http.sh`
   BusyBox `sh` 路由器 HTTP 暴露入口,优先使用 BusyBox `httpd` 暴露运行时文件
-- `scripts/update_vmess_links.py`
-  可选工具,用运行时文件里的值批量替换 `vmess://` 节点
 
 配置文件:
 
@@ -524,39 +522,7 @@ cd /tmp/home/root/vmess-domain-rotator
 nohup sh scripts/router_local_http.sh ./router_local.conf >/tmp/router_http.log 2>&1 &
 ```
 
-## 7. VMess 链接批量替换
-
-如果下游要消费“当前值文件”,可使用 `scripts/update_vmess_links.py`。
-
-服务器模式示例:
-
-```bash
-python3 scripts/update_vmess_links.py \
-  --input ./nodes.txt \
-  --output ./nodes.updated.txt \
-  --domain-file ./runtime/current_domain.txt
-```
-
-路由器/本地 `cfst` 模式示例:
-
-```bash
-python3 scripts/update_vmess_links.py \
-  --input ./nodes.txt \
-  --output ./nodes.updated.txt \
-  --domain-file ./cfip_runtime/current_ip.txt
-```
-
-仅替换匹配名称的节点:
-
-```bash
-python3 scripts/update_vmess_links.py \
-  --input ./nodes.txt \
-  --output ./nodes.updated.txt \
-  --domain-file ./runtime/current_domain.txt \
-  --name-regex "(argo|cf|vm)"
-```
-
-## 8. 常用运维命令
+## 7. 常用运维命令
 
 服务器模式:
 
@@ -577,7 +543,7 @@ cat cfip_runtime/current_ip.txt
 cat cfip_runtime/current_ip.json
 ```
 
-## 9. 注意事项
+## 8. 注意事项
 
 1. 服务器模式和路由器模式的配置不要混用。
 2. `run_update_and_commit.sh` 设计目标是服务器模式;路由器模式默认不走 git 提交。

+ 0 - 5
config.router.json

@@ -51,11 +51,6 @@
     "export_vars_file": "substore_vars.json",
     "substore_value_key": "AUTO_CFIP"
   },
-  "v2ray": {
-    "template_file": "",
-    "output_file": "",
-    "replace_token": "__AUTO_DOMAIN__"
-  },
   "notify": {
     "command": ""
   }

+ 0 - 5
config.server.json

@@ -102,11 +102,6 @@
     "state_file": "state.json",
     "substore_vars_file": "substore_vars.json"
   },
-  "v2ray": {
-    "template_file": "",
-    "output_file": "",
-    "replace_token": "__AUTO_DOMAIN__"
-  },
   "notify": {
     "command": ""
   }

+ 1 - 24
scripts/domain_updater.py

@@ -838,20 +838,6 @@ def check_domains(domains, hc_cfg):
     return results
 
 
-def render_v2ray(template_file, output_file, token, domain):
-    if not template_file or not output_file:
-        return False
-    if not os.path.exists(template_file):
-        return False
-    with open(template_file, "r", encoding="utf-8") as f:
-        tpl = f.read()
-    rendered = tpl.replace(token, domain)
-    os.makedirs(os.path.dirname(output_file), exist_ok=True)
-    with open(output_file, "w", encoding="utf-8") as f:
-        f.write(rendered)
-    return True
-
-
 def run_notify(cmd, domain, status):
     if not cmd:
         return
@@ -938,7 +924,7 @@ def print_output_settings(config_path_abs, cfg):
 
 
 def main():
-    ap = argparse.ArgumentParser(description="Auto select VMess preferred domain")
+    ap = argparse.ArgumentParser(description="Auto select preferred endpoint value")
     ap.add_argument("--config", default="config.server.json", help="Path to config JSON")
     ap.add_argument(
         "--print-output-settings",
@@ -966,7 +952,6 @@ def main():
 
     output_cfg = cfg.get("output", {})
     output_settings = build_output_settings(output_cfg, config_path_abs)
-    v2_cfg = cfg.get("v2ray", {})
     notify_cfg = cfg.get("notify", {})
     selected_text_file = output_settings["selected_text_path"]
     selected_json_file = output_settings["selected_json_path"]
@@ -1056,20 +1041,12 @@ def main():
             },
         )
 
-        rendered = render_v2ray(
-            template_file=v2_cfg.get("template_file", ""),
-            output_file=v2_cfg.get("output_file", ""),
-            token=v2_cfg.get("replace_token", "__AUTO_DOMAIN__"),
-            domain=selected,
-        )
-
         new_state = {
             "updated_at": current_json["updated_at"],
             state_last_good_key: selected,
             "status": status,
             "source_count": len(parsed),
             "checked_count": len(check_results),
-            "rendered_v2ray": rendered,
             "source_type": source_type,
         }
         write_json_file(state_file, new_state)

+ 0 - 131
scripts/update_vmess_links.py

@@ -1,131 +0,0 @@
-#!/usr/bin/env python3
-import argparse
-import base64
-import json
-import os
-import re
-import sys
-
-
-def b64_decode_flexible(s):
-    t = "".join(s.strip().split())
-    pad = (-len(t)) % 4
-    t = t + ("=" * pad)
-    try:
-        return base64.b64decode(t).decode("utf-8", errors="replace")
-    except Exception:
-        return base64.urlsafe_b64decode(t).decode("utf-8", errors="replace")
-
-
-def b64_encode_std(s):
-    return base64.b64encode(s.encode("utf-8")).decode("ascii")
-
-
-def normalize_vmess_payload(payload):
-    clean = "".join(payload.strip().split())
-    pad = (-len(clean)) % 4
-    return clean + ("=" * pad)
-
-
-def update_vmess_line(line, domain, name_rx=None):
-    stripped = line.strip()
-    if not stripped.startswith("vmess://"):
-        return line, False, None
-
-    payload = stripped[len("vmess://") :]
-    try:
-        body = b64_decode_flexible(normalize_vmess_payload(payload))
-        obj = json.loads(body)
-    except Exception as e:
-        return line, False, f"decode_error: {e}"
-
-    ps = str(obj.get("ps", ""))
-    if name_rx is not None and not name_rx.search(ps):
-        return line, False, None
-
-    if str(obj.get("add", "")).strip() == domain:
-        return line, False, None
-
-    obj["add"] = domain
-    encoded = b64_encode_std(json.dumps(obj, ensure_ascii=False, separators=(",", ":")))
-    return f"vmess://{encoded}", True, None
-
-
-def read_domain(args):
-    if args.domain:
-        return args.domain.strip()
-    if not args.domain_file:
-        raise ValueError("must provide --domain or --domain-file")
-    with open(args.domain_file, "r", encoding="utf-8") as f:
-        return f.read().strip()
-
-
-def main():
-    ap = argparse.ArgumentParser(description="Update vmess:// links by replacing add field")
-    ap.add_argument("--input", required=True, help="Input subscription file")
-    ap.add_argument("--output", required=True, help="Output subscription file")
-    ap.add_argument("--domain", default="", help="Target domain to set as add")
-    ap.add_argument("--domain-file", default="./runtime/current_domain.txt", help="Domain file path")
-    ap.add_argument("--name-regex", default="", help="Only update nodes whose ps matches regex")
-    ap.add_argument(
-        "--subscription-base64",
-        action="store_true",
-        help="Input/output file is base64-encoded full subscription content",
-    )
-    args = ap.parse_args()
-
-    domain = read_domain(args)
-    if not domain:
-        print(json.dumps({"status": "error", "error": "empty domain"}, ensure_ascii=True), file=sys.stderr)
-        sys.exit(1)
-
-    name_rx = re.compile(args.name_regex) if args.name_regex else None
-
-    with open(args.input, "r", encoding="utf-8") as f:
-        raw_input = f.read()
-
-    content = raw_input
-    if args.subscription_base64:
-        content = b64_decode_flexible(raw_input)
-
-    lines = content.splitlines()
-    out_lines = []
-    total_vmess = 0
-    updated = 0
-    errors = 0
-
-    for line in lines:
-        if line.strip().startswith("vmess://"):
-            total_vmess += 1
-        new_line, changed, err = update_vmess_line(line, domain, name_rx=name_rx)
-        if changed:
-            updated += 1
-        if err:
-            errors += 1
-        out_lines.append(new_line)
-
-    out_text = "\n".join(out_lines)
-    if content.endswith("\n"):
-        out_text += "\n"
-
-    write_text = out_text
-    if args.subscription_base64:
-        write_text = b64_encode_std(out_text)
-
-    os.makedirs(os.path.dirname(args.output) or ".", exist_ok=True)
-    with open(args.output, "w", encoding="utf-8") as f:
-        f.write(write_text)
-
-    result = {
-        "status": "ok",
-        "domain": domain,
-        "total_vmess": total_vmess,
-        "updated": updated,
-        "errors": errors,
-        "output": args.output,
-    }
-    print(json.dumps(result, ensure_ascii=True))
-
-
-if __name__ == "__main__":
-    main()

+ 1 - 5
workflow.md

@@ -90,9 +90,5 @@ flowchart TD
     A1[runtime/current_domain.json] --> B1[Sub-Store operator]
     A2[cfip_runtime/current_ip.json over LAN] --> B1
     B1 --> C1[read domain or ip]
-    C1 --> C2[rewrite matched vmess server]
-
-    D1[runtime/current_domain.txt] --> E1[update_vmess_links.py]
-    D2[cfip_runtime/current_ip.txt] --> E1
-    E1 --> E2[rewrite vmess add field]
+    C1 --> C2[rewrite matched proxy server]
 ```