From ee17b202ce75c1a0f888b0bf1e2c1f125fec5cc5 Mon Sep 17 00:00:00 2001 From: Milkmonkey Date: Wed, 2 Sep 2026 15:29:59 +0800 Subject: [PATCH] fix(vowifi): avoid outbound refresh for Supported-only --- .../internal/vowifi/imscore/register.go | 3 ++- .../vowifi/imscore/register_flow_trace.go | 3 +++ .../imscore/register_flow_trace_test.go | 25 +++++++++++++++++++ .../internal/vowifi/imscore/types.go | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/third_party/vowifi-go/internal/vowifi/imscore/register.go b/third_party/vowifi-go/internal/vowifi/imscore/register.go index 51710db7..ca8d6668 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/register.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/register.go @@ -127,6 +127,7 @@ func (s *Service) registerLocked(ctx context.Context) error { s.signalingFailureReason = err.Error() s.sipOutboundKeepalive = false s.sipOutbound = false + s.outboundBindingRequired = false s.outboundContactOffered = false s.outboundContactRegistered = false s.flowTimer = 0 @@ -726,7 +727,7 @@ func (s *Service) needsOutboundBindingRefresh() bool { } s.mu.RLock() defer s.mu.RUnlock() - return s.sipOutbound && !s.outboundContactRegistered + return s.sipOutbound && s.outboundBindingRequired && !s.outboundContactRegistered } func withOutboundContactParams(order []string) []string { diff --git a/third_party/vowifi-go/internal/vowifi/imscore/register_flow_trace.go b/third_party/vowifi-go/internal/vowifi/imscore/register_flow_trace.go index 6a8d56b9..ef47e0b6 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/register_flow_trace.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/register_flow_trace.go @@ -26,6 +26,9 @@ func (s *Service) logRegisterFlowNegotiation(response *sipResponse) { s.mu.Lock() s.sipOutboundKeepalive = requiredOutbound || viaKeep s.sipOutbound = supportedOutbound || requiredOutbound || pathOB || contactRegID + // Supported: outbound advertises a capability only. A follow-up REGISTER + // with reg-id/ob is required only when the network explicitly asks for it. + s.outboundBindingRequired = requiredOutbound || pathOB || contactRegID if s.outboundContactOffered { s.outboundContactRegistered = true } diff --git a/third_party/vowifi-go/internal/vowifi/imscore/register_flow_trace_test.go b/third_party/vowifi-go/internal/vowifi/imscore/register_flow_trace_test.go index 91a8d24c..dde7a7be 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/register_flow_trace_test.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/register_flow_trace_test.go @@ -24,3 +24,28 @@ func TestContainsSIPParameter(t *testing.T) { t.Fatal("partial Contact parameter was accepted") } } + +func TestSupportedOutboundDoesNotRequireBindingRefresh(t *testing.T) { + service := &Service{} + service.logRegisterFlowNegotiation(&sipResponse{ + StatusCode: 200, + Headers: map[string]string{"Supported": "path, sec-agree, outbound"}, + }) + if !service.sipOutbound { + t.Fatal("Supported: outbound capability was not recorded") + } + if service.needsOutboundBindingRefresh() { + t.Fatal("Supported: outbound alone must not trigger a follow-up REGISTER") + } +} + +func TestRequiredOutboundRequiresBindingRefresh(t *testing.T) { + service := &Service{} + service.logRegisterFlowNegotiation(&sipResponse{ + StatusCode: 200, + Headers: map[string]string{"Require": "outbound"}, + }) + if !service.needsOutboundBindingRefresh() { + t.Fatal("Require: outbound must trigger a follow-up REGISTER") + } +} diff --git a/third_party/vowifi-go/internal/vowifi/imscore/types.go b/third_party/vowifi-go/internal/vowifi/imscore/types.go index fb51f3b1..2be7b0bc 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/types.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/types.go @@ -212,6 +212,7 @@ type Service struct { tcpCRLFPongWait time.Duration sipOutboundKeepalive bool sipOutbound bool + outboundBindingRequired bool outboundContactOffered bool outboundContactRegistered bool flowTimer time.Duration