billion-context 0.1.53-pr.239.81 → 0.1.53-pr.239.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -148,6 +148,23 @@ bili --no-auto-update # disable self-update for this run
148
148
 
149
149
  Flags override env vars and the config file. `bili --help` lists them all.
150
150
 
151
+ ### Remote agents (`--host`)
152
+
153
+ By default the proxy binds `127.0.0.1` and only accepts loopback
154
+ connections. To serve agents on other machines, bind a non-loopback host:
155
+
156
+ ```bash
157
+ bili --host 0.0.0.0 # all interfaces (or use your LAN IP)
158
+ ```
159
+
160
+ - Remote agents point their model `baseURL` at `http://<this-host>:<port>/bili/…`.
161
+ - MITM-mode `CONNECT` then also accepts remote clients — for **whitelisted
162
+ model hosts only**. Blind tunnels to arbitrary hosts stay loopback-only, so
163
+ the proxy can never be used as an open relay.
164
+ - There is **no authentication**: only do this on a trusted LAN or behind a
165
+ firewall. The `/__bili/` management endpoints remain loopback-only.
166
+ - A startup `[security]` warning reminds you of the above.
167
+
151
168
  ### Debugging
152
169
 
153
170
  Three ways to enable verbose logging (priority: flag > env > config):
package/README.zh-CN.md CHANGED
@@ -133,6 +133,21 @@ bili --no-auto-update # 本次启动禁用自动更新
133
133
 
134
134
  参数优先级高于环境变量和配置文件。`bili --help` 列出全部。
135
135
 
136
+ ### 远程 agent(`--host`)
137
+
138
+ 默认绑定 `127.0.0.1`,只接受本机连接。要给其他机器上的 agent 用,绑定非 loopback 地址:
139
+
140
+ ```bash
141
+ bili --host 0.0.0.0 # 所有网卡(或直接用局域网 IP)
142
+ ```
143
+
144
+ - 远程 agent 把模型 `baseURL` 指向 `http://<本机IP>:<端口>/bili/…`。
145
+ - MITM 模式的 `CONNECT` 也会接受远程客户端 —— 但仅限**白名单内的模型域名**;
146
+ 到任意主机的盲隧道仍仅限本机,代理不会沦为开放中继。
147
+ - **没有任何鉴权**: 只应在可信局域网或防火墙内使用。`/__bili/` 管理
148
+ 端点仍仅限本机访问。
149
+ - 启动时的 `[security]` 警告会提醒上述事项。
150
+
136
151
  ### 调试
137
152
 
138
153
  三种方式打开详细日志(优先级:参数 > 环境变量 > 配置):
package/dist/index.js CHANGED
@@ -53228,17 +53228,23 @@ function isMitmHost(host, extraDomains = []) {
53228
53228
  return all.some((d) => h === d || h.endsWith("." + d));
53229
53229
  }
53230
53230
  function setupMitm(server, extraDomains = [], log2 = () => {
53231
- }, resolveProxyUrl) {
53231
+ }, resolveProxyUrl, allowRemoteClients = false) {
53232
53232
  ensureRootCA();
53233
53233
  server.on("connect", (req, clientSocket, head) => {
53234
- if (!isLoopbackAddress(clientSocket.remoteAddress)) {
53235
- log2(`CONNECT ${req.url} rejected: non-loopback client ${clientSocket.remoteAddress}`);
53234
+ const remote = !isLoopbackAddress(clientSocket.remoteAddress);
53235
+ if (remote && !allowRemoteClients) {
53236
+ log2(`CONNECT ${req.url} rejected: non-loopback client ${clientSocket.remoteAddress} (bind a non-loopback --host to allow remote clients)`);
53236
53237
  clientSocket.end("HTTP/1.1 403 Forbidden\r\n\r\n");
53237
53238
  return;
53238
53239
  }
53239
53240
  const { hostname, port } = parseHostPort(req.url ?? "");
53240
53241
  const targetPort = port || 443;
53241
53242
  if (!isMitmHost(hostname, extraDomains)) {
53243
+ if (remote) {
53244
+ log2(`CONNECT ${req.url} rejected: remote client ${clientSocket.remoteAddress} tunneling non-whitelisted host`);
53245
+ clientSocket.end("HTTP/1.1 403 Forbidden\r\n\r\n");
53246
+ return;
53247
+ }
53242
53248
  const proxyUrl = resolveProxyUrl?.(hostname);
53243
53249
  tunnelThrough(clientSocket, hostname, targetPort, head, log2, proxyUrl);
53244
53250
  return;
@@ -54158,10 +54164,12 @@ Content-Length: ${Buffer.byteLength(body)}\r
54158
54164
  );
54159
54165
  });
54160
54166
  if (opts.mitm.enabled) {
54161
- setupMitm(server, opts.mitm.domains, (msg) => log2("info", msg), (host) => resolveProxy(opts.routes, opts.proxy, `https://${host}`, opts.proxyFallback));
54167
+ const allowRemoteConnect = opts.host === "0.0.0.0" || opts.host === "::" || !isLoopbackAddress(opts.host);
54168
+ setupMitm(server, opts.mitm.domains, (msg) => log2("info", msg), (host) => resolveProxy(opts.routes, opts.proxy, `https://${host}`, opts.proxyFallback), allowRemoteConnect);
54162
54169
  }
54163
54170
  server.listen(opts.port, opts.host, () => {
54164
- const displayHost = opts.host === "0.0.0.0" ? "localhost" : opts.host;
54171
+ const nonLoopbackBind = opts.host === "0.0.0.0" || opts.host === "::" || !isLoopbackAddress(opts.host);
54172
+ const displayHost = nonLoopbackBind ? opts.host : opts.host === "0.0.0.0" ? "localhost" : opts.host;
54165
54173
  try {
54166
54174
  fs6.mkdirSync(stateDir(), { recursive: true });
54167
54175
  const originHost = opts.host === "0.0.0.0" || opts.host === "::" || opts.host === "localhost" ? "127.0.0.1" : opts.host.includes(":") && !opts.host.startsWith("[") ? `[${opts.host}]` : opts.host;
@@ -54174,6 +54182,12 @@ Content-Length: ${Buffer.byteLength(body)}\r
54174
54182
  "info",
54175
54183
  `acp-proxy listening on http://${displayHost}:${opts.port} \u2014 web UI: http://${displayHost}:${opts.port}/__bili/ \u2014 zero-config: prefix any baseURL with http://${displayHost}:${opts.port}/bili/` + (nOverrides ? ` \u2014 context overrides for ${nOverrides} upstream URL(s)` : "") + (opts.mitm.enabled ? ` \u2014 MITM proxy on (whitelist)${opts.mitm.domains.length ? ` +${opts.mitm.domains.join(",")}` : ""}` : "")
54176
54184
  );
54185
+ if (nonLoopbackBind) {
54186
+ log2(
54187
+ "warn",
54188
+ `[security] bound to ${opts.host} \u2014 proxy endpoints (/bili/, CONNECT for whitelisted model hosts) are reachable from the network with NO authentication; /__bili/ management endpoints stay loopback-only. Restrict access with a firewall on untrusted networks. Remote agents: point baseURL at http://<this-host>:${opts.port}/bili/`
54189
+ );
54190
+ }
54177
54191
  if (opts.debug) {
54178
54192
  log2("info", `[debug] build features: raw-HTTP-capture(on) | remote_compaction_v2-strip(on) | cert-MITM-launcher(on) | strip-acp-summary(on) \u2014 seeing this line confirms the launcher build (not registry 0.1.34)`);
54179
54193
  }