Skip to content

fix(dialog): keep a caller-built INVITE Contact on stream transports - #213

Merged
yeoleobun merged 1 commit into
restsend:mainfrom
mycollablab:fix/keep-caller-built-contact
Oct 24, 2026
Merged

yeoleobun merged 1 commit into
restsend:mainfrom
mycollablab:fix/keep-caller-built-contact

Conversation

@mycollablab

Copy link
Copy Markdown
Contributor

Fixes #209.

Problem

make_invite_request rewrites the Contact on stream transports: it replaces the host and port with the local address of the outgoing connection and switches the scheme to sips over TLS. It does this even when the caller passed a Contact built on purpose.

Behind NAT a UA usually wants to advertise the address the registrar reported (the Contact in the REGISTER 200 OK), so the rewrite produces an unreachable Contact. Over TLS it also pairs a sips: Contact with a sip: Request-URI, which some registrars reject with 400.

Change

A Contact that already carries a transport parameter is treated as built by the caller and sent unchanged. Contacts without one behave exactly as before, so existing callers are unaffected (the existing TCP, TLS and no-transport Contact tests pass unchanged).

The behavior is documented on InviteOption::contact.

Tests

  • New test_make_invite_request_keeps_caller_built_contact (TLS listener, caller-built sip:...;transport=tls Contact): fails before this change, passes after.
  • cargo test --lib: 482 passed.

Only the two files above changed; cargo fmt from a newer toolchain also reformatted unrelated files, and those changes were left out.

🤖 Generated with Claude Code

make_invite_request replaced the Contact host and port with the local
address of the outgoing stream connection, and switched the scheme to
sips over TLS, even when the caller had built the Contact deliberately.
Behind NAT the caller usually needs the address a registrar reported
(the Contact in the REGISTER 200 OK), so overwriting it sent an
unreachable Contact, and some registrars reject a sips Contact paired
with a sip Request-URI.

A Contact that already names its transport is now treated as
caller-built and sent unchanged. Contacts without a transport parameter
keep the existing behavior, so current callers are unaffected.

Refs restsend#209

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yeoleobun
yeoleobun merged commit 12ae955 into restsend:main Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make_invite_request overrides a caller-supplied Contact and forces sips: over TLS

2 participants