quieckly to create a vpn client that's support v2ray protocols
License
—
Deps
2
Install Size
—
Vulns
✓ 0
Published
Aug 19, 2025
$ dotnet add package Pouyan.SingBoxConfigure and run sing-box with ease.
Based on sing-box's official documentation.
for more configuration examples, including Route Rules or Dns configuration, please refer to sing-box's official documentation.
var mixedInbound = Pouyan.SingBox.Inbound.CreateMixedInbound(
listen:"127.0.0.1",
listenPort: 3080
);
var tunInbound = Pouyan.SingBox.Inbound.CreateTunInbound();
var myProfileUrl = "trojan://myLovelyPassword@myserver.server:443?security=tls&sni=mySni&type=grpc&serviceName=myGrpcPath#MyTrojanServer";
var myProfile = ProfileParser.ParseProfileUrl(myProfileUrl);
Additionally you can convert parsed profiles back to string url:
var myProfileUrl = myProfile.ToProfileUrl();
sing-box you first need to obtain it's executable from its original repository.Tunnel's constructor.var singbox = new Pouyan.SingBox.Tunnel("sing-box.exe", [mixedInbound]);
CancellationToken to the SingBoxWrapper.StartAsync method, if you cancel it, the sing-box proccess will end. this parameter is optional.var cts = new CancellationTokenSource();
singbox.StartAsync(myProfile, cts, (sender , log) =>
{
Console.WriteLine(log);
});
var profiles = SingBox.GetProfile.GetProfilesFromSubscribe(url);
You can use UrlTestAsync classes to easily test if the proxies are healthy and valid
var myProfileUrl = "trojan://myLovelyPassword@myserver.server:443?security=tls&sni=mySni&type=grpc&serviceName=myGrpcPath#MyTrojanServer";
var myProfile = ProfileParser.ParseProfileUrl(myProfileUrl);
var profileTester = new ProfileTester("sing-box.exe");
var test = await profileTester.UrlTestAsync(myProfile, 7087);
Console.WriteLine($"Success: {test.Result.Success}, Delay: {test.Result.Delay}");
List<ProfileItem>:
var test = await profileTester.UrlTestAsync(profiles);