Files
magpie/docs
yetone fe61503e60 provider: a Remote magpie whose computer took another address is found on the network
luckymanjc (Discord) uses computer A's magpie from computer B over the
LAN. A's router hands it a new DHCP address after a boot, and B's Remote
magpie, saved at the old one, reached nothing until the address was
typed in again.

When B can't connect to a Remote magpie at all (a dial error, not an
answer), the list fetch (models.go) and the gateway's request (forward
in gateway.go) now call provider.SeekMoved (remote_moved.go). It dials
every address of the old one's /24 and of up to four of B's own private
/24s at A's port (500ms each, 128 at once). The first that lists
/v1/models 200 for the provider's key, and whose list this magpie didn't
make (magpie_via), is A: a LAN caller always needs a gateway key, so
another magpie answers 401. That address is saved as the provider's and
the request is made again there. A name or a public address is never
looked around, an address the user changed meanwhile stands, and a
provider is looked for once a minute at most, callers at once sharing
one look.

Run:
- mote-run go test -count=1 -run 'TestRemoteMagpie|TestLANNeighbours|TestDialable|TestRemoteSelf' ./internal/provider ./internal/gateway: ok
- mote-run go vet, GOOS=windows and GOOS=linux go vet of both packages: ok; gofmt -l clean
- Live: A was a real magpie on mote (10.0.0.121:3511), B a -tags nogui
  build in WSL magpie-desktop (127.0.0.1:3522), sandbox HOMEs. B's
  provider was saved at the dead 10.0.0.250:3511. B's start fetch found
  A ("found at 10.0.0.121:3511, saved there") and a chat answered 200 in
  4.2s. Then, with B running, the address was set dead again: a request
  to office/group/rot found A and answered 200 in 4.4s, saved at .121.

Broken by hand, each red: the gateway hook off (502), the fetch hook off
(fetch error), the self check off (saved at this magpie itself).

Not tried: a real Windows A; a mDNS name (.local) that changed address
(left to the name); A on a different /24 than B. On Linux a dial to a
dead LAN address took ~54s (no route to host) before the look starts;
not changed here.

Reported-by: luckymanjc. (Discord)
2026-11-06 18:11:41 +08:00
..