Turn the client into a background daemon; add per-chunk hash verification
Daemon (src/daemon): a Unix-socket control server holds every room this machine is participating in. "share send"/"share <code>" resolve paths to absolute, ask the daemon to join (auto-starting it if needed), and exit immediately instead of blocking. "share stop" leaves every room and shuts the daemon down; a stale socket from a crashed daemon self-heals on next start. swarm.Client is now a Start/Wait/Stop handle instead of a single blocking Run, so the daemon can hold many rooms concurrently. Also added per-chunk sha256 verification: the original seeder publishes a hash for every chunk alongside the whole-file hash, and each chunk is checked against it the moment it arrives — before it's written to disk or reshared to other peers — rather than only catching corruption after the whole file is assembled.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package daemon
|
||||
|
||||
// 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" or "stop"
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user