feat: per-network share directories + isolation test

Each network now carries its own share dir, set at join_network time via
optional share_dir field or updated live with set_share_dir. The global
-share-dir daemon flag becomes a fallback default.

- proto: add ShareDir/DownloadDir to NetworkInfo and IpcMessage
- netmgr: Join accepts shareDir override; SetShareDir updates live
- ipc: wire join_network share_dir and set_share_dir command
- daemon: remove -share-dir from auto-join path (pass "" for default)
- test-network.sh: per-network join with share_dir; isolation verification
  section confirms alice/friends and alice/work share dirs are independent
- test-tui.sh: join_network with share_dir; peer IDs resolved after join

All tests pass: YAW/2.1 FS, share isolation, file transfer, persistence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Fredrik Johansson
2026-06-22 15:13:26 +02:00
parent f437fe94f4
commit d02e18e212
7 changed files with 277 additions and 42 deletions

View File

@@ -217,6 +217,7 @@ const (
CmdLeaveNetwork IpcMsgType = "leave_network"
CmdGetState IpcMsgType = "get_state"
CmdSendFile IpcMsgType = "send_file"
CmdSetShareDir IpcMsgType = "set_share_dir" // set per-network share directory at runtime
CmdGenerateInvite IpcMsgType = "generate_invite"
CmdGetFileList IpcMsgType = "get_file_list"
@@ -241,6 +242,8 @@ type NetworkInfo struct {
NetworkID string `json:"network_id"`
NetworkName string `json:"network_name"`
LocalPeer *PeerInfo `json:"local_peer,omitempty"`
ShareDir string `json:"share_dir,omitempty"` // absolute path; empty = not sharing
DownloadDir string `json:"download_dir,omitempty"` // absolute path for received files
}
// IpcMessage covers both commands and events.
@@ -258,8 +261,9 @@ type IpcMessage struct {
// join_network / leave_network
NetworkName string `json:"network_name,omitempty"`
ShareDir string `json:"share_dir,omitempty"` // optional per-network share directory
// send_file
// send_file / set_share_dir / file_complete path
Path string `json:"path,omitempty"`
// events