Phase 8:NioTlsTransport + NioWebSocketTransport(TLS + WS 完整实装) - #14
Draft
lixuanqun wants to merge 2 commits into
Draft
Phase 8:NioTlsTransport + NioWebSocketTransport(TLS + WS 完整实装)#14lixuanqun wants to merge 2 commits into
lixuanqun wants to merge 2 commits into
Conversation
… 5922) 实装 - 复用 TCP transport 的 framing 与连接复用模式 - 通过 SSLContext 注入证书 / 信任锚 / mTLS 配置(应用层完全控制) - 出站连接启用 HTTPS-style endpoint identification(RFC 5922 SIPS 要求) - TLSv1.3 默认,对端可降级到 TLSv1.2(由 SSLContext 协议版本配置) 测试 - 预生成 PKCS12 keystore via keytool(CN=localhost + SAN dns/ip) - TestSslContext:server/client SSLContext 工厂(trust-all 用于测试, 生产严禁;在 KDoc 中明确说明) - NioTlsTransportTest(2 个): · clientCanSendInviteToServerOverTls — INVITE + SDP body 帧定通过 · serverCanReplyOverSameTlsConnection — 双向 200 OK 走同一 TLS 连接 .gitattributes:*.p12/*.jks 标记 binary。 mvn verify:transport-nio 模块 9 集成测试(3 UDP + 4 TCP + 2 TLS)全绿。 Co-authored-by: li xuanqun <793005378@qq.com>
…455) 帧编解码(WebSocketFrame) - 完整 RFC 6455 §5.2 帧格式:FIN/RSV/opcode/mask/len-short/len-extended - read:自动 mask 反演;reject 超过 4MB payload - write:客户端帧自动加 32-bit random mask;服务端帧不掩码 握手(WebSocketHandshake) - 服务端:解析 GET 请求、校验 Sec-WebSocket-Key/Version、 生成 Sec-WebSocket-Accept = base64(SHA1(key+GUID)) - 客户端:发起请求带 Sec-WebSocket-Protocol: sip(RFC 7118), 校验 101 响应的 Accept 与本地计算一致 - 失败时给出 HTTP 错误响应(400 / 426) NioWebSocketTransport - 复用 TCP transport 的连接复用模式 - 每个 SIP 消息 = 一个 TEXT 帧(RFC 7118 §4.1)→ 不需要 Content-Length framing - 角色区分:server(accept loop)/ client(pure dial) - PING 自动 PONG 回响、CLOSE 双向 echo - send 串行化用 ReentrantLock 测试(NioWebSocketTransportTest,3 个) - clientCanSendSipOverWebSocket - multipleMessagesPerConnectionReuseHandshake — 一个 WS 连接复用 3 次 - serverCanReplyOnSameWebSocket — 双向通信 mvn verify:transport-nio 12 集成测试(3 UDP + 4 TCP + 2 TLS + 3 WS)全绿。 Co-authored-by: li xuanqun <793005378@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
完整 Transport 矩阵收尾:在已有 UDP / TCP 之上加 TLS(RFC 3261 §26.2) 和 WebSocket(RFC 7118)。
NioTlsTransport
SSLContext注入:证书 / 信任锚 / mTLS 配置完全应用层掌控TLS 测试基建
keytool(CN=localhost + SANs),入库src/test/resources/test-keystore.p12.gitattributes标记*.p12 / *.jks binaryTestSslContext工厂:server / client SSLContext(trust-all 仅测试用)NioWebSocketTransport (RFC 7118 + RFC 6455)
WebSocketFrameWebSocketHandshakeSec-WebSocket-Accept = base64(SHA1(key+GUID))Sec-WebSocket-Protocol: sip(RFC 7118)NioWebSocketTransport测试
transport-nio模块从 7 个增到 12 个集成测试:每个 transport 至少覆盖:客户端→服务端发送、服务端回响、连接复用。
验证
现在所有 RFC 3261 §18 + RFC 7118 传输方案都齐了