.NET Library for working with WireGuard keys by wg-easy API
Type this command in project's folder:
dotnet add package WgEasyManager
- Get URL of your server with port
- Get password for access
- Initialize WgEasyClient:
private static WgEasyClient client = new("0.0.0.0:12345", "sup3rSecr3tPassw0rd", true);
//if your server hasn't SSL - set false
- Login to server:
static async Task Main(){
await client.LoginToServerIfNeeded();
//some code...
}
After Initialize in folder "wg-sessions" you can see "ip/port.wgmanager". It's cookies for access to your server.
For getting keys use method .GetKeys()
var keys = client.GetKeys();
//returns List<WireGuardKey>
Use method .CreateKey()
for key creating
- name - name of key
client.CreateKey("Lance's key");
//return key info in object 'WireGuardKey'
Also you can delete key with method DeleteKey()
with parameter clientId
Use method .BlockKey()
for key baning
- clientId - Client ID in wg-easy
client.DeleteKey("xxxx-xxxx-xxxx-xxxx");
// Key id you can get in object "WireGuardKey"
Also you can unblock key with method UnbanKey()
with parameter clientId
Use method .RenameKey()
for updating key's name
- clientId - client Id
- name - new name for this key
client.RenameKey("xxxx-xxxx-xxxx-xxxx", "Lance's key");
Use method .DownloadConfig()
for downloading .config file
- clientId - Client Id for downloading
- path - path for saving .config file
client.DownloadConfig("xxxx-xxxx-xxxx-xxxx", "path/to/download");
Also you can download QR-Code with method DownloadQrCode()
with parameters clientId and path