1
0

feat: 新增 UDP checker,支持自定义 payload 请求-响应探测与断言

基于 Bun connected UDP socket 实现通用 UDP 拨测能力:
- 支持 text/hex/base64 payload 编码与独立 responseEncoding 响应视图
- 支持 responded、response、responseSize、sourceHost、sourcePort、maxDurationMs 专属 expect
- 单 datagram 发送,仅断言首个 UDP 响应 datagram
- 通过 maxResponseBytes 和 flags.truncated 进行响应大小限制与截断保护
- payload 可选,省略时发送空 datagram
- 自包含模块结构(types/schema/validate/expect/encoding/execute)
- 新增 741 tests(含 unit、execute 集成、expect 和编码 roundtrip),全部通过
This commit is contained in:
2026-05-18 17:23:17 +08:00
parent 550c427814
commit 52262a31f6
19 changed files with 2328 additions and 8 deletions

View File

@@ -187,3 +187,44 @@ targets:
maxAvgLatencyMs: 100
maxMaxLatencyMs: 300
maxDurationMs: 5000
# ========== UDP targets ==========
- id: "udp-heartbeat"
name: "UDP 心跳检测"
type: udp
group: "基础设施"
udp:
host: "127.0.0.1"
port: 9000
payload: "PING"
expect:
response:
- contains: "PONG"
maxDurationMs: 100
- id: "udp-binary-probe"
name: "UDP 二进制协议探测"
type: udp
group: "基础设施"
udp:
host: "127.0.0.1"
port: 5683
payload: "400100"
encoding: hex
responseEncoding: hex
expect:
responseSize:
gte: 4
maxDurationMs: 200
- id: "udp-fire-and-forget"
name: "UDP 发送验证(不等待响应)"
type: udp
group: "基础设施"
udp:
host: "127.0.0.1"
port: 514
payload: "<14>health check"
expect:
responded: false