Repository navigation
Conversation
5585843 to
67c9756
Compare
strin
left a comment
There was a problem hiding this comment.
Thanks—this is the host-binding approach I'd prefer for #8. Listen/client separation, IP normalization, instance matching and IPv6 URL formatting look useful; five targeted Go tests passed locally.
Before merge, please make the direct rec-mlx serve --host entry point enforce the intended auth policy: require a nonempty API-key file for non-loopback binds, retaining loopback behavior. Add a test rejecting that configuration before constructing the model and a mocked bind test with an explicit key. That follow-up passed 20 local auth/defaults/serving tests; the wildcard dual-stack test was deliberately excluded. Real remote/IPv6 qualification remains pending.
7d9e054 to
b499337
Compare
|
Added logic for the auth check on Additional tests added for cli behavior in Also added a short addition in the |
Summary
rec servealways listened on127.0.0.1, so the model was only reachable from the Mac running it ( #8 ). Folks in that thread had a copy clever solutions, this just adds the host argument. Feel free to close if you had plans to implement in house.This adds a
--host ADDRESSoption so the server can listen on another address. For example,rec serve --host 0.0.0.0lets other machines on a trusted network use the Mac's model from pi, OpenCode or any OpenAI- or Anthropic-compatible client. A warning is written to the terminal on serve that you should only use this on trusted networks.The default is unchanged. Without
--host, rec still listens only on127.0.0.1.🤖 Spec planned by Opus 5.5; implemented by Flint :)
What changed
rec serve --host ADDRESStakes an IPv4 or IPv6 address, such as127.0.0.1,0.0.0.0,192.168.1.5or::.localhostare rejected. Go and Python can resolve a name to different addresses, so the port check, the readiness probe and the engine could disagree.fe80::1%en0) are also rejected, because they can't appear unescaped in a URL.0:0::0becomes::, and::ffff:127.0.0.1becomes127.0.0.1.listenfield for the address the engine binds to.endpointstays the URL that clients on the same Mac use.0.0.0.0and::, the endpoint is the loopback address (127.0.0.1or[::1]), sorec launch,rec launch --argsandrec statuswork unchanged.rec-mlxtakes--hostand binds to it. Python'sThreadingHTTPServeris IPv4-only, so the Server subclass was modified to pick the address family, and for::it also accepts IPv4 clients by clearingIPV6_V6ONLYbefore binding.validateClientStatusnow accepts any IP-address endpoint instead of only127.0.0.1. It still requireshttp, a port and/v1.0.0.0.0or::, it shows a Listen row. For any non-loopback address, it prints a warning: the server is reachable from the network over unencrypted HTTP.rec serve --helpand the README document--host. The README has a collapsible section withmodels.json(pi) andopencode.json(OpenCode 2.x) configs for connecting from another machine.cli/testdata/fake-rec-mlxandtests/data/smoke-mlx-server.pyaccept--host.Security
Requests still need the bearer token from
rec auth token. With a non-loopback--host, the token and all traffic cross the network over plain HTTP. The ready panel warns about this, and the README says to use it only on trusted networks.Testing
go test -race ./...andgo vet ./...pass.make test-enginepasses the engine pytest suite (68 tests) and the smoke test.--hostreaching the engine;::, accepting both IPv4 and IPv6 clients.TestContextReachEnginetoTestHostAndContextReachesEngineto reflect new behavior.rec/flint.tests/protocol_test.pyfails intermittently at its queue-full check with "Connection reset by peer". It fails about as often withmain'sserver.pyas with this branch (3 of 5 runs each). Possibly the issue described in ( Raise the HTTP server's listen backlog to 32 #27 )Instructions for running locally
These steps build this branch and start the model so other computers on your network can use it. I've tested this to confirm it doesn't impact with an actual install of
rec.1. Download this branch
2. Build it (this assumes you've setup build tools)
This takes about 5 to 15 minutes.
The last line it prints should end in
.build/rec-flint. Name chosen to avoid conflict with tests, same binary asrec.3. Start the model
If you already use rec, stop its server first. If this prints an error saying no instance is reachable, nothing was running, which is fine.
Then start the test build:
4. Get the address and key
5. Connect from another computer
On another Mac or Linux computer on the same network, open a terminal. In the command below:
ADDRESSwith the address from step 5;KEYwith the key from step 5.Then run it:
To use the model from pi or OpenCode on that computer, follow Connect pi or OpenCode on another machine in the README.
6. Stop and clean up
rm -rf ~/rec.~/.local/share/rec, where a regular rec install also keeps it.