diff --git a/third_party/vowifi-go/internal/vowifi/imscore/register.go b/third_party/vowifi-go/internal/vowifi/imscore/register.go index 51710db7..02acb721 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/register.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/register.go @@ -113,7 +113,13 @@ func (s *Service) registerLocked(ctx context.Context) error { if err == nil && s.needsOutboundBindingRefresh() { logging.Info("IMS REGISTER completing outbound flow", "device", s.DeviceID()) if again, againErr := s.runRegisterFlow(ctx); againErr != nil { - err = againErr + if s.outboundBindingRequired() { + err = againErr + } else { + logging.WarnRate("ims-outbound-refresh-"+s.DeviceID(), 30*time.Second, + "IMS outbound binding refresh failed; keep current registration", + "device", s.DeviceID(), "err", againErr) + } } else { expires = again } @@ -127,6 +133,7 @@ func (s *Service) registerLocked(ctx context.Context) error { s.signalingFailureReason = err.Error() s.sipOutboundKeepalive = false s.sipOutbound = false + s.sipOutboundRequired = false s.outboundContactOffered = false s.outboundContactRegistered = false s.flowTimer = 0 @@ -729,6 +736,15 @@ func (s *Service) needsOutboundBindingRefresh() bool { return s.sipOutbound && !s.outboundContactRegistered } +func (s *Service) outboundBindingRequired() bool { + if s == nil { + return false + } + s.mu.RLock() + defer s.mu.RUnlock() + return s.sipOutboundRequired +} + func withOutboundContactParams(order []string) []string { result := append([]string(nil), order...) if !containsContactParamName(result, "sip_instance") { 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 3f28a349..236e8dca 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 @@ -25,7 +25,12 @@ func (s *Service) logRegisterFlowNegotiation(response *sipResponse) { contactRegID := containsSIPParameter(contact, "reg-id") s.mu.Lock() s.sipOutboundKeepalive = requiredOutbound || viaKeep - s.sipOutbound = supportedOutbound || requiredOutbound || pathOB || contactRegID + // RFC 5626: Supported: outbound only means the registrar understands + // outbound. A follow-up REGISTER with reg-id is for an actual flow + // (Require, Path;ob, or an echoed reg-id). 2degrees advertises + // Supported and 503s the extra REGISTER (hideck#6). + s.sipOutboundRequired = requiredOutbound + s.sipOutbound = requiredOutbound || pathOB || contactRegID if s.outboundContactOffered { s.outboundContactRegistered = true } diff --git a/third_party/vowifi-go/internal/vowifi/imscore/register_restore_test.go b/third_party/vowifi-go/internal/vowifi/imscore/register_restore_test.go index 5806a6a9..90db97b2 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/register_restore_test.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/register_restore_test.go @@ -450,6 +450,43 @@ func TestInitialRegisterOmitsOutboundContactWithoutSupportedOutbound(t *testing. } } +func TestSupportedOutboundDoesNotRequireFollowUpRegister(t *testing.T) { + service := &Service{cfg: &IMSConfig{ + IMPI: "user@ims.example", IMPU: "sip:user@ims.example", Domain: "ims.example", + LocalIP: net.ParseIP("192.0.2.10"), LocalPort: 5060, Transport: "udp", + }} + service.logRegisterFlowNegotiation(&sipResponse{ + StatusCode: 200, + Headers: map[string]string{ + "Supported": "path, outbound", + "Path": "", + }, + }) + if service.needsOutboundBindingRefresh() { + t.Fatal("Supported: outbound without Path;ob or Require must not send a follow-up REGISTER") + } + if service.outboundBindingRequired() { + t.Fatal("Supported: outbound is not Require: outbound") + } +} + +func TestRequireOutboundRequiresFollowUpRegister(t *testing.T) { + service := &Service{cfg: &IMSConfig{ + IMPI: "user@ims.example", IMPU: "sip:user@ims.example", Domain: "ims.example", + LocalIP: net.ParseIP("192.0.2.10"), LocalPort: 5060, Transport: "udp", + }} + service.logRegisterFlowNegotiation(&sipResponse{ + StatusCode: 200, + Headers: map[string]string{"Require": "outbound"}, + }) + if !service.needsOutboundBindingRefresh() { + t.Fatal("Require: outbound must trigger a follow-up REGISTER with reg-id") + } + if !service.outboundBindingRequired() { + t.Fatal("Require: outbound must fail registration if the follow-up REGISTER fails") + } +} + func TestPathOBRequiresFollowUpRegisterWithRegID(t *testing.T) { service := &Service{cfg: &IMSConfig{ IMPI: "user@ims.example", IMPU: "sip:user@ims.example", Domain: "ims.example", diff --git a/third_party/vowifi-go/internal/vowifi/imscore/types.go b/third_party/vowifi-go/internal/vowifi/imscore/types.go index 151a0fc7..38ccdd51 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/types.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/types.go @@ -215,6 +215,7 @@ type Service struct { tcpCRLFPongWait time.Duration sipOutboundKeepalive bool sipOutbound bool + sipOutboundRequired bool outboundContactOffered bool outboundContactRegistered bool flowTimer time.Duration