You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the VPN server implemented in C++. It utilizes various networking libraries to handle packet forwarding, routing, and tunneling. The server is designed to manage VPN connections, forward traffic, and provide essential network functionalities.
4
+
ToyVPN is a lightweight VPN server implemented in C++. It leverages **PcapPlusPlus** and various networking tools to handle packet forwarding, routing, and tunneling. The server is designed to efficiently manage VPN connections, forward traffic, and provide essential network functionalities.
5
5
6
-
It is heavily inspired by Android ToyVpn and provides a robust solution for handling VPN connections.
6
+
Inspired by [Android ToyVpn](https://android.googlesource.com/platform/development/+/master/samples/ToyVpn), this project offers a robust solution for handling VPN connections.
7
7
8
8
## Features 🚀
9
-
- Supports multiple clients
10
-
- Single-threaded, utilizing epoll for efficient event handling
11
-
- Automatic configuration: creates tun interface, configures iptables and IP routing, and handles automatic teardown
12
-
- Records pcapng files with traffic per VPN client
-`ServerSocketWrapper.h`: Manages the UDP socket that listens to incoming clients
74
-
-`ClientHandler.h`: Handles the lifecycle of individual VPN clients - connecting to a new client, performing the handshake protocol, managing traffic from the client to the external network and vice versa, handling client disconnection
75
-
-`TunInterfaceWrapper.h`: Creates and manages the TUN interface used for the VPN connection
76
-
-`NatAndRoutingWrapper.h`: Configures IP forwarding and routing. Uses `iptables` and `ip route`
77
-
-`PacketHandler.h`: Run in a separate thread, accepts packets from the main thread and saves them to pcapng files per VPN client
78
-
-`ToyVpnServer.h`: Orchestrates all of the above and manages the server lifecycle
79
-
80
-
### Flow 🔄
81
-
1. The server initializes and sets up a TUN interface.
82
-
2. It configures IP forwarding and routing.
83
-
3. Opens a UDP socket and starts listening to incoming clients.
84
-
4. Clients connect, go through the handshake protocol and establish a VPN session.
85
-
5. Packets are forwarded between clients and the external network (Internet).
86
-
6. If requested by the user, packets are also passed to a different thread for saving them to pcapng files.
87
-
7. When a client disconnects, the server cleans up the resources.
88
-
8. When the server shuts down it removes the TUN interface and restores the IP forwarding and routing configurations.
0 commit comments