Skip to content

Instantly share code, notes, and snippets.

@backslash7
Last active December 18, 2020 21:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save backslash7/50efc532ba5a664b14a4 to your computer and use it in GitHub Desktop.
Save backslash7/50efc532ba5a664b14a4 to your computer and use it in GitHub Desktop.
How to strip destination number from SIP To: header and use it as DID
; Assign this context to your incoming SIP trunk settings
[custom-get-did-from-sip]
exten => _X.,1,Noop(Fixing DID using information from SIP TO header)
exten => _X.,n,NOOP(Header is: ${SIP_HEADER(TO)})
exten => _X.,n,Set(pseudodid=${SIP_HEADER(TO)})
exten => _X.,n,Set(pseudodid=${CUT(pseudodid,@,1)})
exten => _X.,n,Set(pseudodid=${CUT(pseudodid,:,2)})
exten => _X.,n,Noop(Pseudo DID is: ${pseudodid})
exten => _X.,n,Goto(from-trunk,${pseudodid},1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment