-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Design the sync transport layer as pluggable, with three modes:
| Priority | Transport | Environment | Details |
|---|---|---|---|
| Primary | Azure relay | Corporate / anywhere | WSS on port 443, looks like normal HTTPS traffic |
| Backup | Vercel relay | Corporate / anywhere | Edge WebSocket functions, free tier, *.vercel.app domain |
| Direct | Hyperswarm | Home/personal only | DHT + UDP holepunching — triggers corporate IDS, not safe for work networks |
Motivation
Hyperswarm direct P2P is excellent for home networks but uses UDP on non-standard ports + DHT traffic that resembles BitTorrent. Corporate IDS/firewalls will flag it. We need a corporate-safe transport that looks like normal web traffic.
PluresDB already has Azure relay infrastructure (azure/ directory — Bicep templates, deploy/destroy scripts, relay tests). This issue extends that into a proper pluggable transport system.
Design
Transport Trait (Rust)
#[async_trait]
pub trait SyncTransport: Send + Sync {
async fn connect(&self, topic: &[u8; 32]) -> Result<Box<dyn AsyncStream>>;
async fn listen(&self, topic: &[u8; 32]) -> Result<Box<dyn AsyncStream>>;
fn name(&self) -> &str;
}Three Implementations
1. RelayTransport (Azure — primary)
- Connects via WSS to Azure Container Instance relay
- Port 443, TLS — indistinguishable from normal HTTPS
- Relay matches peers by topic hash, pipes encrypted bytes
- Uses existing
azure/infrastructure/Bicep templates - Relay is stateless, horizontally scalable
2. VercelRelayTransport (backup)
- Same protocol as Azure relay but hosted on Vercel edge functions
*.vercel.appdomain — universally whitelisted- Free tier sufficient for signaling + small data relay
- Deploy:
vercel deployfrom a small project
3. HyperswarmTransport (direct)
- Full Hyperswarm DHT + UDP holepunching
- Best throughput, no relay dependency
- Only for home/personal networks
4. AutoTransport (recommended default)
- Try Hyperswarm direct first
- If UDP blocked → fall back to Azure relay
- If Azure unavailable → fall back to Vercel relay
Connection Flow (relay modes)
Phase 1: Discovery via relay (corporate-safe)
A ──wss:443──► Relay ◄──wss:443── B
match by topic hash
exchange connection info
Phase 2: Upgrade to direct (if possible)
A ◄─────── direct connection ──────► B
(relay dropped)
Phase 3: Fallback (if direct fails)
A ──wss:443──► Relay ──wss:443──► B
(relay pipes bytes)
Config
{
"syncTransport": "auto",
"syncRelay": "wss://pluresdb-relay.azurewebsites.net",
"syncRelayFallback": "wss://pluresdb-relay.vercel.app",
"syncKey": "<shared-secret>"
}Implementation Plan
- Define transport trait in
hyperswarm-rscrate (plures/hyperswarm) - Build Azure WSS relay server (extend existing
azure/infra) - Build Vercel relay (new small project, ~100 LOC)
- Implement RelayTransport (JS first, then Rust)
- Implement AutoTransport with fallback chain
- Update superlocalmemory to use pluggable transport config
- Deploy Azure relay to test environment
- Deploy Vercel relay as backup
- Integration tests across all three transports
Related
- feat: P2P sync transport via Hyperswarm (DHT discovery + NAT holepunching) #70 — P2P sync transport via Hyperswarm
- Rust implementation roadmap hyperswarm#1 — Rust implementation roadmap
azure/directory — existing relay infrastructure
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request