Files
share/src/daemon/protocol.go
T
TZGyn 15a6658d1c Add "share status" command and a relay-piped fallback for cross-network peers
status: swarm.Client.Status()/RoomStatus/FileStatus report per-room peer
count and per-file chunk progress; daemon gets a "status" control action;
CLI gets "share status" to display it.

Relay fallback: peers advertising a LAN-only address can't be dialed
directly by peers on a different network. connectToPeer now races a
direct dial against a relay-piped connection (both sides derive the same
pairing key from their two IDs, independent of who arrives first) and
uses whichever succeeds. The relay grows a second, on-demand path
alongside room membership: a "pipe" request pairs two connections on a
key and forwards raw bytes between them from then on, same as the
original relay's behavior before the rendezvous-only redesign, just now
triggered per-pair only when direct connection fails.
2026-07-20 12:27:27 +08:00

29 lines
1001 B
Go

package daemon
import "github.com/tzgyn/share/src/swarm"
// request/response are the only vocabulary spoken over the control
// socket between a CLI invocation and the background daemon.
type request struct {
Action string `json:"action"` // "join", "stop", or "status"
Join *joinRequest `json:"join,omitempty"`
}
// joinRequest asks the daemon to start participating in a room. Paths
// must already be absolute — the daemon may have been started long ago
// from a different working directory than whichever CLI invocation is
// submitting this request.
type joinRequest struct {
RelayAddress string `json:"relay"`
Code string `json:"code"`
Files []string `json:"files,omitempty"`
OutDir string `json:"out,omitempty"`
OneTime bool `json:"oneTime,omitempty"`
}
type response struct {
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
Rooms []swarm.RoomStatus `json:"rooms,omitempty"` // "status" only
}