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.
- 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
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.
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
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-failureAfter building, run the server executable first, followed by the client.
Linux
Server:
./vpnserverClient:
./vpnclientWindows
Server:
.\build\Debug\vpnserver.exeClient:
.\build\Debug\vpnclient.exe- 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
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.
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:
- https://write.yiransheng.com/vpn
- https://beej.us/guide/bgnet/html/
- https://docs.openssl.org/
- https://docs.kernel.org/networking/tuntap.html
- https://git.zx2c4.com/wintun/
- https://www.wireguard.com/
- https://ro-che.info/articles/2021-02-27-linux-routing
- https://pages.cs.wisc.edu/~remzi/OSTEP/
- https://aosabook.org/en/v2/nginx.html
- https://openvpn.net/community-resources/