Viz is a decentralized P2P voice communication application written in Go. It solves the Symmetric NAT problem through UDP tunneling services, allowing users to choose any intermediary servers, UDP reverse proxies, or use their own VPS.
- π Decentralized Architecture: P2P communication utilizing UDP tunneling services
- π« NAT Bypass: Solves Symmetric NAT problems via UDP relay/tunneling
- π§ Server Flexibility: Works with any UDP-capable tunneling services or custom proxies
- π Low Latency: Migrated from WebSockets (TCP) to raw UDP for optimized real-time voice performance
- ποΈ Modern Audio Core: Powered by the custom
Votline/Go-audioengine featuring an integratedringbuffermodule - β‘ Lock-Free Hotpath: Uses
atomic.Valuefor error/warning communication and aggressive buffer reuse to completely eliminate allocations and mutex contention in the hotpath - π΅ High-Quality Audio: OPUS codec with 32 kbps bitrate
- π¦ Aggressive Compression: OPUS + Zstandard for traffic minimization
- β±οΈ Optimized Chunks: 40ms audio chunks with 320ms batch delay to stay tunnel-friendly
- π Bidirectional Communication: Simultaneous recording and playback
- π‘οΈ Thread-Safe: Safe multi-threaded audio processing with atomic state management
- π Detailed Logging: Zap integration with an optional debug mode
ββββββββββββββββββββ Tunnel Service ββββββββββββββββββββ
β User1 (srv) β βββββββββββββββββββΊ β User2 (clt) β
β β (ngrok/CF/etc) β β
β ββββββββββββββββ β β ββββββββββββββββ β
β β AudioStream β β β β AudioStream β β
β β β β β β β β
β β βββββββββββ β β β β βββββββββββ β β
β β β Buffer β β β β β β Buffer β β β
β β βββββββββββ β β β β βββββββββββ β β
β β ββββββββββββ β β β β ββββββββββββ β β
β β βCompressorβ β β β β βCompressorβ β β
β β ββββββββββββ β β β β ββββββββββββ β β
β ββββββββββββββββ β β ββββββββββββββββ β
ββββββββββββββββββββ ββββββββββββββββββββ
β β
ββββββββββββ NAT Problem βββββββββββββββββ
(Solved via tunneling services)
- User1 starts the application in server mode (
srv) - User1 tunnels their server through any service (ngrok, cloudflare, localhost.run)
- User1 shares the tunnel URL with User2
- User2 starts the client (
clt) and connects to the URL - Connection established through the tunneling service, bypassing Symmetric NAT
- AudioStream: Audio flow management (recording/playback)
- Buffer: Ring buffer for audio data with thread-safe operations
- Compressor: Dual compression (OPUS β Zstandard) for traffic optimization
- Batch: Batching system that packs multiple audio frames (8 frames per batch) into single packets
- Queue: Queue for buffering incoming audio packets
- Server: WebSocket server for accepting connections
- Client: WebSocket client for connecting to server
If you download pre-built releases from GitHub Releases, PortAudio and Opus libraries are already embedded in the binary. You don't need to install any additional dependencies - just download and use the binary.
If you want to build the application yourself, you need to install system dependencies first:
-
PortAudio: Cross-platform audio I/O library
- Official website: http://www.portaudio.com/
- GitHub: https://github.com/PortAudio/portaudio
- Installation:
- Linux:
sudo apt-get install portaudio19-dev(Debian/Ubuntu)sudo yum install portaudio-devel(Fedora/RHEL)sudo pacman -S portaudio(Arch Linux)
- macOS:
brew install portaudio - Windows: Download from PortAudio downloads
- Linux:
-
Opus: High-quality audio codec library
- Official website: https://opus-codec.org/
- Installation:
- Linux:
sudo apt-get install libopus-dev(Debian/Ubuntu)sudo yum install opus-devel(Fedora/RHEL)sudo pacman -S opus(Arch Linux)
- macOS:
brew install opus - Windows: Use pre-built libraries from Opus downloads
- Linux:
- User1 starts the application in server mode specifying the port via CLI flags.
- User1 tunnels their UDP server through a tunnel service or custom VPS proxy.
- User1 shares the public UDP tunnel URL/address with User2.
- User2 starts the application in client mode and connects directly to the tunnel address.
- Connection established through raw UDP, bypassing Symmetric NAT.
- Go-audio Core: High-performance audio engine (
Votline/Go-audio) managing core streams and native I/O. - RingBuffer: Specialized module for streaming audio data with thread-safe, optimized operations.
- Compressor: Dual compression (OPUS β Zstandard) for traffic optimization.
- Batch: Packetizer that groups 8 audio frames (320ms total delay) into a single UDP datagram to minimize tunnel overhead.
- Network Layer: Pure
net.UDPimplementation replacing legacy WebSocket over TCP.
Viz completely relies on CLI flags instead of interactive stdin prompts. Tunneling and port forwarding are handled by the user.
# Display help message
./viz -h
# or
./viz help
# Start Server on port 8080 with Debug logging enabled
./viz -s 8080 -d
# Start Client and connect to the server/tunnel address with Debug logging enabled
./viz -c remote-tunnel-url:8080 -d- Sample Rate: 48 kHz
- Channels: Mono (1 channel)
- Bitrate: 32 kbps
- Buffer Size: 2048 samples
- Chunk Duration: 40 ms (optimal for OPUS codec, supports 2ms-120ms range)
- Batching: 8 frames Γ 40ms = 320ms delay (optimized for tunneling services)
- Dual Compression: OPUS + Zstandard to minimize packet size
- Rare Requests: Prevents bans from tunneling services
- Port: 8443
- Read Timeout: 28 seconds
- Write Timeout: 28 seconds
- Idle Timeout: 28 seconds
- Recording: PortAudio β Float32 β Int16 β OPUS β Zstandard β (E2EE encryption at network layer, not in audio processing chain)
- Playback: (E2EE decryption at network layer) β Zstandard β OPUS β Int16 β Float32 β PortAudio
Note: End-to-End Encryption (E2EE) is applied at the network transport layer after audio compression, not within the audio processing pipeline itself.
- OPUS: Audio codec for voice communication (32 kbps)
- Zstandard: Additional compression to minimize traffic
- Result: Maximum compression to avoid tunnel bans
- Ring Buffers: Circular buffers used for both recording and playback operations
- Thread-safe operations with mutexes
- Automatic overflow management
- Separate read/write positions for efficient data flow
- Batching: Multiple compressed audio frames (8 frames Γ 40ms = 320ms total delay) are packed into single packets
- Reduces WebSocket overhead
- Creates ~320ms delay optimized for tunneling services (avoids bans)
- Chunks: 40ms audio chunks (optimal value for OPUS codec, which supports 2ms-120ms range)
This project is distributed under the MIT License. See the LICENSE file for details.
| Package | Version | Purpose |
|---|---|---|
| github.com/gorilla/websocket | v1.5.3 | WebSocket connections |
| go.uber.org/zap | v1.27.0 | Structured logging |
| golang.org/x/crypto | v0.43.0 | Encryption (NaCl Box) |
| github.com/Votline/Go-audio | v1.1.0 | Audio (Compress, record, play) |
- Gorilla WebSocket: BSD 2-Clause License - see licenses/gorilla-websocket_LICENSE.txt
- Uber Zap: MIT License - see licenses/uber-zap_LICENSE.txt
- Go-audio: MIT License - see licenses/Votline-Go-audio_LICENSE.txt