Repository navigation
connect-next 3/5: Node gate and frps on Fly - #6049
Merged
Merged
Conversation
SawyerHood
force-pushed
the
connect-next/3-gate
branch
from
October 21, 2026 16:43
f734004 to
c4f85a4
Compare
SawyerHood
force-pushed
the
connect-next/3-gate
branch
from
October 21, 2026 16:50
c4f85a4 to
b361f43
Compare
apps/connect-next: visitor admission with the Cloudflare gate's rules, frps behind server-plugin hooks, per-request gate assertions, batched account API lookups and presence, answer cache, regions with fly-replay and private network forwarding, graceful drain, Dockerfile, fly.toml, manual deploy workflow, and the local end-to-end scripts.
SawyerHood
force-pushed
the
connect-next/3-gate
branch
from
October 21, 2026 16:54
b361f43 to
676889f
Compare
SawyerHood
added a commit
that referenced
this pull request
Oct 21, 2026
## Human comments ## What was wrong With the account API (PR 1), the server ingress (PR 2) and the gate (PR 3) in place, nothing on a bb server dials the gate yet. bb needs an opt-in builtin plugin that runs `frpc` to the gate with the server's link credential, points it at the tunnel ingress, and serves the server machine's port shares on the next address too. PR 4 of 5 (stack: account API → server ingress → gate → plugin → machine tunnels). Based on #6049. ## What changed - `packages/frp-client` (`@bb/frp-client`): frpc download and SHA-256 verification (frp 0.71.0), config writing (wss with a trusted CA file and server name, credential in metadatas, proxies), log redaction and an `FrpcSupervisor` (restart with backoff, hot reload, login-refusal handling); `./testing` fixtures that run real frps and gate hooks. - `plugins/connect-next` (builtin `bb--connect-next`, disabled by default; registered in `builtin-registry.ts`, bundled plugins, `bb-official.json`, the bundled marketplace): requires `bbPluginSdk >=0.6.66` (the ingress member from PR 2); setting `enabled`, RPC `status`/`setEnabled`, CLI `bb connect-next status|on|off`, a settings section with state, address and shared ports, and a skill. The next domain follows the bb account: `next.<host of the account's base URL>` (`BB_CONNECT_NEXT_SERVER` and `BB_CONNECT_FRPC` override the server and binary). It opens the server's tunnel ingress through `bb.server.internal_DO_NOT_USE_openTunnelIngress` and proxies `<label>` to it and `<label>--<port>` straight to `127.0.0.1:<port>` for shares. - `plugins/bb-account`: `bb-account.v1.connectCredential` also answers `bb--connect-next` (read-only; adopting and refusing a pairing stay connect-only). - `plugins/connect`: `connect.internal_DO_NOT_USE.serverShares` / `waitForServerSharesChange` (long poll, answers only `bb--connect-next`), and share listings carry `nextUrl` for server-machine shares while connect next is on (`bb connect expose` prints it on a second line). - `apps/server`: the real-frps tunnel ingress test (moved here from PR 2 because it drives the plugin's frpc). - `docs/configuration.md` (Connect next section), `turbo.json` (plugin typecheck needs the SDK types). - Fix from the staging test: the settings section description, the `enabled` setting and the plugin description no longer hard-code `next.getbb.app` (wrong on staging, `next.vibecodethis.site`); they say `next.<your bb account's domain>` and the section shows the address derived from the account. ## How you verified - `pnpm exec turbo run typecheck --filter='...[connect-next/3-gate]'`: 109/109 tasks pass. - `pnpm exec turbo run test --filter='[connect-next/3-gate]'` (turbo.json changed, so every package ran): all green except failures that are unrelated to this change and pass on rerun or fail on main for the machine: `@bb/server` timeouts under full-repo load in `timeline-in-turn-window`, `plugin-native-server-loading`, `plugin-service` (75/75 when rerun), `@bb/host-daemon` `command-discovery` (stray `/tmp/.git` on bee; 28/28 with `TMPDIR` outside `/tmp`), `@bb/scripts` `ci-bun` (no `zip` binary on bee). Relevant counts: `@bb/frp-client` 38/38, `bb-plugin-bb--connect-next` 26/26 (incl. the new copy test: fails with the old `(next.getbb.app)` copy), `bb-plugin-connect` 141/141, `bb-plugin-bb-account` 61/61, `@bb/server` 3,637 passed (incl. real frps + plugin frpc through the ingress). - `oxfmt --check`, `pnpm lint`: clean. - Local end to end: results on PR 5. > AGENT GENERATED
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
bb connect next needs its data plane: a gate on Fly that admits visitors to
https://<label>.next.getbb.appwith every rule the Cloudflare gate applies, terminates the frp tunnels bb machines dial, signs a per-request assertion for the server's ingress (PR 2), and routes a visitor to whichever Fly machine holds the label's tunnel.PR 3 of 5 (stack: account API → server ingress → gate → plugin → machine tunnels). Based on #6048.
What changed
apps/connect-next(Fly appbb-connect-next): Node HTTP gate plusfrps0.71.0 as a loopback child (bind, vhost and server-plugin hooksLogin/NewProxy/CloseProxy/Ping). It pipeswss://tunnel.<domain>/~!frpto frps, checks frp logins against the account API (a client may only claim its own label and shares), admits visitors with the Cloudflare gate's rules (owner session, desktop session, machine credential, next-resource MCP OAuth, Origin refusal, header/cookie stripping, Set-Cookie filtering, offline page with a 15 s redial grace), signs an Ed25519x-bb-gate-assertionper request and WebSocket, and refreshes sessions like the Cloudflare gate.fly-replay: elsewhere=true, WebSocket close frames for frp sockets on shutdown, hard exit inside Fly'skill_timeout, open-file limit raised to 65,536.src/regions.ts,src/peer-server.ts): peers over Fly's private network (PEER_SECRET), announcements and lookups,fly-replayto the holder with HMAC'd state, private-network forwarding for bodies Fly cannot replay, duplicate-tunnel resolution.fly.toml[[vm]]isperformance-2x/ 4 GB:flyctl deployapplies it to every machine, and the load test showed shared CPUs cannot carry the gate.docs/connect-next.md(Machine size, Machine plan) says all regions use that size and that staging overrides it with--vm-size shared-cpu-2x --vm-memory 1024on its deploy command.Dockerfile, workflow.github/workflows/deploy-connect-next.yml(manualDeploy Connect Next, pinned flyctl SHA-256).scripts/e2e-local.sh(+e2e-local.ts,e2e-peer-gate.ts): the whole path on one machine; it needs the plugin (PR 4) and machine tunnels (PR 5) to pass fully.No production deploy happens on merge: the workflow is manual.
How you verified
pnpm exec turbo run typecheck test --filter=@bb/connect-next: 87/87 tests (units, plus realfrps/frpcagainst a stand-in account API and bb server intest/gate.e2e.test.ts, the Fly replay stand-in intest/fly.ts).oxfmt --check,pnpm lint: clean.bb-connect-next-staging,next.vibecodethis.site): 2,500 real frpc tunnels. Before the load fixes a shared-cpu-2x 1GB machine sustained only ~30–40 req/s (CPU throttled), performance-2x 4GB held 2,500 tunnels at ~280 req/s with ~1.3× CPU headroom, and the account API was flooded by presence writes. After the fixes: visitor errors from the gate went from ~0.4% to 0, Worker load fell ~15×, no frp Login waits ran out on a mass reconnect, and a stop with 2,294 tunnels took 0.7 s. Details indocs/connect-next.md(Presence, shutdown and limits; Regions).