TunnelForge.Tun 10.0.6

dotnet add package TunnelForge.Tun --version 10.0.6
                    
NuGet\Install-Package TunnelForge.Tun -Version 10.0.6
                    
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="TunnelForge.Tun" Version="10.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TunnelForge.Tun" Version="10.0.6" />
                    
Directory.Packages.props
<PackageReference Include="TunnelForge.Tun" />
                    
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 TunnelForge.Tun --version 10.0.6
                    
#r "nuget: TunnelForge.Tun, 10.0.6"
                    
#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 TunnelForge.Tun@10.0.6
                    
#: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=TunnelForge.Tun&version=10.0.6
                    
Install as a Cake Addin
#tool nuget:?package=TunnelForge.Tun&version=10.0.6
                    
Install as a Cake Tool

TunnelForge.Tun (v10.0.6)

Поддерживаемые языки / Supported languages / Unterstützte Sprachen / 支持的语言:


Русский

TunnelForge.Tun — кроссплатформенная библиотека для работы с виртуальными TUN-адаптерами. Предоставляет единый интерфейс ITunAdapter для Windows (через WinTun) и Linux (через /dev/net/tun). Все операции возвращают Result<T, E> — без исключений.

Установка

dotnet add package TunnelForge.Tun --version 10.0.6

Поддерживаемые платформы

Платформа Реализация
Windows (x64, x86, ARM, ARM64) WinTun driver (wintun.dll)
Linux (x64, ARM, ARM64) /dev/net/tun + ioctl

Быстрый старт

Создание адаптера
// TunAdapterFactory возвращает Option<ITunAdapter>
// Some — на поддерживаемой ОС, None — на неподдерживаемой
TunAdapterFactory.Create("MyTunnel").Match(
    some: adapter =>
    {
        adapter.SetAddress("10.0.0.2", "255.255.255.0")
            .InspectErr(e => Console.WriteLine($"SetAddress failed: {e}"));

        adapter.Up()
            .InspectErr(e => Console.WriteLine($"Up failed: {e}"));

        // ... работа с адаптером ...

        adapter.Dispose();
        return Unit.Value;
    },
    none: () =>
    {
        Console.WriteLine("Платформа не поддерживается");
        return Unit.Value;
    }
);
Получение и отправка пакетов
byte[] buffer = new byte[65535];

// ReceivePacket возвращает Result<int, string>
adapter.ReceivePacket(buffer).Match(
    ok: bytes =>
    {
        if (bytes > 0)
            Console.WriteLine($"Получено {bytes} байт");
    },
    err: e => Console.WriteLine($"Ошибка: {e}")
);

// SendPacket возвращает Result<Unit, string>
byte[] packet = /* данные IP-пакета */;
adapter.SendPacket(packet, 0, packet.Length)
    .InspectErr(e => Console.WriteLine($"Отправка не удалась: {e}"));

Важные замечания

  • На Windows требуются права администратора.
  • На Linux требуются права root или capability CAP_NET_ADMIN.
  • ReadWaitHandle возвращает IntPtr.Zero на Linux — используйте блокирующий ReceivePacket.
  • Адаптер автоматически закрывается при вызове Dispose().
  • Все методы возвращают Result<T, E> — проверяйте IsOk/IsErr или используйте Match.

English

TunnelForge.Tun is a cross-platform library for virtual TUN adapters. It provides a unified ITunAdapter interface for Windows (via WinTun) and Linux (via /dev/net/tun). All operations return Result<T, E> — no exceptions.

Installation

dotnet add package TunnelForge.Tun --version 10.0.6

Supported Platforms

Platform Backend
Windows (x64, x86, ARM, ARM64) WinTun driver (wintun.dll)
Linux (x64, ARM, ARM64) /dev/net/tun + ioctl

Quick Start

Create an adapter
// TunAdapterFactory returns Option<ITunAdapter>
// Some on supported OS, None on unsupported
TunAdapterFactory.Create("MyTunnel").Match(
    some: adapter =>
    {
        adapter.SetAddress("10.0.0.2", "255.255.255.0")
            .InspectErr(e => Console.WriteLine($"SetAddress failed: {e}"));

        adapter.Up()
            .InspectErr(e => Console.WriteLine($"Up failed: {e}"));

        // ... use adapter ...

        adapter.Dispose();
        return Unit.Value;
    },
    none: () =>
    {
        Console.WriteLine("Platform not supported");
        return Unit.Value;
    }
);
Receive and send packets
byte[] buffer = new byte[65535];

// ReceivePacket returns Result<int, string>
adapter.ReceivePacket(buffer).Match(
    ok: bytes =>
    {
        if (bytes > 0)
            Console.WriteLine($"Received {bytes} bytes");
    },
    err: e => Console.WriteLine($"Error: {e}")
);

// SendPacket returns Result<Unit, string>
byte[] packet = /* IP packet data */;
adapter.SendPacket(packet, 0, packet.Length)
    .InspectErr(e => Console.WriteLine($"Send failed: {e}"));

Important Notes

  • Administrator privileges required on Windows.
  • Root or CAP_NET_ADMIN capability required on Linux.
  • ReadWaitHandle returns IntPtr.Zero on Linux — use blocking ReceivePacket instead.
  • Adapter is automatically cleaned up on Dispose().
  • All methods return Result<T, E> — check IsOk/IsErr or use Match.

Deutsch

TunnelForge.Tun ist eine plattformübergreifende Bibliothek für virtuelle TUN-Adapter. Sie bietet eine einheitliche ITunAdapter-Schnittstelle für Windows (via WinTun) und Linux (via /dev/net/tun). Alle Operationen geben Result<T, E> zurück — keine Exceptions.

Installation

dotnet add package TunnelForge.Tun --version 10.0.6

Unterstützte Plattformen

Plattform Backend
Windows (x64, x86, ARM, ARM64) WinTun-Treiber (wintun.dll)
Linux (x64, ARM, ARM64) /dev/net/tun + ioctl

Schnellstart

TunAdapterFactory.Create("MyTunnel").Match(
    some: adapter =>
    {
        adapter.SetAddress("10.0.0.2", "255.255.255.0");
        adapter.Up();
        // ... Adapter verwenden ...
        adapter.Dispose();
        return Unit.Value;
    },
    none: () =>
    {
        Console.WriteLine("Plattform nicht unterstützt");
        return Unit.Value;
    }
);

Wichtige Hinweise

  • Administratorrechte auf Windows erforderlich.
  • Root oder CAP_NET_ADMIN auf Linux erforderlich.
  • Alle Methoden geben Result<T, E> zurück — keine Exceptions.

简体中文

TunnelForge.Tun 是一个跨平台虚拟 TUN 适配器库。提供统一的 ITunAdapter 接口,支持 Windows(通过 WinTun)和 Linux(通过 /dev/net/tun)。所有操作返回 Result<T, E> — 无异常。

安装

dotnet add package TunnelForge.Tun --version 10.0.6

支持的平台

平台 后端
Windows (x64, x86, ARM, ARM64) WinTun 驱动 (wintun.dll)
Linux (x64, ARM, ARM64) /dev/net/tun + ioctl

快速开始

TunAdapterFactory.Create("MyTunnel").Match(
    some: adapter =>
    {
        adapter.SetAddress("10.0.0.2", "255.255.255.0");
        adapter.Up();
        // ... 使用适配器 ...
        adapter.Dispose();
        return Unit.Value;
    },
    none: () =>
    {
        Console.WriteLine("不支持的平台");
        return Unit.Value;
    }
);

重要提示

  • Windows 上需要管理员权限。
  • Linux 上需要 root 或 CAP_NET_ADMIN 权限。
  • 所有方法返回 Result<T, E> — 无异常。
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.6 148 4/16/2026
10.0.5 120 4/16/2026
10.0.4 117 4/16/2026
10.0.3 118 4/15/2026
10.0.2 116 4/15/2026
10.0.1 125 4/13/2026
10.0.0 142 4/8/2026
10.0.0-rc 135 4/8/2026 10.0.0-rc is deprecated because it is no longer maintained.

EN:
Version 10.0.6:
- Updated dependecies: Rustly.{Analyzers, Generators} 10.6.3 and Rustly 10.6.3.

RU:
Версия 10.0.6:
- Обновлены зависимости: Rustly.{Analyzers, Generators} 10.6.3 и Rustly 10.6.3.