YLFramework.AspNetCore.Middleware
2.0.0-alpha.1
This is a prerelease version of YLFramework.AspNetCore.Middleware.
dotnet add package YLFramework.AspNetCore.Middleware --version 2.0.0-alpha.1
NuGet\Install-Package YLFramework.AspNetCore.Middleware -Version 2.0.0-alpha.1
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="YLFramework.AspNetCore.Middleware" Version="2.0.0-alpha.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YLFramework.AspNetCore.Middleware" Version="2.0.0-alpha.1" />
<PackageReference Include="YLFramework.AspNetCore.Middleware" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YLFramework.AspNetCore.Middleware --version 2.0.0-alpha.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: YLFramework.AspNetCore.Middleware, 2.0.0-alpha.1"
#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.
#:package YLFramework.AspNetCore.Middleware@2.0.0-alpha.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=YLFramework.AspNetCore.Middleware&version=2.0.0-alpha.1&prerelease
#tool nuget:?package=YLFramework.AspNetCore.Middleware&version=2.0.0-alpha.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
YLFramework.AspNetCore.Middleware
面向 Kestrel 连接管道的可复用中间件集合。所有中间件都通过 ListenOptionsExtensions 暴露 Use* 风格扩展方法,一行接入。
中间件清单
| 子模块 | 扩展方法 | 作用 |
|---|---|---|
| Echo | UseEcho() |
TCP 回显:把客户端写入的全部字节原样写回。调试 / 探活用 |
| FlowAnalyze | UseFlowAnalyze(IFlowAnalyzer) |
流量统计:按 FlowType(上行 / 下行 / 总和)累计字节数,可注册自定义分析器把指标推送到 Prometheus / 日志等 |
| FlowXor | UseFlowXor(byte[] key) |
字节级 XOR 混淆:常用于代理场景下对透明 TCP 流量做轻度加密,绕过旁路检测 |
| HttpProxy | UseHttpProxy(...) |
HTTP CONNECT 隧道代理:支持认证(IHttpProxyAuthenticationHandler)+ PROXY 协议解析(ProxyMiddleware) |
| TunnelProxy | UseTunnelProxy() |
透传式 TCP 隧道:把 Kestrel 端点变为可转发的中转节点 |
| Telnet | UseTelnet() + 三个嵌套中间件 UseBye() / UseEcho() / UseEmpty() |
Telnet 协议服务端:根据命令返回 BYE / 回显 / 空行 |
| TelnetProxy | UseXorTelnetProxy(byte[] key) |
Telnet 协议上的 XOR 代理:把 Telnet 客户端通过 XOR 流转发到上游 |
| TlsDetection | UseTlsDetection(...) |
TLS 特征识别:通过 FakeTlsConnectionFeature 模拟 TLS 记录,让上游把裸 TCP 误判为 TLS 流量(用于协议伪装) |
用法示例
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(options =>
{
options.ListenAnyIP(8080, listen =>
{
listen.UseFlowAnalyze(new ConsoleFlowAnalyzer());
listen.UseFlowXor(Encoding.ASCII.GetBytes("secret"));
listen.UseEcho();
});
});
服务注册
部分中间件需要把分析器 / 认证处理器等注入 DI:
builder.Services.AddFlowAnalyze();
builder.Services.AddHttpProxyAuthentication<MyAuthHandler>();
DI 注册方法在对应子模块的 ServiceCollectionExtensions 中。
设计要点
- 每个中间件都是
DelegatingDuplexPipe或DelegatingStream包装,对性能影响极小 TlsDetection通过临时替换ConnectionContext.Features实现协议层降级,连接关闭后自动恢复HttpProxy支持 PROXY 协议 v1 / v2 解析(ProxyProtocol)以及用户自定义认证
版本
2.0.0-alpha.1,版本由本项目 csproj 的 <Version> 独立声明。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- BouncyCastle.Cryptography (>= 2.7.0)
- Yarp.ReverseProxy (>= 2.3.0)
- YLFramework.AspNetCore (>= 2.0.0-alpha.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-alpha.1 | 23 | 10/17/2026 |
| 1.0.3-alpha.6 | 82 | 5/1/2026 |
| 1.0.3-alpha.5 | 69 | 5/1/2026 |
| 1.0.3-alpha.4 | 74 | 4/12/2026 |
| 1.0.3-alpha.3 | 72 | 4/12/2026 |
| 1.0.3-alpha.2 | 74 | 4/12/2026 |
| 1.0.3-alpha.1 | 74 | 4/11/2026 |
| 1.0.2-alpha.7 | 79 | 4/11/2026 |
| 0.0.1 | 147 | 12/31/2025 |
| 0.0.1-alpha.1 | 72 | 4/11/2026 |