Merge pull request #8 from Milkmonkey/fix/vowifi-outbound-supported

fix(vowifi): only refresh outbound bindings when required
This commit is contained in:
yibaiba authored and GitHub committed 2026-09-02 17:58:29 +08:00
commit 09f77f4703
4 files changed
+31 -1

No files matched your search

+2 -1
View File
@@ -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 {
@@ -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
}
@@ -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")
}
}
@@ -212,6 +212,7 @@ type Service struct {
tcpCRLFPongWait time.Duration
sipOutboundKeepalive bool
sipOutbound bool
outboundBindingRequired bool
outboundContactOffered bool
outboundContactRegistered bool
flowTimer time.Duration