GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - datamaker/opentunnel

BranchesTags
Open more actions menu

Latest commit

 

History

129 Commits
129 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
clients
clients
 
 
scripts
scripts
 
 
server-rust
server-rust
 
 
shared
shared
 
 
.gitignore
.gitignore
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
docker-compose.yml
docker-compose.yml
 
 
install.sh
install.sh
 
 

Repository files navigation

OpenTunnel VPN

A lightweight, open-source VPN solution built from scratch. OpenTunnel provides secure encrypted tunneling with native clients for all major platforms.

License Docker Clients

Features

  • Full Tunnel VPN: Route all internet traffic through the VPN server
  • TLS 1.3 Encryption: Secure communication using modern cryptography
  • Multi-Platform Clients: Native apps for macOS, iOS, Android, and Windows
  • Docker Deployment: One-command installation using Docker
  • PostgreSQL Backend: Reliable user authentication and session management

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         Clients                                  │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐        │
│  │   iOS    │  │ Android  │  │  macOS   │  │ Windows  │        │
│  │  Swift   │  │  Kotlin  │  │  Swift   │  │   C#     │        │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └────┬─────┘        │
│       └─────────────┴─────────────┴─────────────┘              │
│                           │                                     │
│                   TLS 1.3 Encrypted Tunnel                      │
│                      (Port 1194)                                │
└───────────────────────────┼─────────────────────────────────────┘
                            │
┌───────────────────────────▼─────────────────────────────────────┐
│                    VPN Server (Docker)                          │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐             │
│  │ TLS Server  │  │ TUN Device  │  │   NAT/FW    │             │
│  │   (Rust)    │  │  (native)   │  │ (iptables)  │             │
│  └─────────────┘  └─────────────┘  └─────────────┘             │
│                          │                                      │
│                   ┌──────▼──────┐                               │
│                   │ PostgreSQL  │                               │
│                   └─────────────┘                               │
└─────────────────────────────────────────────────────────────────┘

Quick Start

One-Line Installation (Recommended)

curl -fsSL https://raw.githubusercontent.com/datamaker/opentunnel/main/install.sh | sudo bash

This will:

  • Pull the Docker image from Docker Hub
  • Create a docker-compose.yml configuration
  • Start the VPN server and PostgreSQL database
  • Enable IP forwarding on the host

Manual Docker Installation

# Create network
docker network create vpn-network

# Start PostgreSQL
docker run -d \
  --name opentunnel-db \
  --network vpn-network \
  -e POSTGRES_USER=vpn \
  -e POSTGRES_PASSWORD=your-secure-password \
  -e POSTGRES_DB=vpn \
  postgres:15-alpine

# Start VPN Server
docker run -d \
  --name opentunnel-vpn \
  --network vpn-network \
  --cap-add=NET_ADMIN \
  --device=/dev/net/tun \
  -p 1194:1194 \
  -e DB_HOST=opentunnel-db \
  -e DB_PASSWORD=your-secure-password \
  datamaker/opentunnel:rust

# Enable IP forwarding on host
sudo sysctl -w net.ipv4.ip_forward=1

Verify Installation

# Check containers are running
docker ps

# View server logs
docker logs -f opentunnel-vpn

# Test TLS connection
openssl s_client -connect localhost:1194 -tls1_3

Creating the First User

No VPN users are seeded — earlier versions shipped admin/admin123 and testuser/test123, i.e. the same known credentials on every install's live VPN. Instead, provision users from the admin panel: set ADMIN_PASSWORD (and/or ADMIN_SSO_EMAILS) in your .env, open the panel, and add users under Users. You can also insert one directly (see Adding Users).

Client Setup

The server address and credentials are entered on the app's login screen at runtime — you do not edit them in source. Prebuilt Android (APK) and Windows installers are attached to each GitHub release; the sections below are for building from source.

SSO (Google device flow) currently has the OIDC issuer and Apple bundle identifiers hardcoded to this project's values. To use SSO in your own deployment you must change those in the client sources; password login works without any edits.

macOS / iOS

macOS and iOS share one Xcode project (an app target plus a Packet Tunnel extension); there is no separate clients/ios/ directory.

  1. Open clients/macos/VPNClient/VPNClient.xcodeproj in Xcode.
  2. Select your development team for code signing (required for the Network Extension entitlement).
  3. Build and run the VPNClient scheme (⌘R). For iOS, choose a physical device — the Packet Tunnel APIs do not work in the Simulator.
  4. Enter the server address and credentials on the login screen and connect. On iOS, approve the VPN profile when prompted.

Android

  1. Open clients/android/ in Android Studio, or build from the command line:
    cd clients/android && ./gradlew assembleRelease
  2. Install the APK and grant the VPN permission when prompted.
  3. Enter the server address and credentials on the login screen and connect.

Windows

  1. Open clients/windows/VPNClient.sln in Visual Studio, or build from the command line:
    cd clients/windows && dotnet publish VPNClient/VPNClient.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o ./publish
    The build expects wintun.dll next to the executable (see .github/workflows/build-clients.yml for how CI fetches it).
  2. Run as Administrator (required to create the WinTun adapter).
  3. Enter the server address and credentials and connect.

Server Configuration

Environment Variables

Variable Default Description
VPN_PORT 1194 VPN server port
VPN_SUBNET 10.8.0.0 VPN client subnet
VPN_NETMASK 255.255.255.0 Subnet mask
DNS_SERVERS 8.8.8.8,8.8.4.4 DNS servers for clients
DB_HOST localhost PostgreSQL host
DB_PORT 5432 PostgreSQL port
DB_NAME vpn Database name
DB_USER vpn Database user
DB_PASSWORD required Database password
JWT_SECRET auto-generated JWT signing secret

Adding Users

Connect to the database and insert users:

-- Connect to database
docker exec -it opentunnel-db psql -U vpn

-- Generate bcrypt hash for password (use bcrypt online tool or node)
-- Example: password "mypassword" = "$2b$10$..."

INSERT INTO users (username, password_hash, is_active, max_connections)
VALUES ('newuser', '$2b$10$your-bcrypt-hash', true, 3);

Protocol Specification

Message Format

┌─────────┬──────────────┬─────────────────┐
│  Type   │    Length    │     Payload     │
│ 1 byte  │   4 bytes    │    N bytes      │
│         │  (big-endian)│                 │
└─────────┴──────────────┴─────────────────┘

Message Types

Type Code Description
AUTH_REQUEST 0x01 Client sends username/password
AUTH_RESPONSE 0x02 Server responds with success/failure
CONFIG_PUSH 0x03 Server sends VPN config (IP, DNS, etc.)
KEEPALIVE 0x04 Keepalive ping
KEEPALIVE_ACK 0x05 Keepalive acknowledgment
DISCONNECT 0x06 Graceful disconnect
DATA_PACKET 0x10 Encapsulated IP packet

Authentication Flow

Client                              Server
   │                                   │
   │──── AUTH_REQUEST ────────────────>│
   │     {username, password}          │
   │                                   │
   │<─── AUTH_RESPONSE ────────────────│
   │     {success, sessionToken}       │
   │                                   │
   │<─── CONFIG_PUSH ──────────────────│
   │     {assignedIP, gateway, dns}    │
   │                                   │
   │──── DATA_PACKET ─────────────────>│
   │     [IP packets]                  │
   │<─── DATA_PACKET ──────────────────│
   │                                   │

Troubleshooting

Connection Refused

# Check if port is open
sudo ufw allow 1194/tcp
# or
sudo iptables -A INPUT -p tcp --dport 1194 -j ACCEPT

# Verify Docker is running
docker ps | grep opentunnel

No Internet Through VPN

# Enable IP forwarding on host
sudo sysctl -w net.ipv4.ip_forward=1

# Make persistent
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf

# Check NAT rules in container
docker exec opentunnel-vpn iptables -t nat -L POSTROUTING -n -v

Authentication Failed

# Check server logs
docker logs opentunnel-vpn | grep -i auth

# Verify user exists in database
docker exec opentunnel-db psql -U vpn -c "SELECT username FROM users;"

# Reset user password
docker exec opentunnel-db psql -U vpn -c \
  "UPDATE users SET password_hash='new-bcrypt-hash' WHERE username='your-user';"

TUN Device Error

# Ensure TUN module is loaded
sudo modprobe tun
ls -la /dev/net/tun

# Verify container has NET_ADMIN capability
docker inspect opentunnel-vpn | grep -A5 CapAdd

Development

Building from Source

# Clone repository
git clone https://github.com/datamaker/opentunnel.git
cd opentunnel/server-rust

# Build (Linux, real kernel TUN)
cargo build --release --features tun-device

# Run (needs certs at ./certs/server.{crt,key} and a reachable Postgres)
LOG_LEVEL=debug DB_HOST=localhost DB_PASSWORD=vpnpassword \
  cargo run --release --features tun-device

Building Docker Image

cd server-rust
docker build -t opentunnel:rust .

# Test locally
docker run --rm -it \
  --cap-add=NET_ADMIN \
  --device=/dev/net/tun \
  -p 1194:1194 \
  opentunnel:rust

Project Structure

opentunnel/
├── server-rust/            # Rust VPN server
│   ├── src/
│   │   ├── main.rs        # Entry point
│   │   ├── config.rs      # Configuration
│   │   ├── tun.rs         # Native kernel TUN device
│   │   ├── tls.rs         # TLS server (rustls)
│   │   ├── protocol/      # VPN protocol
│   │   ├── routing/       # Packet routing
│   │   ├── session/       # Session management
│   │   ├── split.rs       # Split-tunnel policy
│   │   ├── auth.rs        # Authentication
│   │   └── db.rs          # Database
│   ├── schema.sql         # PostgreSQL schema
│   ├── Dockerfile
│   └── Cargo.toml
│
├── clients/
│   ├── android/           # Android client (Kotlin)
│   ├── macos/             # macOS + iOS client (Swift, multiplatform)
│   └── windows/           # Windows client (C#)
│
├── install.sh             # One-line installer
├── docker-compose.yml     # Docker Compose config
└── README.md

Security Considerations

  • Change default credentials immediately after installation
  • Use strong passwords (16+ characters recommended)
  • Keep Docker and host system updated
  • Use a firewall to restrict access to management ports
  • Monitor logs for suspicious activity
  • Consider using fail2ban for brute-force protection

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please:

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

Acknowledgments

  • Inspired by OpenVPN architecture
  • Built with Rust, Swift, Kotlin, and C#
  • Uses PostgreSQL for reliable data storage

About

No description, website, or topics provided.

Resources

Readme
MIT license

Contributing

Contributing
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.