WgConf 1.0.0
dotnet add package WgConf --version 1.0.0
NuGet\Install-Package WgConf -Version 1.0.0
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="WgConf" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WgConf" Version="1.0.0" />
<PackageReference Include="WgConf" />
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 WgConf --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WgConf, 1.0.0"
#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 WgConf@1.0.0
#: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=WgConf&version=1.0.0
#tool nuget:?package=WgConf&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WgConf
A .NET library for reading and writing WireGuard configuration files with strongly typed models and comprehensive error handling.
Features
- Strongly typed models for
[Interface]and[Peer]sections - Reader/writer pattern with validation and error accumulation
- Value types for CIDR notation and WireGuard endpoints
- Sync and async APIs for reading and writing
- Case insensitive property parsing and
#comment stripping
Installation
dotnet add package WgConf
Quick Start
Reading a configuration
using WgConf;
var config = WireguardConfiguration.Parse(configText);
using WgConf;
var config = WireguardConfiguration.Load("wg0.conf");
using WgConf;
if (WireguardConfiguration.TryParse(configText, out var config, out var errors))
{
Console.WriteLine($"Loaded {config.Peers.Count} peers");
}
else
{
foreach (var error in errors)
Console.WriteLine(error);
}
Writing a configuration
using WgConf;
var config = new WireguardConfiguration
{
PrivateKey = Convert.FromBase64String("YAnz5TF+lXXJte14tji3zlMNftqN9xFSeRCFKtheBGY="),
ListenPort = 51820,
Address = CIDR.Parse("10.0.0.1/24"),
};
config.Peers.Add(new WireguardPeerConfiguration
{
PublicKey = Convert.FromBase64String("xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg="),
AllowedIPs = [CIDR.Parse("10.0.0.2/32")],
Endpoint = WireguardEndpoint.Parse("example.com:51820"),
PersistedKeepalive = 25,
});
config.Save("wg0.conf");
Configuration Model
WireguardConfiguration (Interface)
PrivateKey- Base64 encoded private key (32 bytes, required)ListenPort- UDP port (1-65535, required)Address- Interface IP address and subnet (CIDR, required)PreUp,PostUp,PreDown,PostDown- Hook commands (optional)Peers- Collection of peer configurations
WireguardPeerConfiguration (Peer)
PublicKey- Base64 encoded public key (32 bytes, required)AllowedIPs- Array of allowed IP ranges (CIDR[], required)Endpoint- Optional peer endpoint (host:portor[ipv6]:port)PresharedKey- Optional preshared key (Base64, 32 bytes)PersistedKeepalive- Optional keepalive interval in seconds
Value Types
CIDR
Represents an IP address with prefix length (for example 10.0.0.1/24).
var cidr = CIDR.Parse("10.0.0.1/24");
Console.WriteLine(cidr.ToString());
WireguardEndpoint
Represents a WireGuard endpoint in host:port format with IPv6 support.
var endpoint = WireguardEndpoint.Parse("example.com:51820");
var ipv6 = WireguardEndpoint.Parse("[::1]:51820");
Requirements
- .NET 8.0 or later
Related Packages
WgConf.Amnezia- Extension package for AmneziaWG obfuscation parameters
License
MIT License - see LICENSE for details.
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on WgConf:
| Package | Downloads |
|---|---|
|
WgConf.Amnezia
Extension for WgConf adding support for AmneziaWG-specific obfuscation parameters. Includes reader and writer for AmneziaWG configuration files. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 481 | 1/30/2026 |