Skip to content

Commit 870a197

Browse files
authored
Merge pull request #2742 from RestComm/issue_2741
Support for SBC in front of Restcomm Pull Request Review
2 parents 468762c + 283e143 commit 870a197

16 files changed

Lines changed: 2445 additions & 61 deletions

File tree

restcomm/configuration/config-scripts/as7-config-scripts/restcomm/advanced.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,8 @@ CACHE_NO_WAV=false
152152

153153
#MSS Configuration
154154
TLS_CLIENT_AUTH_TYPE="Disabled" #Possible values Enabled, Want, Disabled,DisabledAll
155+
156+
#USESBC: Option to disable all patch for NAT (Includes patch-for-nat-b2bua-sessions,disable-sdp-patching-on-updating-mediasession)
157+
RCUSESBC=false
158+
#Domain to be used in the SIP URI <user>@<domain>. If not defined, it will default to the webapp host name.
159+
WebOlympusDomain=""

restcomm/configuration/config-scripts/as7-config-scripts/restcomm/autoconfig.d/config-olympus.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,16 @@ FILE=$BASEDIR/standalone/deployments/olympus.war/resources/xml/olympus.xml
3838
}
3939

4040

41+
DomainConf(){
42+
#Configure Web Olympus Domain.
43+
FILE=$BASEDIR/standalone/deployments/olympus.war/resources/xml/olympus.xml
44+
echo "WebOlympusDomain: $WebOlympusDomain"
45+
xmlstarlet ed -L -P -u "/olympus/server/address" -v ${WebOlympusDomain} $FILE
46+
}
4147

4248

4349
# MAIN
4450
echo 'Configuring Olympus...'
4551
#Reload Variables
4652
olympusPortConf
53+
DomainConf

restcomm/configuration/config-scripts/as7-config-scripts/restcomm/autoconfig.d/config-restcomm.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,10 @@ otherRestCommConf(){
687687
echo "CACHE_NO_WAV $CACHE_NO_WAV"
688688
sed -i "s|<cache-no-wav>.*</cache-no-wav>|<cache-no-wav>${CACHE_NO_WAV}</cache-no-wav>|" $FILE
689689

690+
#Configure USESBC
691+
echo "USESBC: $RCUSESBC"
692+
sed -i "s|<use-sbc>.*</use-sbc>|<use-sbc>${RCUSESBC}</use-sbc>|" $FILE
693+
690694
echo "End Rest RestComm configuration"
691695
}
692696

restcomm/restcomm.application/src/main/webapp/WEB-INF/conf/restcomm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@
173173
If set to false RestComm will use the Request URI to determine the destination. -->
174174
<use-to>true</use-to>
175175

176+
<!-- if this flag is set to true, it will disable all patching done for NAT
177+
even if they are enabled in the configuration file-->
178+
<use-sbc>false</use-sbc>
179+
176180
<!-- If set to true Restcomm will use the Local Address (or external address
177181
if available) in the host part of the From header for calls to the outbound
178182
proxy. Default is False, which means that Restcomm will use outbound proxy

restcomm/restcomm.dao/src/test/java/org/restcomm/connect/dao/mybatis/ExtensionConfigurationDaoTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.joda.time.DateTime;
77
import org.junit.After;
88
import org.junit.Before;
9+
import org.junit.Ignore;
910
import org.junit.Test;
1011
import org.junit.experimental.categories.Category;
1112
import org.restcomm.connect.commons.annotations.UnstableTests;
@@ -28,6 +29,7 @@
2829
* Created by gvagenas on 21/10/2016.
2930
*/
3031
@Category(UnstableTests.class)
32+
@Ignore
3133
public class ExtensionConfigurationDaoTest {
3234
private static MybatisDaoManager manager;
3335
private MybatisExtensionsConfigurationDao extensionsConfigurationDao;

restcomm/restcomm.extension.controller/src/test/java/org.restcomm.connect.extension.controller/ExtensionsControllerTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919

2020
package org.restcomm.connect.extension.controller;
2121

22+
import java.util.List;
23+
24+
import javax.servlet.ServletContext;
25+
2226
import org.apache.log4j.Logger;
27+
import org.junit.After;
2328
import org.junit.Assert;
24-
import org.junit.Ignore;
2529
import org.junit.Test;
26-
import org.junit.experimental.categories.Category;
27-
import org.restcomm.connect.commons.annotations.UnstableTests;
2830
import org.restcomm.connect.commons.dao.Sid;
2931
import org.restcomm.connect.extension.api.ApiRequest;
3032
import org.restcomm.connect.extension.api.ExtensionRequest;
@@ -34,10 +36,6 @@
3436
import org.restcomm.connect.extension.api.RestcommExtension;
3537
import org.restcomm.connect.extension.api.RestcommExtensionGeneric;
3638

37-
import javax.servlet.ServletContext;
38-
import java.util.List;
39-
import org.junit.After;
40-
4139
public class ExtensionsControllerTest {
4240

4341
private static Logger logger = Logger.getLogger(ExtensionsControllerTest.class);

restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/VoiceInterpreter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,6 +2896,10 @@ public void execute(final Object message) throws Exception {
28962896
return;
28972897
} else {
28982898
if (callState == CallStateChanged.State.IN_PROGRESS) {
2899+
if (logger.isInfoEnabled()) {
2900+
String msg = String.format("At finishDialingState, will ASK call to hangup. Current VI State %s Call State: %s ",state, callState);
2901+
logger.info(msg);
2902+
}
28992903
call.tell(new Hangup(), self());
29002904
} else {
29012905
if (logger.isInfoEnabled()) {

restcomm/restcomm.sms/src/main/java/org/restcomm/connect/sms/SmsService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ public SmsService(final Configuration configuration, final SipFactory factory,
151151
// final Configuration runtime = configuration.subset("runtime-settings");
152152
// TODO this.useTo = runtime.getBoolean("use-to");
153153
patchForNatB2BUASessions = runtime.getBoolean("patch-for-nat-b2bua-sessions", true);
154+
boolean useSbc = runtime.getBoolean("use-sbc", false);
155+
if(useSbc) {
156+
if (logger.isDebugEnabled()) {
157+
logger.debug("SmsService: use-sbc is true, overriding patch-for-nat-b2bua-sessions to false");
158+
}
159+
patchForNatB2BUASessions = false;
160+
}
154161

155162
extensions = ExtensionController.getInstance().getExtensions(ExtensionType.SmsService);
156163
if (logger.isInfoEnabled()) {

restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,37 @@ public static boolean redirectToB2BUA(final ActorSystem system, final SipServlet
120120
final String aor = registration.getAddressOfRecord();
121121
SipURI to;
122122
SipURI from;
123-
to = (SipURI) sipFactory.createURI(location);
123+
SipURI locationURI = null;
124+
124125
Sid fromOrganizationSid = OrganizationUtil.getOrganizationSidBySipURIHost(storage, (SipURI) request.getFrom().getURI());
125126
// if both clients don't belong to same organization, call should not be allowed.
126127
if(!toOrganizationSid.equals(fromOrganizationSid)){
127128
logger.warn(String.format("B2B clients do not belong to same organization. from-client: %s belong to %s . where as to-client %s belong to %s", client.getLogin(), fromOrganizationSid, user, toOrganizationSid));
128129
return false;
129130
}
130-
from = (SipURI) sipFactory.createURI((registrations.getRegistration(client.getLogin(), fromOrganizationSid)).getLocation());
131+
if(patchForNat) {
132+
to = (SipURI) sipFactory.createURI(location);
133+
from = (SipURI) sipFactory.createURI((registrations.getRegistration(client.getLogin(), fromOrganizationSid)).getLocation());
134+
} else {
135+
// https://github.com/RestComm/Restcomm-Connect/issues/2741 support for SBC
136+
if (logger.isDebugEnabled()) {
137+
logger.debug("B2BUA not patched for NAT, using address of record for to and from");
138+
}
139+
to = (SipURI) sipFactory.createURI(aor);
140+
locationURI = (SipURI) sipFactory.createURI(location);
141+
from = (SipURI) sipFactory.createURI((registrations.getRegistration(client.getLogin(), fromOrganizationSid)).getAddressOfRecord());
142+
}
143+
131144
final SipSession incomingSession = request.getSession();
132145
// create and send the outgoing invite and do the session linking
133146
incomingSession.setAttribute(B2BUA_LAST_REQUEST, request);
134147
SipServletRequest outRequest = sipFactory.createRequest(request.getApplicationSession(), request.getMethod(),
135148
from, to);
136-
outRequest.setRequestURI(to);
149+
if(patchForNat) {
150+
outRequest.setRequestURI(to);
151+
} else {
152+
outRequest.setRequestURI(locationURI);
153+
}
137154

138155
if (request.getContent() != null) {
139156
final byte[] sdp = request.getRawContent();

restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/Call.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ public final class Call extends RestcommUntypedActor implements TransitionEndLis
254254
private Configuration runtimeSettings;
255255
private Configuration configuration;
256256
private boolean disableSdpPatchingOnUpdatingMediaSession;
257+
private boolean useSbc;
257258

258259
private Sid inboundCallSid;
259260
private boolean inboundConfirmCall;
@@ -435,6 +436,14 @@ public Call(final Sid accountSid, final SipFactory factory, final MediaServerCon
435436
this.configuration = configuration;
436437
final Configuration runtime = this.configuration.subset("runtime-settings");
437438
this.disableSdpPatchingOnUpdatingMediaSession = runtime.getBoolean("disable-sdp-patching-on-updating-mediasession", false);
439+
this.useSbc = runtime.getBoolean("use-sbc", false);
440+
if(useSbc) {
441+
if (logger.isDebugEnabled()) {
442+
logger.debug("Call: use-sbc is true, disable-sdp-patching-on-updating-mediasession to true");
443+
}
444+
disableSdpPatchingOnUpdatingMediaSession = true;
445+
}
446+
438447
this.enable200OkDelay = runtime.getBoolean("enable-200-ok-delay",false);
439448
if(!runtime.subset("ims-authentication").isEmpty()){
440449
final Configuration imsAuthentication = runtime.subset("ims-authentication");
@@ -1001,7 +1010,9 @@ public void execute(Object message) throws Exception {
10011010
} else {
10021011
invite = ((SipFactoryExt)factory).createRequestWithCallID(application, "INVITE", from, to, callId);
10031012
}
1004-
invite.pushRoute(uri);
1013+
if(!useSbc) {
1014+
invite.pushRoute(uri);
1015+
}
10051016

10061017
if(userAgent!=null){
10071018
invite.setHeader("User-Agent", userAgent);
@@ -2185,6 +2196,8 @@ private void onSipServletResponse(SipServletResponse message, ActorRef self, Act
21852196
uri.setLrParam(true);
21862197
challengeRequest.pushRoute(uri);
21872198
}
2199+
//FIXME:should check for the Ims pushed Route?
2200+
B2BUAHelper.addHeadersToMessage(challengeRequest, extensionHeaders, factory);
21882201
challengeRequest.send();
21892202
}
21902203
break;

0 commit comments

Comments
 (0)