SoftEtherApi 1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SoftEtherApi --version 1.0.0
NuGet\Install-Package SoftEtherApi -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="SoftEtherApi" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SoftEtherApi --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SoftEtherApi, 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.
// Install SoftEtherApi as a Cake Addin #addin nuget:?package=SoftEtherApi&version=1.0.0 // Install SoftEtherApi as a Cake Tool #tool nuget:?package=SoftEtherApi&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SoftEtherApi
C# .net API to remote control SoftEther VPN Server
Examples
Program.cs
using System;
using SoftEtherApi;
namespace TestProgram
{
internal class Program
{
public static void Main()
{
var ip = "";
ushort port = 5555;
var pw = "";
var hubName = "";
var userName = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
if (!connectResult.Valid())
{
Console.WriteLine(connectResult.Error);
return;
}
var authResult = softEther.Authenticate(pw);
if (!authResult.Valid())
{
Console.WriteLine(authResult.Error);
return;
}
var user = softEther.HubApi.GetUser(hubName, userName);
Console.WriteLine(user.Valid() ? "Success" : user.Error.ToString());
}
}
}
}
Connect and authenticate with SoftEther
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var pw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
if (!connectResult.Valid())
{
Console.Write("Could not Connect: ");
Console.WriteLine(connectResult.Error);
return;
}
var authResult = softEther.Authenticate(pw);
if (!authResult.Valid())
{
Console.Write("Could not authenticate: ");
Console.WriteLine(authResult.Error);
return;
}
}
Connect and authenticate with specific hub
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var hubPw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
var authResult = softEther.Authenticate(hubPw, "testHub");
}
Get user by name
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var pw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
var authResult = softEther.Authenticate(pw);
var user = softEther.HubApi.GetUser("testHub", "testUser");
Console.WriteLine(user.Valid() ? "Success" : user.Error.ToString());
}
Create user
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var pw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
var authResult = softEther.Authenticate(pw);
var user = softEther.HubApi.CreateUser("testHub", "testUser", "userPw");
Console.WriteLine(user.Valid() ? "Success" : user.Error.ToString());
}
Create online hub
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var pw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
var authResult = softEther.Authenticate(pw);
var hub = softEther.HubApi.Create("testHub", "hubPw", true); //true: set hub online
Console.WriteLine(user.Valid() ? "Success" : hub.Error.ToString());
}
Create hub and set it online
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var pw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
var authResult = softEther.Authenticate(pw);
var hub = softEther.HubApi.Create("testHub", "hubPw", true); //true: set hub online
Console.WriteLine(user.Valid() ? "Success" : hub.Error.ToString());
}
Activate SecureNat and replace accessList to allow network only
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var pw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
var authResult = softEther.Authenticate(pw);
var network = "192.168.178.0";
var networkSubnet = "255.255.255.0";
var hubName = "testHub";
var natOnline = softEther.HubApi.EnableSecureNat(hubName);
//Add route from secureNat to network for clients
var natOptions = softEther.HubApi.GetSecureNatOptions(hubName);
var pushRoutesResult = softEther.HubApi.SetSecureNatDhcpPushRoutes(hubName, new DhcpRouteCollection
{
{network, networkSubnet, natOptions.DhcpGatewayAddress.ToString()}
});
//Replace accessList
//Allow access only from secureNat to network. VPN-Clients cannot talk with eachother and access outside of the network is denied
var networkAclList = softEther.HubApi.SetAccessList(hubName,
AccessListFactory.AllowNetworkOnly(network, networkSubnet,
natOptions.DhcpGatewayAddress, natOptions.DhcpSubnetMask));
}
Activate SecureNat and replace accessList to allow devices only
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var pw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
var authResult = softEther.Authenticate(pw);
var network = "192.168.178.0";
var networkSubnet = "255.255.255.0";
var hubName = "testHub";
var natOnline = softEther.HubApi.EnableSecureNat(hubName);
//Add route from secureNat to network for clients
var natOptions = softEther.HubApi.GetSecureNatOptions(hubName);
var pushRoutesResult = softEther.HubApi.SetSecureNatDhcpPushRoutes(hubName, new DhcpRouteCollection
{
{network, networkSubnet, natOptions.DhcpGatewayAddress.ToString()}
});
//Replace accesslist with DevicesOnly
var deviceAclList = softEther.HubApi.SetAccessList(hubName, AccessListFactory.AllowDevicesOnly(
natOptions.DhcpGatewayAddress, natOptions.DhcpSubnetMask, new AccessDevice("192.168.178.240", "Server")));
//Add another device to the accessList afterwards
var fritz = softEther.HubApi.AddAccessList(hubName, AccessListFactory.AccessToDevice(AccessListFactory.AllowDevicesPriority,
"FritzBox", IPAddress.Parse("192.168.178.1"), natOptions.DhcpGatewayAddress, natOptions.DhcpSubnetMask));
}
Get SoftEther-Certificate
var ip = "";
ushort port = 5555; //one of the ports out of the Listener List (443, 992, 1194, 5555)
var pw = "";
using (var softEther = new SoftEther(ip, port))
{
var connectResult = softEther.Connect();
var authResult = softEther.Authenticate(pw);
var serverCert = softEther.ServerApi.GetCert();
Console.WriteLine(serverCert.Cert.Issuer);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial Release