Initial commit
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
using SingboxLib.Configuration.Outbound.Shared;
|
||||
using SingBoxLib.Configuration;
|
||||
using SingBoxLib.Configuration.Dns;
|
||||
using SingBoxLib.Configuration.Inbound;
|
||||
using SingBoxLib.Configuration.Inbound.Abstract;
|
||||
using SingBoxLib.Configuration.Outbound;
|
||||
using SingBoxLib.Configuration.Outbound.Abstract;
|
||||
using SingBoxLib.Configuration.Shared;
|
||||
using SingBoxLib.Parsing;
|
||||
using SingBoxLib.Runtime;
|
||||
|
||||
namespace WinWARP.Service;
|
||||
|
||||
public class Worker(ILogger<Worker> logger) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
var profileUrl = "vless://5af742f0-5915-492e-b618-406e8170c77f@redlt.jojackcraft.ru:443?encryption=none&flow=xtls-rprx-vision&type=tcp&security=reality&sni=goo.su&fp=qq&pbk=1vSZjvhZO01oAEH3b7eebR1qF5dLU1Dq2E7xu8pwGSs&sid=428ef87fd47a3a32&spx=%2F#%F0%9F%87%B1%F0%9F%87%B9%C2%B2%E2%9A%A1%20%D0%9B%D0%B8%D1%82%D0%B2%D0%B0";
|
||||
var profile = ProfileParser.ParseProfileUrl(profileUrl);
|
||||
|
||||
// 1. Define your sing-box configuration
|
||||
var config = new SingBoxConfig
|
||||
{
|
||||
Inbounds = new()
|
||||
{
|
||||
new MixedInbound
|
||||
{
|
||||
Listen = "127.0.0.1",
|
||||
ListenPort = 12534,
|
||||
SetSystemProxy = true
|
||||
}
|
||||
},
|
||||
Outbounds = new List<OutboundConfig>
|
||||
{
|
||||
new VLessOutbound
|
||||
{
|
||||
Server = "redlt.jojackcraft.ru",
|
||||
ServerPort = 443,
|
||||
Uuid = "5af742f0-5915-492e-b618-406e8170c77f",
|
||||
Flow = "xtls-rprx-vision",
|
||||
Tls = new OutboundTlsConfig
|
||||
{
|
||||
Enabled = true,
|
||||
ServerName = "goo.su",
|
||||
UTls = new UtlsConfig
|
||||
{
|
||||
Enabled = true,
|
||||
Fingerprint = "qq"
|
||||
},
|
||||
Reality = new OutboundRealityConfig
|
||||
{
|
||||
Enabled = true,
|
||||
PublicKey = "1vSZjvhZO01oAEH3b7eebR1qF5dLU1Dq2E7xu8pwGSs",
|
||||
ShortId = "428ef87fd47a3a32"
|
||||
}
|
||||
},
|
||||
PacketEncoding = "xudp"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 2. Initialize wrapper with path to sing-box executable
|
||||
var wrapper = new SingBoxWrapper("SingBox/sing-box.exe");
|
||||
|
||||
// 3. Subscribe to the log event to inspect output or errors
|
||||
wrapper.OnLog += (sender, logArgs) =>
|
||||
{
|
||||
if (logger.IsEnabled(LogLevel.Information))
|
||||
{
|
||||
logger.LogInformation(logArgs);
|
||||
}
|
||||
};
|
||||
|
||||
// 4. Start the sing-box process
|
||||
using var cts = new CancellationTokenSource();
|
||||
//var runTask = wrapper.StartAsync(config, stoppingToken);
|
||||
|
||||
// 5. Terminate the sing-box process gracefully by cancelling the token
|
||||
//await cts.CancelAsync();
|
||||
//await runTask;
|
||||
|
||||
//while (!stoppingToken.IsCancellationRequested)
|
||||
//{
|
||||
// if (logger.IsEnabled(LogLevel.Information))
|
||||
// {
|
||||
// logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||
// }
|
||||
// await Task.Delay(1000, stoppingToken);
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user