.NET binding over WireGuardNT
WireGuardNT-PInvoke library written in C# targeting .NET Standard 2.0. Version.
Save the configuration file to the path of the Example program, and then use the following code to load the configuration file.
Also, I created project with reference to the following link.
WireGuardNT/Example.C WireGuardNT/embeddable-dll-service
[Interface]
Address = 10.0.0.2/24
ListenPort = 51820
PrivateKey = ==SOME===PRIVATE===key==
[Peer]
PublicKey = ==SOME===PUBLIC===KEY==
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = myserver.dyndns.org:51820
...
NET_LUID adapterLuid;
WgConfig WgConfig = new WgConfig();
var baseName = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
var configFile = System.IO.Path.Combine(baseName, "client.conf");
//Read all line from config file
var configAllLinesLine = File.ReadAllLines(configFile);
var adapterName = "wgtest";
var tunnelType = "wgtest";
//Create Some GUID
var adapterGuid = Guid.Parse("{0xdeadc001,0xbeef,0xbabe,{0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}}");
//Get Adapter
var adapter = new Adapter(adapterName, tunnelType);
adapter.ParseConfFile(configAllLinesLine, out WgConfig);
...
adapter.SetConfiguration(WgConfig);
adapter.SetStateUp();
And Run the program.
Visual Studio -> Choose WireGuard-Cli -> Run
Run Cmd -> netsh interface show interface or ipconfig
Usage: WireGuard-Cli.exe [OPTION...]
-v version
-c config "config file path" default path is "client.conf"
-n name "adapter name" default name is "client"
-t type "tunnel type" default type is "client"
Install-Package WireGuardNT-PInvoke
[ ] IPv6 Support
[ ] Code Refactor
[ ] Nuget Package
[ ] Add more example
[ ] TestCode