mirror of
https://github.com/dtzp555-max/ocp.git
synced 2026-07-19 09:44:07 +00:00
Follow-up cleanup from #115's review. isLoopbackBind was defined in server.mjs and copy-pasted into test-features.mjs (with a "keep in sync" comment, because importing server.mjs would run server.listen()). Extracted to a new importable lib/net.mjs; server.mjs and the test now import the one definition, removing the drift surface. Pure refactor — the function body is byte-identical to the prior server.mjs version, the TUI LAN-gate call site is unchanged, and the 8 isLoopbackBind truth-table tests now exercise the real shared function. 181 tests pass. ALIGNMENT.md: touches server.mjs but adds/removes no operation — it relocates an existing (#115) helper into a module. cli.js citation N/A under Rule 2. Independent fresh-context reviewer (opus): APPROVE (Iron Rule 10) — byte-identical body, exactly one definition, wiring + scope correct, no test dropped, scope clean. Closes #125. Co-authored-by: dtzp555 <dtzp555@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
10 lines
476 B
JavaScript
10 lines
476 B
JavaScript
// OCP network helpers — shared so server.mjs and tests use one definition. (issue #125)
|
|
|
|
// A bind address is "loopback" only if it cannot be reached from another host.
|
|
// Any other address (0.0.0.0, ::, a concrete LAN/Tailscale IP, etc.) is
|
|
// network-exposed and must trigger the TUI LAN gate.
|
|
export function isLoopbackBind(addr) {
|
|
return addr === "127.0.0.1" || addr === "::1" || addr === "localhost" ||
|
|
addr === "::ffff:127.0.0.1" || /^127\./.test(addr);
|
|
}
|