A secure, high-performance VPN system written in Go with modern cryptography and clean architecture.
** Perfect for Moroccan TPE/PME (Small & Medium Businesses)**
Ce VPN open-source est idΓ©al pour:
- TPE/PME - Petites et moyennes entreprises
- SΓ©curitΓ© - Protection des donnΓ©es sensibles
- Γconomique - Solution gratuite et open-source
- Télétravail - Accès sécurisé pour employés distants
- π²π¦ Local - DΓ©veloppΓ© avec les besoins marocains en tΓͺte
This open-source VPN is perfect for:
- Small & Medium Businesses - TPE/PME
- Security - Protect sensitive business data
- Cost-Effective - Free and open-source solution
- Remote Work - Secure access for remote employees
- π²π¦ Local - Built with Moroccan needs in mind
- β Personal VPN Usage - Protection personnelle
- β Corporate Deployments - DΓ©ploiements d'entreprise
- β Educational Purposes - Objectifs Γ©ducatifs
- β Learning Go & Cryptography - Apprendre Go et la cryptographie
- β Building Custom VPN Solutions - Solutions VPN personnalisΓ©es
- β Open-Source Contributions - Contributions open-source
π¨ IMPORTANT: READ BEFORE USE π¨
β Legitimate Use Only:
- Secure business communications
- Private corporate networks
- Educational and research purposes
- Protecting sensitive data on untrusted networks
- Secure remote access to private resources
- Professional VPN deployments
β DO NOT USE FOR:
- Illegal activities of any kind
- Bypassing legal restrictions or regulations
- Unauthorized access to networks or systems
- Circumventing content protection or copyright laws
- Malicious traffic routing or attacks
- Any activity that violates local, national, or international laws
YOU ARE RESPONSIBLE FOR:
- β Compliance with all applicable laws in Morocco and your jurisdiction
- β Obtaining necessary permissions and authorizations
- β Respecting intellectual property rights
- β Following your organization's security policies
- β Ensuring legitimate use at all times
π²π¦ Morocco Specific:
- VPN usage is legal in Morocco for legitimate purposes
- Users must comply with Moroccan telecommunications regulations
- Businesses should consult with legal counsel for compliance
AS A USER, YOU MUST:
- π Keep private keys secure and never share them
- π Use strong passwords and secure key storage
- π Monitor logs for suspicious activity
- π Keep software updated with security patches
- π‘οΈ Follow security best practices
- π Implement proper access controls
THE AUTHORS AND CONTRIBUTORS:
- Are NOT responsible for misuse of this software
- Do NOT endorse or support illegal activities
- Provide this software "AS IS" without warranties
- Are NOT liable for any damages or legal consequences
- Strongly condemn any misuse of this technology
BY USING THIS SOFTWARE, YOU AGREE:
- To use it only for lawful purposes
- To comply with all applicable laws and regulations
- To take full responsibility for your use
- That the authors are not liable for your actions
If you discover misuse of this software, please report it to:
- GitHub Issues: Report Here
- Local authorities if illegal activity is suspected
π΄ REMEMBER: With great power comes great responsibility. Use this tool ethically and legally. π΄
βββββββββββββββ βββββββββββββββ
β Client ββββββ Encrypted ββββΊβ Server β
β (TUN Dev) β Tunnel β (TUN Dev) β
βββββββββββββββ βββββββββββββββ
β β
βΌ βΌ
Local Apps Internet Gateway
- Server: VPN server handling multiple concurrent clients
- Client: VPN client establishing secure tunnels
- Crypto: X25519 key exchange + ChaCha20-Poly1305 encryption
- Tunnel: TUN device management and packet handling
- Network: Routing, NAT traversal, DNS forwarding
- Mutual Authentication: Public/private key pairs (X25519)
- Modern Encryption: ChaCha20-Poly1305 AEAD cipher
- Key Exchange: Noise Protocol Framework (Noise_XX pattern)
- Replay Protection: Nonce-based anti-replay mechanism
- Perfect Forward Secrecy: Ephemeral key exchange per session
- Go 1.21 or higher
- Linux/macOS (TUN device support)
- Root/sudo privileges (for network interface management)
# Clone the repository
git clone https://github.com/lahcenassmira/open-source-vpn.git
cd open-source-vpn
# Build server and client
make build
# Or build manually
go build -o bin/vpn-server ./cmd/server
go build -o bin/vpn-client ./cmd/client# Generate server keys
./bin/vpn-server keygen --output server-keys.json
# Generate client keys
./bin/vpn-client keygen --output client-keys.json# Edit server configuration
cp configs/server.example.yaml configs/server.yaml
# Add client public keys to server.yaml
# Start server (requires root)
sudo ./bin/vpn-server start --config configs/server.yaml# Edit client configuration
cp configs/client.example.yaml configs/client.yaml
# Add server public key and endpoint to client.yaml
# Connect (requires root)
sudo ./bin/vpn-client connect --config configs/client.yamlopen-source-vpn/
βββ cmd/
β βββ server/ # Server CLI entry point
β βββ client/ # Client CLI entry point
βββ internal/
β βββ crypto/ # Cryptography and key exchange
β βββ tunnel/ # TUN device management
β βββ network/ # Routing and packet handling
β βββ protocol/ # VPN protocol implementation
β βββ config/ # Configuration management
βββ pkg/
β βββ logger/ # Structured logging
β βββ metrics/ # Performance metrics
βββ configs/ # Example configurations
βββ docker/ # Docker deployment files
βββ scripts/ # Utility scripts
βββ docs/ # Additional documentation
server:
listen_address: "0.0.0.0:51820"
protocol: "udp"
network:
interface: "tun0"
address: "10.8.0.1/24"
mtu: 1420
crypto:
private_key: "server_private_key_base64"
clients:
- public_key: "client1_public_key_base64"
allowed_ips: ["10.8.0.2/32"]
- public_key: "client2_public_key_base64"
allowed_ips: ["10.8.0.3/32"]
routing:
forward_all_traffic: false
allowed_networks: ["10.8.0.0/24"]
dns:
enabled: true
servers: ["8.8.8.8", "8.8.4.4"]
logging:
level: "info"
format: "json"
output: "/var/log/vpn-server.log"client:
server_address: "vpn.example.com:51820"
protocol: "udp"
network:
interface: "tun0"
address: "10.8.0.2/24"
mtu: 1420
crypto:
private_key: "client_private_key_base64"
server_public_key: "server_public_key_base64"
routing:
default_route: false
routes: ["10.8.0.0/24"]
dns:
enabled: true
servers: ["10.8.0.1"]
logging:
level: "info"
format: "json"# Build Docker image
docker build -t open-source-vpn-server -f docker/Dockerfile .
# Run server container
docker run -d \
--name vpn-server \
--cap-add=NET_ADMIN \
--device=/dev/net/tun \
-p 51820:51820/udp \
-v $(pwd)/configs:/etc/vpn \
open-source-vpn-server# Server status
./bin/vpn-server status
# Client status
./bin/vpn-client statusStructured JSON logs include:
- Connection events (connect/disconnect)
- Data transfer statistics
- Latency measurements
- Error tracking
Example log entry:
{
"timestamp": "2026-05-20T10:30:45Z",
"level": "info",
"component": "server",
"event": "client_connected",
"client_id": "abc123",
"client_ip": "10.8.0.2",
"remote_addr": "203.0.113.45:54321"
}vpn-server start --config <path> # Start VPN server
vpn-server stop # Stop VPN server
vpn-server status # Show server status
vpn-server keygen --output <path> # Generate key pair
vpn-server logs --follow # Tail logsvpn-client connect --config <path> # Connect to VPN
vpn-client disconnect # Disconnect from VPN
vpn-client status # Show connection status
vpn-client keygen --output <path> # Generate key pair
vpn-client logs --follow # Tail logs- Latency: < 5ms overhead on local network
- Throughput: 1+ Gbps on modern hardware
- Concurrent Clients: 1000+ per server
- Memory: ~50MB base + ~1MB per client
- CPU: Efficient goroutine-based I/O
# Run all tests
make test
# Run with coverage
make test-coverage
# Run benchmarks
make benchmark
# Integration tests
make test-integration- Key Management: Store private keys securely, never commit to version control
- Firewall: Configure firewall rules to allow only VPN traffic
- Updates: Keep dependencies updated for security patches
- Monitoring: Enable logging and monitor for suspicious activity
- Access Control: Use allowed_ips to restrict client access
- Client β Server: Ephemeral public key
- Server β Client: Ephemeral public key + static public key (encrypted)
- Client β Server: Static public key (encrypted) + payload
ββββββββββββ¬βββββββββ¬ββββββββββββ¬ββββββββββββββ
β Type (1) β ID (4) β Nonce (12)β Payload (N) β
ββββββββββββ΄βββββββββ΄ββββββββββββ΄ββββββββββββββ
- Type: Packet type (handshake/data/keepalive)
- ID: Connection identifier
- Nonce: Unique nonce for AEAD
- Payload: Encrypted data + authentication tag
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License - see LICENSE file for details.
This VPN system is designed for legitimate privacy and security use cases. Users are responsible for compliance with local laws and regulations. The authors are not responsible for misuse of this software.
- Inspired by WireGuard's design principles
- Uses Noise Protocol Framework for key exchange
- Built with Go's excellent networking libraries
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with passion for secure and open internet.