v1.6.1

Localhost Binding

Last updated


Which addresses the daemon listens on, and which requests it refuses before any handler runs.
The HTTP server listens on the loopback addresses 127.0.0.1:17989 and [::1]:17989, so by default LAN clients cannot reach the daemon. Since v1.5.0 the LAN access switch (compiled only into make build ENABLE_LAN=1 binaries since v1.5.1; a default build cannot open the API to the LAN; lan_access_enabled in config.json, /config → LAN access in the TUI, which asks for confirmation before turning it on, or Web UI System → Security; off by default) changes that: the daemon watches config.json and, while the switch is on, also listens on port 17989 at every private or IPv4 link-local interface address (app.SyncLANListeners; the loopback listeners are left as they are), closing those listeners again when it is turned off. A LAN client then reaches the API without any password, so leave the switch off when you are done. The web dashboard is embedded into the binary and served from / by that same daemon, so the usual browser origin is your own machine. Since v1.5.0 every route first passes routes.hostOnly: the Host header must be localhost, 127.0.0.1 or ::1 (any port), otherwise the request gets 403 [Denied] host: ..., which stops a DNS-rebinding page whose own domain resolves to 127.0.0.1. CORS middleware accepts loopback origins (localhost, 127.0.0.1, ::1) and answers Chrome Private Network Access with Access-Control-Allow-Private-Network. The two hosted origins it used to accept, https://web.agenvoy.com and https://agenvoy-board.pardn.workers.dev, were removed in v1.0.17 — use the dashboard the daemon serves at /.
Endpoints that touch credentials, config files, or process state carry an extra localhostOnly() guard on top of the bind. It checks the connection's remote address (127.0.0.1 / ::1), not the Origin header. While LAN access is on, Host, Origin and the localhostOnly() remote address also accept an IP literal inside one of those interfaces' subnets (never a domain name).
CORS only stops a page from reading a response, not from sending a request, so since v1.3.11 the daemon also refuses cross-site writes: a POST, PUT, PATCH or DELETE whose Origin header names a host other than localhost, 127.0.0.1 or ::1 gets 403 [Denied] origin: ... before any handler runs (a request without Origin, such as curl, is unaffected). POST /v1/send and POST /v1/chat/completions also require Content-Type: application/json and answer anything else with 415, which closes the text/plain simple request that needs no preflight. enable_sandbox on /v1/send was removed; use agen -p --skip-sandbox in a terminal (Removed in v1.5.0). agen -p now calls app.Send in its own process instead of going over HTTP, and HTTP has no field that leaves the sandbox, because a sandboxed hook, script tool or network: true command can reach the API from loopback.
Since v1.2.0 the TUI does not run agents itself; it talks to the daemon over the Unix socket ~/.config/agenvoy/daemon.sock, created with mode 0600 so only the owning user can connect. Since v1.5.0 the HTTP server also has a 10-second read-header timeout (HTTP_READ_HEADER_TIMEOUT), and the daemon log, generated images and audio are written with mode 0600 and background job log directories with 0700.