Skip to content

fix: allow remote clients when bound to a non-loopback host (#240) - #241

Merged
ranxianglei merged 1 commit into
masterfrom
2026-08-25_remote-host-bind
Aug 25, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-08-25_remote-host-bind

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Model: qwen3.8-27b (vllm)

Fixes #240.

Problem

With host: 0.0.0.0 the HTTP side (/bili/ prefix, health) was already reachable from remote machines, but MITM-mode CONNECT hard-rejected every non-loopback client (the #77 gate in src/mitm.ts) — so remote agents relying on proxy-mode HTTPS got 403.

Change

  • src/mitm.ts — setupMitm gains allowRemoteClients = false:
  • src/server.ts — derives the flag from the bind host (0.0.0.0 / :: / LAN IP ⇒ remote allowed), passes it to setupMitm; startup log now shows the honest bind (0.0.0.0, not masquerading as localhost) and prints a [security] warning on non-loopback binds (no authentication; /__bili/ management endpoints stay loopback-only).
  • tests/mitm.test.ts — 绑定 0.0.0.0 时 MITM CONNECT 为无鉴权开放 TCP 转发 [master/pre-existing] #77 test rewritten as the full remote policy matrix (strict → 403; allowed + api.anthropic.com → 200; allowed + example.com → 403). Runs on the host's real LAN address, skips on boxes without one.
  • Docs — README(.zh-CN).md new "Remote agents (--host)" section (also resolves the dangling "see host note below" pointer); CONFIGURATION(.zh-CN).md host entry extended with the remote-CONNECT policy.

Verification

  • unit: 14/14 in tests/mitm.test.ts (real LAN addr, not skipped); full suite 593/593, typecheck, build green
  • live e2e (--host 0.0.0.0 --port 18788, client via 192.168.10.157): health 200; CONNECT api.anthropic.com → "tunnel established (TLS terminated locally)" (curl then alerts unknown-ca client-side, as expected without the root CA); CONNECT example.com → rejected with "remote client … tunneling non-whitelisted host"

- setupMitm: new allowRemoteClients flag; remote CONNECT accepted only for
  whitelisted model hosts (blind tunnels stay loopback-only — no open relay)
- server: derive the flag from --host; honest 0.0.0.0 display + [security]
  warning on non-loopback binds
- tests: #77 case extended to the full remote policy matrix
- docs: README/CONFIGURATION remote-agents section (en+zh)
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-08-25_remote-host-bind (c4eed7c)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-241

Each push to this PR publishes a new version under the pr-241 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr241.tgz
npm install -g package

This comment is automatically updated on each push.

@ranxianglei
ranxianglei merged commit 7b70419 into master Aug 25, 2026
6 checks passed
@ranxianglei ranxianglei mentioned this pull request Aug 25, 2026
@ranxianglei
ranxianglei deleted the 2026-08-25_remote-host-bind branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can we support host:0.0.0.0

1 participant