# -*- coding: utf-8 -*- r'''查「默认中转服务器」在源码和已构建成品里各是什么值。 用户报告:软件默认中转服务器应该是**空白**、让用户自己填。 但给我的版本是填好的,上传的版本是清空的 —— 两者不一致。 先把所有源头找出来,看清楚再改。 ''' from __future__ import annotations import re import zipfile from pathlib import Path ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote") SOURCES = [ ("windows/lanremote/server.py", r"DEFAULT_RELAY_URL\s*=\s*(.+)"), ("windows/lanremote/relay.py", r"192\.168\.\d+\.\d+:8080"), ("windows/run_agent.py", r"or\s+\"(192\.168[^\"]*|[^\"]*xxmxxs[^\"]*)\""), ("android/src/com/lanremote/watch/MainActivity.java", r"DEFAULT_RELAY_URL\s*=\s*(.+);"), ] print("=" * 70) print(" 一、源码里的默认中转地址") print("=" * 70) for rel, pattern in SOURCES: path = ROOT / rel if not path.is_file(): print(" [不存在] %s" % rel) continue text = path.read_text(encoding="utf-8", errors="replace") hits = re.findall(pattern, text, re.M) print(" %s" % rel) if hits: for h in hits[:4]: h = h if isinstance(h, str) else h[0] print(" %s" % h.strip()[:100]) else: print(" (没匹配到)") print() print("=" * 70) print(" 二、已构建成品里到底是什么") print("=" * 70) # APK apk = ROOT / "dist" / "ykxmz-watch-1.8.2.apk" if apk.is_file(): print(" %s" % apk.name) try: with zipfile.ZipFile(apk) as z: dex = [n for n in z.namelist() if n.endswith(".dex")] found = [] for name in dex: blob = z.read(name) for needle in (b"https://relay.xxmxxs.top", b"192.168.2.156", b"192.168.10.105"): if needle in blob: found.append((name, needle.decode())) if found: for name, needle in sorted(set(found)): print(" %s -> 含 %s" % (name, needle)) else: print(" dex 里没有硬编码的中转地址(默认是空白)") except Exception as exc: # noqa: BLE001 print(" 读 APK 失败: %s" % exc) else: print(" dist/ykxmz-watch-1.8.2.apk 不存在") # exe / onedir exe_dir = ROOT / "dist_exe" / "ykxmz" print() print(" %s" % exe_dir) if exe_dir.is_dir(): hits = [] for f in exe_dir.rglob("*"): if not f.is_file() or f.suffix.lower() not in (".py", ".pyc"): continue try: blob = f.read_bytes() except OSError: continue for needle in (b"192.168.2.156", b"192.168.10.105", b"https://relay.xxmxxs.top"): if needle in blob: hits.append((f.relative_to(exe_dir).as_posix(), needle.decode())) if hits: for name, needle in sorted(set(hits))[:10]: print(" %-50s 含 %s" % (name, needle)) else: print(" 没有硬编码的中转地址") else: print(" 不存在") # 服务端 zip print() srv = ROOT / "dist" / "ykxmz-server-1.8.2.zip" if srv.is_file(): print(" %s" % srv.name) try: with zipfile.ZipFile(srv) as z: for name in z.namelist(): if not name.endswith((".py", ".txt", ".sh")): continue try: text = z.read(name).decode("utf-8", "replace") except Exception: # noqa: BLE001 continue for line in text.splitlines(): if ("192.168.2.156" in line or "192.168.10.105" in line or "relay.xxmxxs.top" in line): print(" %s: %s" % (name, line.strip()[:90])) break except Exception as exc: # noqa: BLE001 print(" 读 zip 失败: %s" % exc) else: print(" dist/ykxmz-server-1.8.2.zip 不存在") print() print("=" * 70) print(" 三、结论") print("=" * 70) print(" 期望:默认中转服务器为**空白**,由用户自己填。") print(" 实际:见上面。凡是出现硬编码地址的地方都要改成空字符串。")