using Microsoft.Extensions.Hosting;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
namespace FastGithub.PacketIntercept
{
///
/// tcp拦截后台服务
///
[SupportedOSPlatform("windows")]
sealed class TcpInterceptHostedService : BackgroundService
{
private readonly IEnumerable tcpInterceptors;
///
/// tcp拦截后台服务
///
///
public TcpInterceptHostedService(IEnumerable tcpInterceptors)
{
this.tcpInterceptors = tcpInterceptors;
}
///
/// https后台
///
///
///
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
var tasks = this.tcpInterceptors.Select(item => item.InterceptAsync(stoppingToken));
return Task.WhenAll(tasks);
}
}
}