English | 简体中文 | 📖 Online Docs
A production-ready WebRTC learning platform — from basic peer-to-peer calls to advanced multi-party Mesh architecture.
- Features
- Quick Start
- Why This Project?
- Architecture
- Documentation
- Configuration
- Deployment
- Contributing
- License
| Feature | Description |
|---|---|
| 🌐 WebSocket Signaling | Gorilla WebSocket with heartbeat, room management, and message relay |
| 👥 Multi-party Mesh | Up to 50 participants per room with automatic peer management |
| 💬 DataChannel Chat | Peer-to-peer text messaging without server relay |
| 🎥 Media Controls | Mute/unmute, camera toggle, screen sharing |
| 📹 Local Recording | Browser-side MediaRecorder with WebM export |
| 🔒 Security | Origin validation, identity binding, rate limiting |
| 🐳 Docker Ready | Multi-stage builds with HTTPS/TURN support |
- Go 1.22+
- Modern browser (Chrome 90+, Firefox 88+, Safari 14+)
- Docker (optional)
git clone https://github.com/LessUp/webrtc.git
cd webrtc
go mod tidy
go run ./cmd/serverOpen http://localhost:8080 and start calling!
docker build -t webrtc .
docker run --rm -p 8080:8080 webrtcexport DOMAIN=your-domain.com
docker compose up -dVisit https://your-domain.com with automatic HTTPS.
- 🎓 Learning-Oriented — Progressive complexity from 1-on-1 to multi-party
- 🔐 Security-First — Origin validation, identity binding, connection limits
- 📦 Zero-Dependency Frontend — Pure vanilla JavaScript, no frameworks
- 🚀 Docker-Ready — Multi-stage builds for minimal image size
- 📝 Well-Documented — Bilingual docs (EN/ZH), architecture diagrams, troubleshooting guides
webrtc/
├── cmd/server/ # HTTP + WebSocket entry point
├── internal/signal/ # Signaling logic
│ ├── hub.go # Room management, message relay
│ ├── hub_test.go # Unit tests
│ └── message.go # Message type definitions
├── web/ # Frontend (vanilla JS)
│ ├── index.html # UI
│ ├── app.js # Main entry
│ ├── app.*.js # Modular components
│ └── styles.css # Responsive styles
├── docs/ # Documentation (EN/ZH)
├── changelog/ # Version history
└── .github/workflows/ # CI/CD
┌──────────────────────────────────────────────────────┐
│ Browser A │
│ ┌──────────┐ ┌──────────┐ ┌────────────────┐ │
│ │ HTML UI │──→│ app.js │──→│ getUserMedia │ │
│ └──────────┘ └────┬─────┘ └──────┬─────────┘ │
└───────────────────────┼─────────────────┼───────────┘
│ WebSocket │ WebRTC P2P
┌──────▼──────┐ │
│ Go Server │ │
│ ┌──────────┐│ │
│ │Signal Hub││ │
│ └──────────┘│ │
└──────┬──────┘ │
│ WebSocket │
┌───────────────────────┼─────────────────┼───────────┐
│ Browser B │ │ │
│ ┌──────────┐ ┌────▼─────┐ ┌──────▼─────────┐│
│ │ HTML UI │──→│ app.js │──→│ getUserMedia ││
│ └──────────┘ └──────────┘ └────────────────┘│
└─────────────────────────────────────────────────────┘
| Flow | Path | Description |
|---|---|---|
| Signaling | Browser ↔ WebSocket /ws ↔ Hub |
Offer/Answer/ICE relay |
| Media | Browser ↔ WebRTC P2P ↔ Browser | Audio/video streams |
| DataChannel | Browser ↔ WebRTC P2P ↔ Browser | Text chat |
Complete documentation available in English and 简体中文:
| Document | Description |
|---|---|
| 📘 Guide | Architecture, implementation details |
| 🚀 Deployment | Docker, HTTPS, TURN setup |
| 📡 Signaling | WebSocket protocol specification |
| 🔧 API Reference | Configuration, environment variables |
| 🔍 Troubleshooting | Common issues and solutions |
📖 Online Docs: https://lessup.github.io/webrtc/
| Variable | Default | Description |
|---|---|---|
ADDR |
:8080 |
HTTP listen address |
WS_ALLOWED_ORIGINS |
* |
Comma-separated origins; * for all |
RTC_CONFIG_JSON |
Public STUN | JSON ICE/TURN config passed to browser |
export RTC_CONFIG_JSON='{
"iceServers": [
{ "urls": ["stun:stun.l.google.com:19302"] },
{ "urls": ["turn:turn.example.com:3478"], "username": "user", "credential": "pass" }
]
}'- Set
WS_ALLOWED_ORIGINSto your domain - Configure TURN server for NAT traversal
- Enable HTTPS (Caddy handles this automatically)
- Set up monitoring and logging
# docker-compose.yml
services:
webrtc:
build: .
environment:
- WS_ALLOWED_ORIGINS=yourdomain.com
- RTC_CONFIG_JSON={"iceServers":[{"urls":"turn:yourdomain.com:3478"...}]}
caddy:
image: caddy:2-alpine
ports:
- "80:80"
- "443:443"
coturn:
image: coturn/coturn:latest
network_mode: hostSee Deployment Guide for detailed instructions.
We welcome contributions! Please see:
- Contributing Guidelines — Setup and workflow
- Roadmap — Future plans
- Changelog — Version history
# Install dependencies
go mod tidy
# Run tests
go test -race ./...
# Run linter
golangci-lint run
# Start with hot reload
air| Category | Technology |
|---|---|
| Backend | Go 1.22+, net/http, Gorilla WebSocket |
| Frontend | HTML5 + Vanilla JavaScript + CSS3 |
| Media | WebRTC APIs (getUserMedia, RTCPeerConnection, DataChannel) |
| Container | Docker (multi-stage) |
| CI/CD | GitHub Actions |
- Origin whitelist validation
- Server-verified client identities
- Connection limits (50 clients/room, 1000 rooms)
- Input validation and sanitization
- See Security Policy
Made with ❤️ by LessUp