d3fc6f2bfada18e6ae7887b79ed1e4c650ca37e1
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6c201095d8 |
gateway: in Docker, other containers on the host are shown the host's Docker bridge address
jiezhengj (Discord #feedback) runs magpie in Docker on a NAS at 192.168.31.218. The web UI's host address, http://192.168.31.218:3425, works for other devices. Other containers on the NAS couldn't use it, and not the container's own 172.17.0.x either. What works for them is the host's Docker bridge address, http://172.17.0.1:3425. On Linux, host.docker.internal is there only in a container given extra_hosts. magpie showed no such address. - gateway.ContainerHostURL: in a container on a bridge network, the gateway of /proc/net/route's default route (172.17.0.1 on the default bridge, a compose network's own otherwise), on the gateway's port. It is "" outside a container and on the host's network (`network_mode: host`, told by the host's docker0/br-*/veth*/podman* interfaces). In that case ContainerAddrs is false too, since the addresses are the host's own. - The GUI gets it as /api/providers' gateway.containerHost, /api/settings' lanContainerHost and boot's sideGateway.containerHost. - settings.js lanShown is fed by the new gwLAN(g) for Gateway, Connect, the sidebar and the key page. Each case lists: - Opened at the host: the host's address first, then the bridge address, labelled "Other containers on this host". - At localhost: the bridge address alone, with that label, and a line that the host's own is MAGPIE_PUBLIC_URL's. - No default route: as before. The container's own 172.17.0.x is no longer offered beside them. The sidebar line and the key page prefer an address other machines reach. The scheme comes from the URL, not a hard-coded http. Three new strings are in zh, zh-TW, ja and de. - CLI: `magpie web` and the share banner print "other containers on this host <url>". - docs/reference.md and site docs/docker (en, zh, ja): the log example and a new "Other containers on the same host" paragraph. Run on mote, at this change on |
||
|
|
e056779a67 |
gui: the app serves its page to a browser, behind its key (Settings › Browser access)
jiakun_zhao on X ran `magpie web` in a terminal beside the desktop app, to manage it through a Cloudflare tunnel. Settings › Network and sharing › Browser access now has the app serve the same page itself: Off, This computer (127.0.0.1, for a tunnel or SSH forward) or Local network. Access is magpie web's, unchanged: the key in the link is traded for the cookie (webGuard), the allow list holds, and the gateway's client routes on the page's port need a gateway key (onePort). A rebound Host and Origin: null get no cookie. There is no way to serve it without the key. The key and choice live in web-page.json (0600) beside settings.json, so a sync never carries them. GET/POST /api/web-page are the app windows' alone: a browser on the page can't read the key or turn the page off. A busy port (magpie web, the magpie before an update) is tried every 4s; `magpie web` on the same port opens the app's link instead. Run at d43b7c40d (this change on |
||
|
|
a3d4f8c5c4 |
cli: magpie serve and magpie web give what they start the user's node too (#3803)
|
||
|
|
d9ca84a2f4 |
gateway: built-in TLS, magpie serve/web/daemon install --tls-cert --tls-key, reloaded on renewal (RoderickZH)
magpie serve, magpie web and magpie daemon install take --tls-cert <file> --tls-key <file> (or MAGPIE_TLS_CERT / MAGPIE_TLS_KEY). The gateway and the web UI on its listener then serve HTTPS to other computers. Without them nothing changes. - Half a pair, a file that doesn't parse, or a flag with no value is refused at start with a message naming the missing flag. - The pair is re-read when either file's mtime or size changes (certbot renewal), with no restart. A renewal that doesn't parse keeps the certificate already served and is logged once. - Other computers get HTTPS only. Plain HTTP from them gets net/http's 400 "Client sent an HTTP request to an HTTPS server". - This computer (loopback, or a peer address equal to the local one) may still use plain http on the same port. Its connections are sniffed on their own goroutine (a first byte of 0x16 is TLS) for up to 10s, so a silent client holds nobody else up. gateway.URL() stays http://127.0.0.1:<port>, which agents, MCP servers, ServedBy, the healthcheck and daemon status all use, and no certificate covers loopback. - WSL NAT and containers count as other computers. - ALPN is http/1.1 only (hijacked connections and websockets need it), with TLS 1.2 as the minimum. - Printed links, LAN addresses, publicURL, the serve/web banners and daemon install show https:// for other computers' addresses. - The DNS-rebinding Host checks (foreignPage, rebound, the MCP loopbackHost) don't depend on the scheme and are unchanged. - daemon install carries MAGPIE_TLS_* into the unit or plist. A reinstall or `daemon web on` that names no certificate keeps the installed pair, and --no-tls removes it. - Docs: reference.md gets an HTTPS section that names Caddy as the alternative, gateway-routing.md gets a TLS row, and docker.html (en, zh, ja) gets the env rows. What was run: - New tests: internal/gateway/tls_test.go (others HTTPS-only, this computer both, a silent local client holds no other, renewed certificate served, CheckTLS, addresses, Relisten keeps TLS), internal/cli/tls_cli_test.go and daemon TestInstallCarriesTLS (linux and darwin, paths with space, %, & and "). - Each was broken by hand and went red: no wrap in listen, no reload, a synchronous sniff, a bad renewal dropping the certificate, http in publicURL or the pinned LANURLs, the carried entries removed, and keepTLS as a no-op. - Real use under a sandbox HOME, with a self-signed pair, on 0.0.0.0:3461: - Half a pair, a garbage certificate, a flag with no value, and the env set to half a pair each exit 1 with the message. - curl -k https://127.0.0.1 and https://<LAN IP>/v1/models with a key: 200. Plain http on loopback: 200. - The cert files were swapped for a second pair while it ran. openssl s_client then showed the new CN and serial, and curl --cacert with the new pair got 200. A junk key file then kept the second pair, logged once. - From the Windows box over the LAN: plain http got 400; https with the key got 200, and without it 401. - magpie web --addr 0.0.0.0:3462: https network links. From Windows, http got 400 and https with the key got 303. - gofmt -l clean. go vet passed on darwin, GOOS=linux -tags nogui and GOOS=windows. - go test -tags nogui for ./internal/cli, ./internal/daemon, and the TLS tests of ./internal/gateway and ./internal/gui: all pass at the rebased head. - Two reds in the full suite (`go test -tags nogui ./...`) are the same on origin/main f074996d9; both are filed: - TestGatewayHeldByAContainer failed 2 of 5 there (#2107). - The gateway package runs past go test's default 10m under load: 1208s on main and 1221s here, both passing with -timeout 40m (#2108). |
||
|
|
82f3befd29 |
daemon: magpie daemon install --web serves the browser page from the service, with a link that lasts (HuanCheng Bai)
HuanCheng Bai on Discord runs `magpie daemon` on a Linux server and asked
for the daemon to serve the web page too, or for an option to turn it on.
`magpie web` run beside it is a second process, and he read it as not
seeing the daemon's state.
- `magpie serve --web[=host:port]` serves the gateway and `magpie web`'s
page from one process (stats, StartWeb, Wait). The default page address
is 127.0.0.1:3430. Any other argument is refused, where before it was
ignored.
- `magpie daemon install --web | --lan | --addr host:port | --no-web` and
`magpie daemon web [on|off] [--lan] [--addr host:port]`. The unit's
ExecStart and the plist's ProgramArguments become `serve --web=<addr>`,
and the key goes into the 0600 file's environment as MAGPIE_WEB_KEY. The
key is made once. A reinstall with no flags keeps the page and its key
(read back from the file by daemon.Web), so the link survives restarts
and reinstalls. `web off` drops it. MAGPIE_WEB_KEY in the shell, when
set, is used and checked like magpie web's. The page defaults to
loopback; --lan or a non-loopback --addr prints the network links and
magpie web --lan's warning.
- `magpie daemon status`, install and `daemon web` print the page's link.
- `magpie web` while the service serves a page prints that page's link and
exits. Beside a gateway another magpie serves, it says so and points to
`magpie daemon web on`.
- docs/reference.md (the service section and the Use list), and the
site's start page (en, zh, ja). The READMEs don't cover the daemon.
Run:
- Tests: TestInstallWithWeb (systemd and launchd, plutil lint, read back,
reinstall without the page, the shell's key not carried, no key
refused), TestWebNotInstalled, TestParseDaemon, TestWebOptions,
TestDaemonStatusPrintsPage and TestServeArgs. Each of these went red
with its line reverted by hand: withKey, prevKey in webOptions, and the
status page line.
- Sandbox HOME with a fake launchctl:
- `daemon install --web --lan` wrote a 0600 plist with
`serve --web=0.0.0.0:3430` and the key. plutil said OK, and it printed
the link, the network links and the warning.
- Reinstalling with no flags kept the key. `daemon status` showed the
link.
- `daemon web off` / `daemon web` / `daemon web on` behaved as above,
with a new key after off.
- `daemon web bogus` and `serve --lan` gave the usage errors.
- `serve --web=127.0.0.1:3462` served the gateway (3461) and the page in
one process. The page answered 200 with the key and 401 without, and the
page and /v1/models both showed 3 models. `magpie web --no-open` beside
it printed the service's link and exited 0.
- gofmt -l; go vet (gui), and go vet -tags nogui for darwin, linux and
windows; go test -tags nogui ./... in a sandbox HOME.
Not tried: a real systemd on Linux. The unit text is checked by test only.
|
||
|
|
23e764d0e0 |
cli: magpie's commands move from the root into internal/cli; the root keeps only main.go
The root held 89 .go files (30 commands, 59 tests). They move as they are to internal/cli (package cli), with git mv so history follows them. The only code change is main() becoming cli.Main(version): the root's new main.go keeps `var version` in package main, so -ldflags "-X main.version=…" in the Makefile, the Dockerfile and magpie-releases, and every workflow, work unchanged. go-winres's rsrc_windows_*.syso still land next to package main in the root. Tests that read testdata by a root-relative path now go up one level (../plugin/testdata/fake, ../sessions/testdata). Five subsystem doc links point at internal/cli/. Run: - go build ./..., gofmt -l, go vet on darwin, linux and windows (nogui) - builds with tags production, dev, "production nogui"; windows -H windowsgui; linux CGO_ENABLED=0 - make release-cli TARGETS="darwin/arm64 linux/amd64 windows/amd64 android/arm64" VERSION=9.9.9-tidy: all four built, binary prints "magpie 9.9.9-tidy" - docker build --build-arg VERSION=7.7.7-tidy: container prints "magpie 7.7.7-tidy" - go test ./internal/cli (default and nogui): 152 tests, the same count as the root on main - go test ./...: all packages pass (agent, gateway, library, provider timed out at 10m under other sessions' load and passed rerun alone with -timeout 40m; none of them changed) - the built binary in a sandbox HOME: version, help, ls, providers, claude, and an unknown command's error |