🚀 MVP Proposal: fastn-p2p Daemon
This issue tracks implementation of a centralized P2P daemon that addresses security, performance, and resource management issues with the current direct P2P approach.
Requirements Summary
- Security: Eliminate secret key sharing with clients
- Performance: Reduce P2P connection overhead through reuse
- Resource Management: Avoid port conflicts from multiple CLI instances
- Architecture: Simple Unix domain socket communication (no WASM for MVP)
Architecture Overview
┌─────────────────┐ Unix Domain Socket ┌──────────────────┐
│ CLI Client │◄─────────────────────────►│ fastn-daemon │
│ (no secrets) │ │ (has secrets) │
└─────────────────┘ └──────────────────┘
│
▼
┌──────────────────┐
│ P2P Network │
│ (persistent) │
└──────────────────┘
Core Components
1. fastn-daemon Binary
- Single background process per user
- Exclusive secret key access
- Persistent P2P connection management
- Unix socket listener (
~/.fastn/daemon.sock)
- Built-in protocol handlers (compiled Rust, not WASM)
2. Client CLI
- Zero secret key access
- Unix socket communication only
- JSON + streaming protocol
- Backward compatible commands
3. Unix Socket Protocol
Request/Response (JSON):
// Request
{
"id": "uuid",
"type": "call",
"target": "peer_id52",
"protocol": "Echo",
"data": {"message": "hello"}
}
// Response
{
"id": "uuid",
"status": "ok|error",
"data": {...} | "error_msg"
}
Bidirectional Streaming:
// Stream request
{
"id": "uuid",
"type": "stream",
"target": "peer_id52",
"protocol": "Shell",
"data": {"command": "interactive_shell"}
}
// Stream established response
{"id": "uuid", "status": "streaming"}
// Then raw bidirectional data flows over the Unix socket
MVP Scope
✅ Included
- Basic daemon process with socket listener
- Request/response pattern support
- Simple bidirectional streaming (shell, file transfer)
- Built-in protocols from examples/ (Echo, Shell, FileTransfer)
- P2P connection pooling and reuse
- Simple authentication via Unix socket permissions
- Daemon management commands
❌ Not in MVP
- WASM plugin system
- iptables integration
- Complex security sandboxing
- Auto-installation features
- Complex streaming protocols (focus on simple patterns)
Implementation Phases
Phase 1: Basic Daemon
Phase 2: Streaming Support
Phase 3: Client Integration
Phase 4: Protocol Expansion
Benefits
- Security: Secret keys isolated in daemon process
- Performance: Connection reuse eliminates repeated handshakes
- Flexibility: Both request/response and streaming patterns
- Simplicity: Unix sockets + simple protocols
- Compatibility: Existing CLI commands continue working
This MVP delivers secure, performant P2P communication through centralized connection management with support for both simple request/response and bidirectional streaming patterns.
🚀 MVP Proposal: fastn-p2p Daemon
This issue tracks implementation of a centralized P2P daemon that addresses security, performance, and resource management issues with the current direct P2P approach.
Requirements Summary
Architecture Overview
Core Components
1. fastn-daemon Binary
~/.fastn/daemon.sock)2. Client CLI
3. Unix Socket Protocol
Request/Response (JSON):
Bidirectional Streaming:
MVP Scope
✅ Included
❌ Not in MVP
Implementation Phases
Phase 1: Basic Daemon
fastn-daemonbinary with Unix socket listenerPhase 2: Streaming Support
Phase 3: Client Integration
fastn daemon start/stop/status)Phase 4: Protocol Expansion
Benefits
This MVP delivers secure, performant P2P communication through centralized connection management with support for both simple request/response and bidirectional streaming patterns.