Experimental SIP trunking support #3501
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds experimental SIP trunking support to the SIP plugin. It's an effort that I presented at Kamailio World a few months ago:
You can find more information in the presentation, but in a nutshell, it allows you to create a shared stack in the SIP plugin that can establish an IP-based trunk with a SIP proxy. Notice that, at the moment, it doesn't support any form of authentication or encryption: it's just an IP-based pair trunk. My hope is that, by having people test it, more requirements will emerge to improve it and make it more usable.
To create a trunk, you need to do it in the
janus.plugin.sip.jcfg
configuration file. The PR comes with verbose comments on how to fill that in, but an example is the following:In this case, the SIP plugin will bind to port 5090 for its own side of the trunk, and establish a pair with the provided address in the
peer
property. As I said, nothing happens when you do that, except that we create a Sofia SIP stack bound at that address, and that we'll only accept incoming messages from the peer address: messages coming from other addresses are all rejected with a 403. The peer address is also configured automatically as outbound proxy, so that all messages we'll send ourselves will go there.In order to allow users of the plugin to use the trunk, they need to set
type: "trunk"
when using theregister
method in the SIP plugin API. This works pretty much as theguest
mode does, meaning that no SIP register will actually be sent: unlikeguest
mode, though, thetrunk
mode will allow those users to receive incoming calls even if no registration was sent, since the plugin will intercept incoming INVITE messages from the trunk peer. The way the code works right now, we check the username part of the URI they set in theregister
request: if an incoming INVITE from the trunk peer matches that, we pass the call to that user.This is it in a nutshell. I've marked the PR as a draft since it's not really complete (is no authentication on the trunk ok, or do we need one? what about matching rules for incoming calls?), and most importantly I've done very little testing with it. If you're interested in this functionality, please test and do provide feedback, so that we can get it to a mergeable status soon.
PS: in the future, I also plan to make the management of trunks more dynamic. At the moment, you can only create one, and only at startup (config file). It may be interesting to have ways to dynamically create more than one using the SIP plugin API. Besides, we probably need ways to locally "authenticate" users of a trunk (locally as in the SIP plugin, and not via SIP), and ways to send push events to external backends when we get incoming calls for addresses that we don't have a user for yet (which would allow for dynamically adding a SIP plugin trunk user only when we get a call for a specific address).