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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VpnHood.Net.VpnAdapters.Abstractions" Version="9.1.875" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VpnHood.Net.VpnAdapters.Abstractions" Version="9.1.875" />
                    
Directory.Packages.props
<PackageReference Include="VpnHood.Net.VpnAdapters.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VpnHood.Net.VpnAdapters.Abstractions --version 9.1.875
                    
#r "nuget: VpnHood.Net.VpnAdapters.Abstractions, 9.1.875"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VpnHood.Net.VpnAdapters.Abstractions@9.1.875
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VpnHood.Net.VpnAdapters.Abstractions&version=9.1.875
                    
Install as a Cake Addin
#tool nuget:?package=VpnHood.Net.VpnAdapters.Abstractions&version=9.1.875
                    
Install as a Cake Tool

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

  • IVpnAdapter is the contract: start with VpnAdapterOptions (addresses, DNS servers, routes, NAT, app filter), read packets through PacketReceived, write them with SendPacketQueued, stop.
  • TunVpnAdapter does 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.
  • ProtectSocket keeps a socket, such as the one to the VPN server, out of the tunnel.
  • NullVpnAdapter has 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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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