I have it working
- In each of your outbound routes that you want Transnexus to throw the Identity header, add the following, order it at 30:
Action: set / clearipsti=1
Action: set / sip_h_Identity=${sip_i_identity}
Action: export / sip_h_Identity=${sip_i_identity}
- Bridge the call to the transnexus/clearIP trunk
- Create a new outbound route and make sure it is numbered before any other outbound route that is using TransNexus. Make it look like the attached.
NOTE: SOME ITEMS ARE DISABLED! No need to input those into your system.
- Insert the below lua script to /usr/share/freeswitch/scripts and set permissions: chown www-data:www-data /usr/share/freeswitch/scripts/redirect.lua
- Finally, in the sip profile that your TransNexus trunk is attached to (most likely “internal”) make sure manual-redirect is set to ”true”. Flush cache and restart the profile
If you experience any issues at this point you may have to adjust a couple of parameters in the clearIP portal. For example, the SBC needs to be set a certain way, and then you need to create a domestic outbound route with the appropriate SBC selected.
Code:
--include config.lua
require "resources.functions.config";
--add the function
require "resources.functions.explode";
require "resources.functions.trim";
require "resources.functions.channel_utils";
--prepare the api object
api = freeswitch.API();
-- The flag parameter identifying destination support STIR/SHAKEN
local shakenString = ";shaken"
-- The option to insert Identity header per destination
local branchString = "[sip_h_Identity=${identity}]"
--local branchString = "[sip_h_X-Identity=${identity}]"
-- If no Identity header in INVITE, use SIP 3xx X-Identity header
if not session:getVariable("identity") then
session:setVariable("identity", session:getVariable("sip_rh_X-Identity"))
end
-- Extract destination dial string from SIP 3xx
local inDialString = session:getVariable("sip_redirect_dialstring")
-- Insert Identity header into SIP INVITE to destinations supporting SHAKEN
local outDialString = ""
-- For each destination
for part in string.gmatch(inDialString , "([^|]+)") do
if string.match(part, shakenString) then
-- If destination supports SHAKEN, insert Identity header
outDialString = outDialString .. branchString .. string.gsub(part, shakenString, "") .. "|"
else
-- If destination does not support SHAKEN, do nothing
outDialString = outDialString .. part .. "|"
end
end
-- Erase trailing pipe char
session:setVariable("redirect_dialstring", string.sub(outDialString, 1, -2))