cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
353
Views
0
Helpful
0
Replies

Replacing outbound TO, with domain RHS in LUA.

Timothy Nelson
Level 1
Level 1

I am trying to replace the RHS on all outbound messaging for the To header.  If there is any chance someone can assist, I would appreciate

 

--[[

Description:
Modify the Right Hand Side of the outbound SIP Invite

--]]

M = {}

trace.enable()

local top_level_domain = "domain.com"

local function modify_rhs_of_uri(msg, header, rhs)
local value = msg:getHeader(header)

if value and rhs
then
local replacePattern = string.format("<sip:%s@%s>", "%1", rhs)
value = value:gsub("<sip:(.*)@(.*)>", replacePattern)
msg:modifyHeader(header, value)
end
end

local function modify_rhs_of_uri_for_called_party(msg)
modify_rhs_of_uri(msg, "To", top_level_domain)
end

local function process_outbound_request(msg, isInvite)
modify_rhs_of_uri_for_called_party(msg)
end

M.outbound_INVITE = function(msg)
process_outbound_request(msg, true)
end

return M

 

 

0 Replies 0