160 Commits

Author SHA1 Message Date
token 3e0d1f1b2a chore: 清理本地 Claude 配置 2026-08-31 09:47:14 +08:00
token cd444c893e style: 规范前端服务文件结尾 2026-08-31 09:47:10 +08:00
token 2077e56029 docs: 保存实施计划 2026-08-31 09:47:08 +08:00
token d226c1b977 test(bot-protection): 增加 Turnstile 服务测试 2026-08-31 09:45:59 +08:00
token 724ec5e858 feat(bot-protection): 接入 Turnstile 机器人防护 2026-08-31 09:45:35 +08:00
token 87f1fe3853 feat(resource): 增加网关连接与转发资源限制 2026-08-31 09:44:49 +08:00
token 5e52fefd0f fix(tunnel): 完善隧道连接生命周期清理 2026-08-31 09:42:04 +08:00
token 2afee30f2c fix: 还原 v2.14.0 出站协议语义与建连参数,移除 Http2UnencryptedSupport 开关
无全局开关时 Version=2.0 + OrLower 对明文上游由 .NET 静默降级 HTTP/1.1
(不做 h2c 探测),HTTPS 上游恢复 ALPN 协商 HTTP/2 多路复用;
隧道路径改用 RequestVersionExact 原生启用 h2c,不再依赖全局开关。
ConnectTimeout 回调至 1s、连接池寿命/空闲恢复 10min/2min,
高峰期上游过载时半开连接快速释放 fd,缓解 ENFILE。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 17:18:34 +08:00
token 72d2a7aa0a feat: 网关路由集群节点展示健康探测与代理状态
在服务集群列表中显示每个上游的主动探测和被动代理结果,并修正综合健康判定,避免被动 Unknown 把已探测成功的节点标成未知。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 01:49:57 +08:00
token 6903369da2 fix: 默认出站客户端固定 HTTP/1.1 并移除每上游连接数上限
上限会让高峰期多余请求在连接池内排队,排队请求持续占用入站连接反而加速
fd 堆积;恢复 v2.14.0 的无上限行为,出站规模交由系统 nofile 约束。
HTTP/2 仅保留给按 h2c 设计的隧道路径,HTTPS 上游 ALPN 只出 http/1.1。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-23 01:48:17 +08:00
token bf0af07298 feat: replace TunnelDetailModal with NodeDetailSheet for improved node management UI
- Implemented NodeDetailSheet component to display detailed information about tunnel nodes, including connection info, key management, and proxy rules.
- Removed the TunnelDetailModal component as its functionality has been integrated into the new NodeDetailSheet.
- Updated TunnelPage to utilize NodeDetailSheet for displaying node details and managing node actions.
- Enhanced TunnelService with new API methods for creating nodes, updating node details, and regenerating node keys.
- Improved UI elements for better user experience, including search functionality and loading states.
2026-08-21 00:54:52 +08:00
token a0c651ec9f fix: 限制每上游最大出站连接数,避免高并发耗尽文件描述符
共享连接池的 MaxConnectionsPerServer 曾放开为 int.MaxValue,HTTP/1.1 上游
一请求一连接,高并发下无限建连触发 ENFILE(Too many open files in system)。
恢复为有界上限(默认 1024,与 2.14.0 稳定行为一致),可通过
MAX_CONNECTIONS_PER_UPSTREAM 环境变量调整;故障转移中间件同步修复。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-17 23:21:58 +08:00
token 3ce677c73e fix: 对 HTTPS 上游启用多条 HTTP/2 连接
单连接约 100 路并发流打满后另开连接,避免高并发排队。明文 http:// 仍固定 HTTP/1.1,不受此开关影响。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 10:29:44 +08:00
token 64ed8e3c74 fix: 避免明文上游 h2c 探测耗尽文件描述符
普通 http:// 上游固定 HTTP/1.1,并让 YARP cluster 共用一份出站连接池,避免 prior-knowledge 失败后套接字翻倍。容器提高 nofile,并以 root 运行以免 bind mount 的 data/certs 无法写入。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 10:27:30 +08:00
token 2cc6644ccb fix: 修复 Program.cs 对象初始化器多余括号导致的编译失败
CreateSlimBuilder 的 WebApplicationOptions 被多写了一个 ),CI Native AOT 发布因此中断。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 20:39:12 +08:00
token 2c669b29d3 revert: 撤回对明文上游强制 HTTP/2 的转发配置
h2c VersionPolicy 会导致部分上游异常,先恢复由 YARP 默认协商协议。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 20:23:01 +08:00
token 2b8bfc1666 fix(stats): 暴露统计库失败原因并修复 Docker 目录权限
chiseled 镜像以 UID 1654 运行,chmod 给宿主机登录用户不够。仪表盘改为展示真实错误,权限恢复后自动重试,compose 启动时 chown 数据目录。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 20:22:59 +08:00
token f226606c41 feat: 支持明文上游 HTTP/2(h2c)
打开 Http2UnencryptedSupport,让 YARP 对 http:// 上游走 prior-knowledge HTTP/2,避免静默降到 HTTP/1.1 占满连接。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 10:55:25 +08:00
token de605253b2 docs: 补充集群说明与产品截图
README 增加主从集群、访问节点中继,并配上控制面与隧道截图。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 01:37:57 +08:00
token 67521ad227 fix(stats): Native AOT 下显式初始化 SQLite 并提示统计降级
裁剪会丢掉 SQLitePCLRaw 模块初始化器,导致 stats.db 打不开、仪表盘静默变成暂无数据。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 01:37:57 +08:00
token 095c2cb80f fix(ui): 访问节点下拉移到目标页,无集群时不显示
独立部署或尚未接入从节点时隐藏该选项,避免干扰原有路由表单。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 01:37:57 +08:00
token 59d2af3ba6 feat: 支持地区黑名单与集群访问节点中继
基于 ip2region 预编译地区 IP 区间实现零查询封禁,并支持域名指定集群节点回源时在节点间安全中继。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-12 15:03:27 +08:00
token 5179aed038 chore(release): v2.15.0 更新日志
Co-authored-by: Cursor <cursoragent@cursor.com>
v2.15.0
2026-08-12 13:38:06 +08:00
token 356558c765 feat: 集群管理与 MessagePack 节点同步协议,重写限流引擎并优化统计性能
- 集群:主/从角色、接入码一键加入、WebSocket 全量配置+证书同步、
  心跳与节点管理,前端新增集群管理页与 /api/v1/cluster 接口组
- 协议:节点间通信采用 MessagePack + LZ4 二进制编码,源生成 Resolver
  完全兼容 Native AOT,证书文件原生二进制传输
- 限流:移除 AspNetCoreRateLimit,改用内置 System.Threading.RateLimiting
  按 IP 分区固定窗口限流
- 性能:静态站点 ETag/304 协商缓存、统计链路内存封顶与两代缓存、
  配置服务并发安全加固
- 前端:证书/限流/安全/隧道/端口转发等页面动画补齐

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-12 13:37:56 +08:00
token f7ebf85f62 feat: 文件存储分片上传与前端动画/路由重构,补充架构文档
- FileStorageService 增加分片上传(暂存目录白名单校验、24h 过期清理、合并/放弃接口)
- 新增 MergeChunksRequest / AbortUploadRequest DTO 并注册到 AOT JsonContext
- 前端文件管理器:分片上传队列、复制/移动/压缩/解压/下载,剪贴板存节点快照
- 抽出 motion 动画组件与 routes/lazy-pages 路由懒加载单源,侧边栏 hover 预取
- 补全 README 架构、源码布局、运行数据流与隧道数据路径说明
2026-08-08 02:30:04 +08:00
token b7561cd08c feat: implement system settings for log retention configuration
- Added a new SystemSettingPage for managing log retention days.
- Introduced LogRetention service to handle log retention settings.
- Updated SettingService to include methods for getting and setting log retention.
- Enhanced AbnormalIpMonitor to manage IP entries more efficiently with eviction logic.
- Refactored ClusterRequestFailoverMiddleware to improve request handling and routing.
- Improved BlacklistAndWhitelistService to utilize IpPolicyMatcher for IP policies.
- Added a new FailoverRouteTable and FailoverEntry classes for better route management.
- Updated various services to support new configuration versioning.
- Enhanced error handling and logging throughout the middleware and services.
2026-07-24 23:56:23 +08:00
token 36b5dd192f feat: improve gateway service cards and client IP sources 2026-07-24 16:17:55 +08:00
token 4c96ca2ed1 Merge pull request #32 from 239573049/fix/acme-challenge-empty-payload-aot
fix(acme): 修复 internal 载荷属性在 AOT 下被丢弃导致 finalize CSR 为空
2026-07-22 18:50:26 +08:00
token 2d61d02ed9 fix(acme): 修复 internal 载荷属性在 AOT 下被丢弃导致 finalize CSR 为空
Order.Payload.Csr 与 Account.Payload.OnlyReturnExisting 声明为 internal,
System.Text.Json 源生成器只序列化 public 成员,二者被静默丢弃:
- finalize 请求缺少 csr 字段,Let's Encrypt 报
  'asn1: syntax error: sequence truncated'
- onlyReturnExisting 丢失会破坏"仅返回已有账号"流程

改为 public 并加 [JsonInclude]。外层 Payload 类本身是 internal,
不会扩大公共 API 表面。

本地验证:真实 CSR 经签名后 csr 字段完整往返(DER 278B,tag 0x30),
onlyReturnExisting 正常序列化。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 18:46:40 +08:00
token b67c2d5498 Merge pull request #31 from 239573049/fix/acme-challenge-empty-payload-aot
fix(acme): 修复挑战验证阶段匿名 {} 载荷在 AOT 下无 JsonTypeInfo 崩溃
2026-07-22 18:11:38 +08:00
token 01d17e92b4 fix(acme): 修复挑战验证阶段匿名 {} 载荷在 AOT 下无 JsonTypeInfo 崩溃
ChallengeContext.Validate 使用 new {} 作为空对象载荷,Native AOT 下
CertesJsonContext.GetTypeInfo(匿名类型) 返回 null,JwsSigner.Sign 调用
JsonSerializer.Serialize(payload, null) 抛出 ArgumentNullException,
导致证书申请在挑战验证阶段失败。

- 新增已注册的 EmptyObject 载荷类型,序列化为 {}(RFC 8555 §7.5.1)
- JwsSigner.Sign 对无法解析元数据的载荷抛出可诊断的 InvalidOperationException,
  而非深层 STJ 的裸 ArgumentNullException
- 保留 null 载荷 -> 空串(POST-as-GET)语义

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 18:05:50 +08:00
token 23e2a25516 fix: 更新 JwsHeader 中的 Jwk 和 OldKey 属性为 object 类型,以支持运行时类型序列化 v2.14.1 2026-07-22 17:26:48 +08:00
token e7963b5282 fix: 更新 Dockerfile,添加 Microsoft apt 源以安装 libmsquic 2026-07-22 16:15:52 +08:00
token 6f96f0d880 fix(aot): 隔离 PerformanceCounter 以修复 Linux Native AOT 构建失败
System.Diagnostics.PerformanceCounter 依赖反射、不兼容 Native AOT,
导致 linux-x64/arm64 的 dotnet publish 在 AOT 链接阶段失败。

- csproj: 按 RID 定义 WINDOWS 常量,PerformanceCounter 包仅 Windows 目标引用
- QpsService/ISystemUsage: 用 #if WINDOWS 隔离所有 PerformanceCounter 引用,
  非 Windows 走已有的 /proc 与 P/Invoke 实现,CPU/磁盘统计降级为 0
- ConfigurationService: 顺带修复 AOT 迁移遗漏的 _jsonOptions,改用源生成上下文

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 15:20:27 +08:00
token 1e18177c88 Merge branch 'main' of https://github.com/239573049/FastGateway 2026-07-22 14:49:19 +08:00
token fdf52f5656 fix: 更新 Dockerfile,切换 Node.js 版本并优化构建阶段,增强 Native AOT 支持 2026-07-22 14:46:07 +08:00
token c8e9efb9f6 Merge pull request #30 from 239573049/vendor-certes-aot
Vendor certes aot
2026-07-22 14:45:53 +08:00
token 0ef26345d6 Merge branch 'main' into vendor-certes-aot 2026-07-22 14:45:42 +08:00
token 401f6b1ec2 Merge branch 'main' into vendor-certes-aot 2026-07-22 14:41:23 +08:00
token ace59e5b36 feat: Enhance JSON serialization and DTO usage across services
- Introduced AppJsonContext for optimized JSON serialization with source generation.
- Updated ResultFilter to handle EmptyHttpResult and EmptyResult correctly.
- Refactored ClusterRequestFailoverMiddleware and ProxyErrorResponseMiddleware to use DTOs for error responses.
- Modified ConfigurationService to utilize the new JSON context for configuration loading and saving.
- Enhanced FileStorageService to return structured DTOs instead of anonymous objects.
- Updated QpsService to return structured QPS data using DTOs.
- Refactored RateLimitService to return structured error responses using DTOs.
- Implemented SqlRunner for lightweight ADO.NET operations, replacing Dapper for compatibility with Native AOT.
- Refactored Statistics services to utilize SqlRunner for database operations, ensuring type safety and explicit parameter binding.
- Updated SystemService to return structured system information using DTOs.
- Enhanced StreamForwardService to return structured data for port forwarding lists.
2026-07-22 14:30:22 +08:00
token 224e109618 fix: 优化后台服务异常处理,避免影响网关主流程;改进配置文件写入逻辑,增强稳定性 2026-07-22 11:41:16 +08:00
token 5c7b9ccbd9 xg 2026-07-22 10:03:37 +08:00
token 927f83f1f8 fix: 优化请求超时和连接超时配置,支持流式响应
1. ConnectTimeout 从 1s 提升到 10s:避免跨域/高延迟场景握手失败
2. RequestTimeout 从默认 100s 改为 10 分钟:防止大文件/慢上游/AI 流式响应在传输中被截断
3. 增强超时豁免机制:
   - 请求阶段检测标准 SSE(Accept: text/event-stream)直接豁免
   - 响应阶段检测流式响应(Content-Type: text/event-stream)二次豁免
   - 支持 AI SDK 的 stream:true + Accept: application/json 场景

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-22 09:42:06 +08:00
token 7f129e91b6 vendor Certes 源码并移除 Newtonsoft.Json/BouncyCastle 以支持 AOT
将 fszlin/certes 3.0.4 源码内置到 src/Certes 独立类库项目,
FastGateway 由 PackageReference 改为 ProjectReference。

- 无任何外部包依赖,开启 IsAotCompatible/IsTrimmable
- Newtonsoft.Json → System.Text.Json + 源生成 CertesJsonContext,
  消除全部匿名对象,保留 JWK RFC 7638 属性顺序
- Portable.BouncyCastle → System.Security.Cryptography
  (ECDsa/RSA/CertificateRequest/X509Certificate2),
  FromPem 兼容读取旧 SEC1/PKCS1 账户密钥
- 证书链直接使用 ACME 返回的 issuers,移除本地 PKIX 构建与内嵌根证书
- resx 资源类改为常量类,移除过时的异常序列化

Certes 单独构建 0 警告 0 错误;NativeAOT publish 通过;
CertService.cs 无需改动。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 09:24:28 +08:00
token 169300d912 修正地理回填 UPDATE 参数名不匹配导致后台服务崩溃
Dapper 依匿名成员名生成 SQLite 命名参数,row.Id 推断为 @Id,
而 SQLite 参数区分大小写,SQL 中的 @id 无法绑定,后台服务启动即抛
InvalidOperationException 并停机。显式指定 id = row.Id 使成员名与占位符一致。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 03:03:54 +08:00
token 72ffa7aba9 统一地理统计中文化并回填国家维度数据
将 IP 地理解析扩展为国家、区域、省份字段,统一国家名为中文,并对最近保留周期内的请求日志及国家、省份聚合数据执行一次性回填。兼容历史英文国家名,合并重复维度并保留访问量与拦截量。

前端对世界地图和排行数据进行国家名称归一与同名聚合,避免历史英文数据导致国家重复显示;中国地图仍按省份维度展示。
2026-07-21 17:59:15 +08:00
token f9996ae3bc 修正 v4 地理库省份解析并回填历史省份统计
适配 ip2region_v4.xdb 的区域字段顺序,避免省份解析错位。统计服务启动时对最近保留周期内的中国请求日志回填省份,并在事务中重建省份维度聚合数据;通过元数据标记确保仅执行一次,地理库不可用时跳过回填。
2026-07-21 10:31:56 +08:00
token b232e8c29e feat(security): 添加拦截日志页面以支持安全审计 2026-07-21 01:09:15 +08:00
token 2b5ee9d64d Update package.json
修改
2026-07-21 00:50:11 +08:00
token 2bb4fc1252 feat(security): implement access control and threat detection features
- Refactor CreateBlacklistAndWhitelist component to enforce mandatory enabling of blacklist.
- Update RateLimitPage to improve UI and add warning for gateway rebuilds after changes.
- Remove redundant WhitelistPage and integrate its functionality into AccessControlPage.
- Create AccessControlPage for unified management of IP blacklists and whitelists.
- Add SecurityOverviewPage for a comprehensive security dashboard overview.
- Introduce SecurityFilterBar for consistent filtering across security-related pages.
- Develop ThreatDetectionPage to monitor and manage abnormal IPs with blacklist capabilities.
- Implement StatisticsService for fetching various statistical data related to security.
- Add TypeScript definitions for echarts-gl module.
2026-07-20 10:10:42 +08:00