Skip to content
whoashish115Public

About

A lightweight cross-platform VPN implementation written in modern C++ that securely tunnels IP traffic using virtual TUN interfaces and OpenSSL-based mutual TLS.

Topics

Resources

Stars

21 stars

Watchers

0 watching

Forks

Latest commit

 

History

120 Commits

Folders and files

Repository files navigation

UwUN

UwUN is a lightweight cross-platform VPN written in modern C++. It uses virtual TUN interfaces and TLS-encrypted communication to forward IP packets between a client and a server.

Features

  • Cross-platform support for Linux and Windows
  • Platform-specific TUN implementations (Linux /dev/net/tun and Windows WinTUN integration)
  • TLS-encrypted communication (TLS helpers live in common/; OpenSSL is expected at build time)
  • Username/password authentication performed by the server after the TLS handshake
  • Simple custom packet framing and forwarding between the TUN interface and the tunnel (shared in common/)
  • Separate client and server executables
  • CMake-based build system
  • Helper PowerShell script to generate development certificates (Windows)
  • Per-client address allocation from a small pool, handed out after login
  • A tiny test runner covering the login check, the packet layout and the TLS context

How It Works

The client first creates or opens a virtual TUN interface on the local machine and establishes a TCP connection to the server. A secure TLS handshake is then performed, after which the client authenticates with the server using a username and password. Once the connection is established, IP packets read from the local TUN interface are encrypted and sent through the secure tunnel to the server. The server decrypts the packets and writes them to its own TUN interface, while packets travelling in the opposite direction follow the same process back to the client, creating a secure bidirectional VPN tunnel.

Project Structure

UwUN/
├── certs/                  # TLS certificates
│   ├── ca.crt
│   ├── ca.key
│   ├── client.crt
│   ├── client.key
│   ├── server.crt
│   └── server.key
├── client/                 # VPN client
│   └── main.cpp
├── common/                 # Shared client/server code
│   ├── common.hpp
│   ├── tls.cpp
│   ├── tls.hpp
│   └── tun.hpp
├── external/               # External dependencies
│   └── wintun/
│       ├── wintun.dll
│       └── wintun.h
├── platform/               # Platform-specific code
│   ├── linux/
│   │   └── tun.cpp
│   └── windows/
│       └── tun.cpp
├── server/                 # VPN server
│   ├── login.cpp
│   ├── login.hpp
│   └── main.cpp
├── tests/                  # Unit tests
│   ├── main.cpp
│   ├── test_login.cpp
│   ├── test_packet.cpp
│   ├── test_tls.cpp
│   ├── test_utils.hpp
│   └── tests.hpp
├── CMakeLists.txt          # Build configuration
├── gen-cert.ps1            # Certificate generator
├── LICENSE
├── .gitignore
└── README.md

Building

Requirements:

  • CMake
  • A C++20 compatible compiler (GCC, Clang, or MSVC)
  • OpenSSL development libraries

Build the project with:

mkdir build
cd build
cmake ..
cmake --build .

On Windows, CMake automatically uses the installed Visual Studio generator, or you can specify one explicitly using the -G option.

The tests build as a separate vpntests target and can be run through CTest:

ctest --output-on-failure

Running

After building, run the server executable first, followed by the client.

Linux

Server:

./vpnserver

Client:

./vpnclient

Windows

Server:

.\build\Debug\vpnserver.exe

Client:

.\build\Debug\vpnclient.exe

Limitations

  • Minimal authentication (username/password) - review server/login.cpp before using in production
  • Addresses come from a small hard coded 10.0.0.0/24 pool, there is no DHCP
  • No IPv6-specific handling is implemented
  • No built-in NAT traversal or advanced NAT punch-through
  • No integrated certificate revocation checking
  • Focused on being a small research/example project rather than a production VPN

License

This project is licensed under the MIT License. You are free to use, modify, distribute, and incorporate this code into personal or commercial projects with proper attribution.

References

This project is inspired by classical networking concepts, VPN implementations, TLS, virtual network interfaces, and secure communication protocols. The following resources were particularly helpful during the design and implementation of this project:

About

A lightweight cross-platform VPN implementation written in modern C++ that securely tunnels IP traffic using virtual TUN interfaces and OpenSSL-based mutual TLS.

Topics

Resources

Stars

21 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages