Skip to content
/ ezvpn Public

EZVPN is a secure VPN solution built on top of SOCKS5 protocol, providing encrypted tunneling based on WebSocket and mTLS mechanism.

License

Notifications You must be signed in to change notification settings

easzlab/ezvpn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EZVPN

Go Version License Build Status

README | δΈ­ζ–‡ζ–‡ζ‘£

EZVPN is a secure VPN solution built on top of SOCKS5 protocol, providing encrypted tunneling based on WebSocket and mTLS mechanism.

πŸš€ Features

  • Secure Tunneling: WebSocket-based tunneling with mTLS encryption
  • SOCKS5 Proxy: Built-in SOCKS5 proxy server support
  • Multiplexing: Efficient connection multiplexing using smux
  • Cross-Platform: Supports macOS, Linux, and Windows
  • Built-in Certificates: Default certificates for quick setup
  • Hot Reload: Dynamic configuration reloading
  • High Performance: Goroutine pool for concurrent connection handling

πŸ“‹ Architecture

EZVPN consists of two main components:

Agent (eva)

  • Acts as a local SOCKS proxy client
  • Establishes WebSocket connection to the server
  • Tunnels local traffic through encrypted connection
  • Supports automatic retry with exponential backoff

Server (evs)

  • Accepts WebSocket connections from agents
  • Provides SOCKS5 proxy services
  • Manages multiple concurrent agent connections
  • Supports both inline and external SOCKS servers
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        socks5       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   ws+mTLS    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client    β”‚ ◄─────────────────► β”‚   Agent     β”‚ ◄──────────► β”‚   Server    β”‚
β”‚ Application β”‚                     β”‚   (eva)     β”‚              β”‚    (evs)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                                        β”‚
                                                                        β–Ό
                                                                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                                 β”‚ Destination β”‚
                                                                 β”‚   Server    β”‚
                                                                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Installation

Prerequisites

  • Go 1.24 or higher
  • Make (for building)

Build from Source

# Clone the repository
git clone https://github.com/easzlab/ezvpn.git
cd ezvpn

# Build binaries
make build

# The binaries will be available in the build/ directory
ls build/
# eva  evs

Quick Start with Built-in Certificates

The project includes built-in certificates for quick testing and development.

πŸš€ Usage

Starting the Server

# Start server with default settings
./build/evs

# Start server with custom configuration
./build/evs --listen=":8443" --withsocks=true --loglvl=info

# Start server with external SOCKS server
./build/evs --withsocks=false --socks="127.0.0.1:1080"

Starting the Agent

# Start agent (requires auth key)
./build/eva --auth="your-auth-key" --server="127.0.0.1:8443"

# Start agent with custom local address
./build/eva --auth="your-auth-key" --listen="127.0.0.1:6116"

# Disable TLS (for testing only)
./build/eva --auth="your-auth-key" --tls=false

Configuration

Server Configuration

Create an agents.yaml file to configure allowed agents:

agents:
  - name: "agent-1"
    auth_key: "your-secret-auth-key-1"
    approved_cn: "ezvpn-agent"
  - name: "agent-2"
    auth_key: "your-secret-auth-key-2"
    approved_cn: "ezvpn-agent"

Command Line Options

Server (evs) Options:

  -a, --agentsfile string   allowed agents file (default "agents.yaml")
  -l, --listen string       server listen address (default "127.0.0.1:8443")
      --socks string        socks server address (default "socks.sock")
      --withsocks           enable inline socks (default true)
      --tls                 enable tls (default true)
      --ca string           ca file (default "ca.pem")
      --cert string         cert file (default "evs.pem")
      --key string          key file (default "evs-key.pem")
      --logfile string      log file (default "evs.log")
      --loglvl string       log level (default "debug")
      --pprof               enable pprof
  -v, --version             show version

Agent (eva) Options:

  -k, --auth string         auth key (required)
  -s, --server string       server address (default "127.0.0.1:8443")
  -l, --listen string       local address (default "127.0.0.1:6116")
      --tls                 enable tls (default true)
      --ca string           ca file (default "ca.pem")
      --cert string         cert file (default "eva.pem")
      --key string          key file (default "eva-key.pem")
      --lock string         lock file (default "eva.lock")
      --logfile string      log file (default "eva.log")
      --loglvl string       log level (default "debug")
      --pprof               enable pprof
  -v, --version             show version

πŸ§ͺ Testing

Unit Tests

# Run all tests
make test

# Run tests with coverage
make test-cov

End-to-End Tests

# Run e2e tests
./tests/e2e_test.sh

πŸ”§ Development

Project Structure

ezvpn/
β”œβ”€β”€ cmd/                    # Command line applications
β”‚   β”œβ”€β”€ agent/             # Agent (eva) main
β”‚   └── server/            # Server (evs) main
β”œβ”€β”€ pkg/                   # Public packages
β”‚   β”œβ”€β”€ agent/             # Agent implementation
β”‚   β”œβ”€β”€ server/            # Server implementation
β”‚   └── utils/             # Utility functions
β”œβ”€β”€ internal/              # Private packages
β”‚   └── config/            # Configuration management
β”œβ”€β”€ tests/                 # Test files
β”‚   └── e2e_test.sh       # End-to-end test script
β”œβ”€β”€ docs/                  # Documentation
β”œβ”€β”€ Makefile              # Build automation
└── README.md             # This file

πŸ”’ Security

mTLS Authentication

EZVPN uses mutual TLS (mTLS) for secure authentication:

  1. Certificate Authority (CA): Validates both client and server certificates
  2. Server Certificate: Authenticates the server to clients
  3. Client Certificate: Authenticates clients to the server
  4. Certificate Validation: Both sides validate certificates against the CA

Built-in Certificates

For development and testing, EZVPN includes built-in certificates. Do not use these in production environments.

Custom Certificates

For production use, generate your own certificates:

# Generate CA private key
openssl genrsa -out ca-key.pem 4096

# Generate CA certificate
openssl req -new -x509 -days 365 -key ca-key.pem -out ca.pem

# Generate server private key and certificate
openssl genrsa -out evs-key.pem 4096
openssl req -new -key evs-key.pem -out evs.csr
openssl x509 -req -days 365 -in evs.csr -CA ca.pem -CAkey ca-key.pem -out evs.pem

# Generate client private key and certificate
openssl genrsa -out eva-key.pem 4096
openssl req -new -key eva-key.pem -out eva.csr
openssl x509 -req -days 365 -in eva.csr -CA ca.pem -CAkey ca-key.pem -out eva.pem

πŸ“Š Performance

Benchmarks

  • Concurrent Connections: Supports thousands of concurrent connections
  • Throughput: High-speed data transfer through multiplexed streams
  • Memory Usage: Efficient memory management with goroutine pools
  • Latency: Low-latency tunneling with WebSocket connections

Monitoring

Enable pprof for performance monitoring:

# Server with pprof
./build/evs --pprof

# Agent with pprof
./build/eva --pprof --auth="your-key"

# Access pprof endpoints
curl http://localhost:6062/debug/pprof/  # Server
curl http://localhost:6061/debug/pprof/  # Agent

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Go best practices and conventions
  • Add tests for new functionality
  • Update documentation as needed
  • Ensure all tests pass before submitting PR

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support


EZVPN - Secure, Fast, and Reliable VPN Solution

About

EZVPN is a secure VPN solution built on top of SOCKS5 protocol, providing encrypted tunneling based on WebSocket and mTLS mechanism.

Resources

License

Stars

Watchers

Forks

Packages