feat: WebSocket IPC endpoint for web UI
Add --ws-port flag to waste-daemon; when set, starts a WebSocket IPC server alongside the existing TCP one. The web UI connects to this from the browser. Uses nhooyr.io/websocket with localhost-only origin policy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ func main() {
|
||||
dataDir := flag.String("data-dir", "~/.waste", "path to identity/config directory")
|
||||
alias := flag.String("alias", "anon", "display name shown to peers (advisory only)")
|
||||
ipcPort := flag.Int("ipc-port", 17337, "port for local IPC (UI connects here)")
|
||||
wsPort := flag.Int("ws-port", 0, "port for WebSocket IPC (web UI); 0 = disabled")
|
||||
anchorURL := flag.String("anchor", "", "anchor WebSocket URL, e.g. ws://your-vps:17339/ws")
|
||||
shareDir := flag.String("share-dir", "", "directory to share with peers on the network")
|
||||
joinInvite := flag.String("join", "", "waste: invite string — sets anchor URL and auto-joins the network on startup")
|
||||
@@ -81,6 +82,14 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if *wsPort != 0 {
|
||||
go func() {
|
||||
if err := ipc.RunWS(mgr, *wsPort); err != nil {
|
||||
log.Fatalf("ipc ws: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if err := ipc.Run(mgr, *ipcPort); err != nil {
|
||||
log.Fatalf("ipc: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user