VpnHood.Net.VpnAdapters.Abstractions
9.1.875
dotnet add package VpnHood.Net.VpnAdapters.Abstractions --version 9.1.875
NuGet\Install-Package VpnHood.Net.VpnAdapters.Abstractions -Version 9.1.875
<PackageReference Include="VpnHood.Net.VpnAdapters.Abstractions" Version="9.1.875" />
<PackageVersion Include="VpnHood.Net.VpnAdapters.Abstractions" Version="9.1.875" />
<PackageReference Include="VpnHood.Net.VpnAdapters.Abstractions" />
paket add VpnHood.Net.VpnAdapters.Abstractions --version 9.1.875
#r "nuget: VpnHood.Net.VpnAdapters.Abstractions, 9.1.875"
#:package VpnHood.Net.VpnAdapters.Abstractions@9.1.875
#addin nuget:?package=VpnHood.Net.VpnAdapters.Abstractions&version=9.1.875
#tool nuget:?package=VpnHood.Net.VpnAdapters.Abstractions&version=9.1.875
VpnHood.Net.VpnAdapters.Abstractions
The contract and the base class of VpnHood's VPN adapters: virtual network
interfaces (TUN) that the host's traffic is routed into, whose IP packets a VPN reads and writes. One package per
platform builds on it: VpnHood.Net.VpnAdapters.WinTun, .WinDivert, .WindowsVpnPlugin, .LinuxTun,
.AndroidTun and .IosTun.
dotnet add package VpnHood.Net.VpnAdapters.Abstractions
How it works
IVpnAdapteris the contract: start withVpnAdapterOptions(addresses, DNS servers, routes, NAT, app filter), read packets throughPacketReceived, write them withSendPacketQueued, stop.TunVpnAdapterdoes the work every platform shares: the order of a start's steps, the stop, the reader and the writer with their retries, stopping after repeated I/O errors,AutoRestart, and following the host when its network changes. A platform's adapter supplies only its steps: add, open, close and remove the interface, set its addresses, routes and DNS servers, read and write one packet.ProtectSocketkeeps a socket, such as the one to the VPN server, out of the tunnel.NullVpnAdapterhas no interface: it runs a VPN without rights, for tests.
Quick start
The example below runs as a test in CI
(VpnAdaptersReadmeExampleTest.cs).
Its namespaces are System.Net, VpnHood.Net.VpnAdapters.Abstractions, VpnHood.Net.Packets,
VpnHood.Net.Packets.Extensions and VpnHood.Net.Toolkit.Net.
// in an app, a platform's adapter: WinTunVpnAdapter, LinuxTunVpnAdapter, AndroidVpnAdapter...
using var adapter = new NullVpnAdapter(blocking: false);
// what the host routes into the tunnel arrives here, on the adapter's reader task
adapter.PacketReceived += (_, ipPacket) => {
Console.WriteLine($"From the host: {ipPacket}");
ipPacket.Dispose(); // the handler owns each packet: forward it or dispose it
};
await adapter.Start(new VpnAdapterOptions {
SessionName = "My VPN",
VirtualIpNetworkV4 = IpNetwork.Parse("10.255.0.2/24"),
DnsServers = [IPAddress.Parse("10.255.0.1")],
IncludeNetworks = IpNetwork.All // every address of the IP versions the interface carries: IPv4 here
}, CancellationToken.None);
// what the VPN sends the host is queued; the adapter writes it on its own loop and disposes it
var packet = PacketBuilder.BuildUdp(
new IPEndPoint(IPAddress.Parse("10.255.0.1"), 53),
new IPEndPoint(IPAddress.Parse("10.255.0.2"), 5353),
"answer"u8);
packet.UpdateAllChecksums();
adapter.SendPacketQueued(packet);
adapter.Stop(); // removes the interface, its routes and its DNS servers
License
LGPL-2.1-only. See the VpnHood repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- VpnHood.Net.PacketTransports (>= 9.1.875)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on VpnHood.Net.VpnAdapters.Abstractions:
| Package | Downloads |
|---|---|
|
VpnHood.Core.Client
The VpnHood VPN client engine: it finds a server, builds a session with it, and runs the session's tunnel on a VPN adapter. To build an app, start from VpnHood.AppLogic.App. |
|
|
VpnHood.Core.Server
The VpnHood VPN server engine: it takes its configuration from its access manager, listens for clients, and carries their sessions. |
|
|
VpnHood.Core.Client.VpnServices.Host
The VPN service's side of the contract: it takes the app's requests, connects with the options the app saved, and reports the connection's state back. |
|
|
VpnHood.Net.VpnAdapters.WinDivert
A VPN adapter for Windows on WinDivert, a packet capture driver, with no network interface of its own. |
|
|
VpnHood.Net.VpnAdapters.WinTun
The VPN adapter for Windows on WinTun, a layer-3 TUN driver: it makes the interface and gives it its addresses, routes and DNS servers. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.875 | 35 | 11/16/2026 |
| 9.1.874 | 64 | 11/15/2026 |
| 9.1.864 | 226 | 11/3/2026 |
| 9.0.860 | 220 | 10/31/2026 |
| 9.0.859.16-prerelease | 186 | 10/30/2026 |
| 9.0.857 | 212 | 10/20/2026 |
| 9.0.856 | 205 | 10/19/2026 |
| 9.0.855 | 210 | 10/13/2026 |
| 8.2.853.11-prerelease | 202 | 10/5/2026 |
| 8.2.853 | 226 | 9/23/2026 |
| 8.2.852 | 212 | 9/23/2026 |