Pouyan.SingBox
1.0.0.10
dotnet add package Pouyan.SingBox --version 1.0.0.10
NuGet\Install-Package Pouyan.SingBox -Version 1.0.0.10
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="Pouyan.SingBox" Version="1.0.0.10" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pouyan.SingBox --version 1.0.0.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Pouyan.SingBox, 1.0.0.10"
#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 Pouyan.SingBox as a Cake Addin #addin nuget:?package=Pouyan.SingBox&version=1.0.0.10 // Install Pouyan.SingBox as a Cake Tool #tool nuget:?package=Pouyan.SingBox&version=1.0.0.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
<div align="center">
Pouyan.SingBox
Template project: GitHub
Configure and run sing-box with ease.
Based on sing-box
's official documentation.
</div>
Configuration examples
for more configuration examples, including Route Rules or Dns configuration, please refer to sing-box
's official documentation.
Mixed inbound:
var mixedInbound = Pouyan.SingBox.Inbound.CreateMixedInbound(
listen:"127.0.0.1",
listenPort: 3080
);
Tun inbound:
- Please note that tun inbound requires your app to have administrator privileges.
var tunInbound = Pouyan.SingBox.Inbound.CreateTunInbound();
Parse outbound profiles:
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();
Running
- In order to use this library for running
sing-box
you first need to obtain it's executable from its original repository. - You need to have the path to this executable and pass it to
Tunnel
's constructor.
var singbox = new Pouyan.SingBox.Tunnel("sing-box.exe", [mixedInbound]);
- you can pass a
CancellationToken
to theSingBoxWrapper.StartAsync
method, if you cancel it, thesing-box
proccess will end. this parameter is optional. - if you need sing-box's logs, you need to subscribe to the Onlog event (optional).
var cts = new CancellationTokenSource();
singbox.StartAsync(myProfile, cts, (sender , log) =>
{
Console.WriteLine(log);
});
Take outbounds from subscribe:
var profiles = SingBox.GetProfile.GetProfilesFromSubscribe(url);
Url testing
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);
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Pouyan.Network (>= 1.0.0.2)
- SingBoxLib (>= 1.1.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.