Phase 5:Dialog + RegistrationClient + OptionsProbe + Digest 鉴权 - #10
Draft
lixuanqun wants to merge 1 commit into
Draft
Phase 5:Dialog + RegistrationClient + OptionsProbe + Digest 鉴权#10lixuanqun wants to merge 1 commit into
lixuanqun wants to merge 1 commit into
Conversation
sip-dialog 模块 - DialogId:(callId, localTag, remoteTag) — RFC 3261 §12.1.1 - DialogState:EARLY / CONFIRMED / TERMINATED - Dialog · fromUacResponse:UAC 视角,UAC route set = reverse(Record-Route) · fromUasRequest:UAS 视角,UAS route set = Record-Route 原序 · remoteTarget 自动从 Contact 解析 · nextLocalCSeq 单调递增 · onResponse 把 EARLY 升级为 CONFIRMED · refreshRemoteTarget 实现 RFC §12.2.1.2 target refresh - DialogTest(5 个):UAC/UAS 构造、route set 顺序、early→confirmed、CSeq 单调 sip-ua 模块 - SipStackInfo + Branch(RFC §8.1.1.7 magic cookie + 96-bit 随机熵) - auth/DigestChallenge:解析 WWW-Authenticate / Proxy-Authenticate · 支持 RFC 7616 SHA-256 / SHA-512-256 与 RFC 2617 MD5 · realm / nonce 必需;opaque / qop / stale / algorithm 可选 · 自实现 quoted-string + escape 解析 - auth/DigestResponse:构造 Authorization header · HA1 / HA2 / response 按 RFC 7616 §3.4 计算 · qop=auth 时附 cnonce/nc;无 qop 走 legacy · 算法映射 MD5/SHA-256/SHA-512-256 - RegistrationClient · 构造 REGISTER(含 Via 带 rport、Contact、Expires、User-Agent) · 走 NonInviteClientTransaction · 收到 401/407 自动用 Digest 凭据重发(一次性,不重试第二次) · 自动选 WWW-Authenticate vs Proxy-Authenticate 对应的 Authorization header - OptionsProbe:OPTIONS 检测可用性,CompletableFuture<SipResponse> 返回 测试(12 个) - DigestChallengeTest:6 个(basic、MD5 legacy、opaque/stale、非 Digest 拒、缺 realm/nonce 拒) - DigestResponseTest:4 个(RFC 7616 例验证、SHA-256 哈希长度、无 qop 路径、MD5 哈希正确性) - RegistrationClientTest:2 个(请求字段、自定义 Expires 值) mvn verify:9 模块 SUCCESS,全 158 tests 通过。 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.
概述
把"事务上面那一层"补完:Dialog(RFC 3261 §12)、Digest 鉴权(RFC 7616 + 兼容 MD5 legacy)、REGISTER 客户端(RFC 3261 §10)、OPTIONS probe(§11)。
sip-dialog
DialogId:(callId, localTag, remoteTag),三元组身份DialogState:EARLY / CONFIRMED / TERMINATEDDialog:fromUacResponse(request, response)— UAC 视角;route set = reverse(Record-Route)fromUasRequest(request, response)— UAS 视角;route set = Record-Route 原序nextLocalCSeq()单调递增供 in-dialog request 使用onResponse把 EARLY → CONFIRMEDrefreshRemoteTarget实现 §12.2.1.2 target refreshsip-ua
鉴权(
com.sip.ua.auth)DigestChallenge.parse(headerValue)— 解析 WWW-Authenticate / Proxy-AuthenticateDigestCredentials— username + passwordDigestResponse.authorizationHeader(method, uri, nc, challenge, credentials)REGISTER + OPTIONS
Branch.newBranch()— RFC §8.1.1.7 magic cookie + 96-bit 随机熵RegistrationClientNonInviteClientTransaction(无锁、非阻塞)OptionsProbe— 同样架构,用于检测对端可用性测试
12 个新测试:
DialogTest— 5DigestChallengeTest— 6(含 GB28181 风格的 MD5 legacy 挑战)DigestResponseTest— 4(RFC 7616 example、SHA-256 哈希长度、无 qop 路径、MD5 算式验证)RegistrationClientTest— 2(请求字段、自定义 Expires)验证