


























@@ -18,13 +18,45 @@ const multipleListenersHint =
1818describe("ports-format", () => {
1919it.each([
2020[{ commandLine: "ssh -N -L 18789:127.0.0.1:18789 user@host" }, "ssh"],
21+[{ commandLine: "ssh -NL 18789:127.0.0.1:18789 user@host" }, "ssh"],
22+[{ commandLine: "ssh -NfL18789:127.0.0.1:18789 user@host" }, "ssh"],
23+[
24+{ commandLine: '"C:\\Program Files\\Git\\usr\\bin\\ssh.exe" -N -L18789:127.0.0.1:22 host' },
25+"ssh",
26+],
27+[{ commandLine: "ssh -N -L 127.0.0.1:18789:remote:22 host" }, "ssh"],
28+[{ commandLine: "ssh -N -R 18789:localhost:22 host" }, "ssh"],
29+[{ commandLine: "ssh -N -D 18789 host" }, "ssh"],
30+[{ commandLine: "ssh -ND18789 host" }, "ssh"],
31+[{ commandLine: "ssh -N -D 127.0.0.1:18789 host" }, "ssh"],
32+[{ commandLine: "ssh -N -o 'LocalForward 18789 localhost:22' host" }, "ssh"],
33+[{ commandLine: "ssh -N -oLocalForward=127.0.0.1:18789 localhost:22 host" }, "ssh"],
34+[{ commandLine: "ssh -N -o DynamicForward=18789 host" }, "ssh"],
35+[{ command: "ssh", commandLine: "ssh -N host-from-ssh-config" }, "ssh"],
2136[{ command: "ssh" }, "ssh"],
37+// ssh-named processes that do not forward *this* port are not tunnels; the
38+// "close the tunnel / change -L port" remediation does not apply to them.
39+[{ command: "sshd" }, "non_gateway"],
40+[{ command: "sshd-session.exe" }, "non_gateway"],
41+[{ commandLine: "/opt/fast-ssh/server --listen 18789" }, "non_gateway"],
42+// ssh-named non-tunnel that merely mentions the queried port with a colon: there
43+// is no -L/-R forward, so it must not classify as a tunnel or emit the hint.
44+[{ commandLine: "/opt/fast-ssh/server --listen 127.0.0.1:18789" }, "non_gateway"],
45+[{ commandLine: "ssh -N -L 9999:remote:22 host" }, "ssh"],
2246[{ commandLine: "node /Users/me/Projects/openclaw/dist/entry.js gateway" }, "gateway"],
2347[{ commandLine: "python -m http.server 18789" }, "unknown"],
2448] as const)("classifies port listener %j", (listener, expected) => {
2549expect(classifyPortListener(listener, 18789)).toBe(expected);
2650});
275152+it("does not emit the SSH tunnel hint for an ssh-named non-tunnel process", () => {
53+const hints = buildPortHints([{ command: "sshd" }], 18789);
54+expect(hints).not.toContain(
55+"SSH tunnel already bound to this port. Close the tunnel or use a different local port in -L.",
56+);
57+expect(hints).toContain("Another process is listening on this port.");
58+});
59+2860it("builds ordered hints for mixed listener kinds and multiplicity", () => {
2961expect(
3062buildPortHints(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。