libresbc icon indicating copy to clipboard operation
libresbc copied to clipboard

[BUG] unable to change sip_to_user

Open badcrc opened this issue 1 year ago • 2 comments

I want to change the sip_to_user in the outbound leg, I've tried to make a Manipulation rule in the inbound leg (as I saw in the code how the manipulations are being applied) but I'm not able to do it.

I can change the sip_from_user but changing the sip_to_user results in a strange bug.

This works:

"actions": [
        {
            "action": "set",
            "refervar": null,
            "pattern": null,
            "targetvar": "sip_from_user",
            "values": [
                "34${sip_from_user}"
            ]
        }
    ],

and adds +34 to the sip_from_user (don't know why it adds the +, I do want it so... ).

But the same manipulation but for the sip_to_user:

 "actions": [
        {
            "action": "set",
            "refervar": null,
            "pattern": null,
            "targetvar": "sip_to_user",
            "values": [
                "34${sip_to_user}"
            ]
        }
    ],

Results in:

2024-12-05 14:24:53.099169 [DEBUG] switch_channel.c:1264 sofia/ZZZZZZZ/[email protected] EXPORTING[export_vars] [sip_invite_from_uri]=[<sip:343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434${sip_from_user}@ZZZZZZZ>] to event

And if the manipulation is just:

 "actions": [
        {
            "action": "set",
            "refervar": null,
            "pattern": null,
            "targetvar": "sip_to_user",
            "values": [
                "${sip_to_user}"
            ]
        }
    ],

nothing changes and To: <sip:${sip_to_user}@ is being literally sent to the gateway, not changing it value.

What I'm missing? Thanks!

badcrc avatar Dec 05 '24 14:12 badcrc

Hi @badcrc, Can you try "values":["+34", "sip_to_user" ] I'm not sure if FreeSWITCH allow to change sip_invite_to (if so try with sip_invite_to_uri).

hnimminh avatar Dec 05 '24 21:12 hnimminh

Hi,

I was finally able to do this.

When the outbound cid_type is set to something other than "none" it changes the variables:

            if cidtype~='none' then
                local sipadip = freeswitch.getGlobalVariable(_sipprofile..':advertising')
                if not sipadip then sipadip = freeswitch.getGlobalVariable('hostname') end
                local sip_from_display = InLeg:getVariable("sip_from_display")
                if sip_from_display then InLeg:execute("export", "nolocal:sip_from_display="..sip_from_display) end
                local sip_from_user = InLeg:getVariable("sip_from_user")
                if sip_from_user then InLeg:execute("export", "nolocal:sip_invite_from_uri=<sip:"..sip_from_user.."@"..sipadip..">") end
                local sip_to_user = InLeg:getVariable("sip_to_user")
                if sip_to_user then InLeg:execute("export", "nolocal:sip_invite_to_uri=<sip:"..sip_to_user.."@"..gwproxy..":"..gwport..";transport="..gwtransport..">") end
            end

(...)
manipulate(InLeg, NgVars)

if I change to "none" I can change the from and to users with the manipulation_classes but then I don't have the P-Asserted-Identity, needed on my project.

badcrc avatar Mar 12 '25 10:03 badcrc