Skip to content

topology_hiding: fix the Contact usernames of in-dialog requests - #4512

Open
Lt-Flash wants to merge 2 commits into
OpenSIPS:masterfrom
Lt-Flash:fix/th-dlg-contact-users
Open

Lt-Flash wants to merge 2 commits into
OpenSIPS:masterfrom
Lt-Flash:fix/th-dlg-contact-users

Conversation

@Lt-Flash

@Lt-Flash Lt-Flash commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With topology_hiding("U", "/caller/callee") in dialog mode, in-dialog requests carry the wrong Contact username in both directions. Fixes #4513.

Details

The caller username is the one shown to the caller, and the callee username is the one shown to the callee. The initial INVITE and its replies get this right. In-dialog requests take the usernames from a copy kept on the dialog, and that path has two bugs:

  1. th_params_dup() pointed the callee username at the start of the block, over the caller username, so the callee's bytes overwrote the caller's.
  2. topo_dlg_onroute() read the copy as a single str, so every in-dialog request used the caller username, whichever way it went.

With topology_hiding("U", "/alice/bobbylonger"), both a caller re-INVITE and a callee re-INVITE went out with sip:bobby@. The caller re-INVITE should carry bobbylonger and the callee re-INVITE alice.

Solution

  • th_params_dup(): the caller username now goes at the start of the block and the callee username right after it. A username that is not set is not copied.
  • topo_dlg_onroute(): the username is chosen by direction: the caller username upstream and the callee username downstream. This is how dlg_th_onreply() already does it for replies.

Dialogs restored from the database or a cluster peer use the same code, so they are fixed too.

Compatibility

In-dialog requests now carry the username the script asked for. Calls that don't pass any usernames are not affected.

Testing

Tested on master 98ee38b with a SIP test script against a dialog-mode proxy using the config above. The script sends INVITE, 200, ACK, then a re-INVITE from each side, and checks the Contact that each side receives:

initial INVITE 200 caller re-INVITE callee re-INVITE
master bobbylonger alice bobby bobby
first commit only bobbylonger alice alice alice
both commits bobbylonger alice bobbylonger alice

The module also builds clean with gcc and clang-19 -Werror.

@Lt-Flash Lt-Flash changed the title topology_hiding: keep both Contact usernames apart in the dialog copy topology_hiding: fix the Contact usernames of in-dialog requests Nov 27, 2026
th_params_dup() pointed the callee username at the start of the
block, over the caller one, so the caller's bytes were overwritten
by the callee's. topo_dlg_onroute() reads the caller username from
that copy, so in-dialog requests towards the callee carried the
callee username, cut to the caller's length: with
topology_hiding("U", "/alice/bobbylonger") a re-INVITE went out
with Contact sip:bobby@...

Lay the two out one after the other, and skip the copy of a username
that is not set.
@Lt-Flash
Lt-Flash force-pushed the fix/th-dlg-contact-users branch from f7b96c7 to 432eefb Compare December 1, 2026 09:51
topo_dlg_onroute() read the saved usernames as a single str, so every
in-dialog request used the caller username, the one meant for the
caller, whatever its direction. A caller re-INVITE showed the callee
the caller username, while the initial INVITE had shown it the callee
one.

Pick the username by direction, the way dlg_th_onreply() does for
replies: the caller username upstream, the callee one downstream.
@Lt-Flash
Lt-Flash force-pushed the fix/th-dlg-contact-users branch from 432eefb to 1b50d52 Compare December 1, 2026 18:07
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.

[BUG] topology_hiding: in-dialog requests carry the wrong Contact username

1 participant