Commit Graph
2 Commits
Author SHA1 Message Date
yetone 27bf14790f gui: the page's links for other computers are at the gateway's addresses
A user's computer has a static public address from its ISP on the
network card itself (203.236.50.70) as well as a private one
(10.77.70.2). Settings › Network & sharing listed 203.236.50.70 as the
gateway's address but only 10.77.70.2 under "Open magpie in a browser",
and they asked why the two differ. The gateway's list
(gateway.LANURLs) took every IPv4 address on an interface that is up;
the page's (gui.LANAddrs) took private ones only, through
net.InterfaceAddrs, down interfaces included. The page server in LAN
mode listens on 0.0.0.0, so the public address serves it too.

Now one list makes both: gateway.LANHosts, every interface that is up,
IPv4, not loopback or link-local, in the interfaces' order.
gui.LANAddrs (and so NetworkLinks, the CLI's `magpie web` and daemon
links) returns it, MAGPIE_PUBLIC_URL's host still first when set.
The page's links now also show a CGNAT/Tailscale 100.64.x address, as
the gateway's already did.

Run, on mote: go vet ./internal/gateway ./internal/gui ./internal/cli;
GOOS=windows go vet ./internal/gateway ./internal/gui; GOOS=linux go vet
./internal/gateway; go test -run
"LAN|Lan|URL|TLS|Public|Network|Share|Allow|Container"
./internal/gateway ok; go test ./internal/gui ./internal/cli: cli ok,
gui ok but for TestMainWindowCorners/macOS_26_SDK, #3949 (macOS 27,
not about addresses). On xiaomi-gpu (Windows): the gateway's LANHosts,
PublicURL and TLS address tests ok.
New: TestLANHostsKeepAPublicAddress (a stubbed public, private, CGNAT,
link-local, loopback and IPv6 address) and
TestNetworkLinksAtTheGatewaysHosts.
Broken by hand: LANHosts keeping private addresses only, as the page's
list did, turns TestLANHostsKeepAPublicAddress red (got [10.77.70.2]).
Not run: GOOS=linux vet of internal/gui (needs cgo; the WSL box lacks
gtk4 and webkitgtk-6.0 headers); not tried on the reporter's machine.
2026-10-28 19:54:53 +08:00
yetone 171d8dc646 web: behind a reverse proxy, magpie web prints MAGPIE_PUBLIC_URL as the page's link (#372) — with MAGPIE_PUBLIC_URL=https://magpie.example.com the link for other machines was http://magpie.example.com:3430/?k=…, its host on the page's port over plain http, which nothing answers. A public URL with no port of its own is now the link, scheme and path kept; one with a port (a container's published ports, http://<host>:3425) still gives that host on the page's port. TestNetworkLinksPublicURL fails without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-01 21:49:15 +08:00