Skip to content

Commit

Permalink
issue #142
Browse files Browse the repository at this point in the history
  • Loading branch information
ocarriles committed May 4, 2019
1 parent 9d6c643 commit df1bc99
Show file tree
Hide file tree
Showing 109 changed files with 3,615 additions and 666 deletions.
19 changes: 18 additions & 1 deletion application/src/main/java/org/restcomm/sbc/Bootstrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.apache.log4j.Logger;
import org.restcomm.sbc.dao.DaoManager;
import org.restcomm.sbc.identity.IdentityContext;
import org.restcomm.chain.processor.spi.impl.ProcessorFactory;
import org.restcomm.chain.processor.spi.impl.ProcessorLoadException;
import org.restcomm.sbc.bo.shiro.ShiroResources;
import org.restcomm.sbc.call.CallManager;
import org.restcomm.sbc.configuration.RestcommConfiguration;
Expand Down Expand Up @@ -123,9 +125,24 @@ public void init(final ServletConfig config) throws ServletException {
LOG.info("CallManager created and stored in the context");
}
}

//Initialize ProcessorFactory
ProcessorFactory processorFactory = null;
try {
processorFactory = ProcessorFactory.getInstance(home(config)+"/WEB-INF/");
} catch (ProcessorLoadException e) {
LOG.error("Cannot create processorFactory!");
}
if (processorFactory != null) {
context.setAttribute(ProcessorFactory.class.getName(), processorFactory);
if (LOG.isInfoEnabled()) {
LOG.info("ProcessorFactory created and stored in the context");
}
}

ShiroResources.getInstance().set(CallManager.class, callManager);

ShiroResources.getInstance().set(ProcessorFactory.class, processorFactory);

Version.printVersion();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public void init(final ServletConfig servletConfig) throws ServletException {

Monitor monitor=Monitor.getMonitor();
monitor.start(sipFactory, configuration);




}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public String getProtocol() {
@Override
protected String adaptSdp(MediaController mediaController, String host) throws SdpException {

String sdpContent = mediaController.getAVPProxySdp(host);
String sdpContent;
if(mediaController.isSecure()) {
sdpContent = mediaController.getSAVPProxySdp(host);
}
sdpContent= mediaController.getAVPProxySdp(host);

return sdpContent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import javax.servlet.sip.Address;
import javax.servlet.sip.B2buaHelper;
import javax.servlet.sip.SipApplicationSession;
import javax.servlet.sip.SipFactory;
import javax.servlet.sip.SipServletMessage;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipServletResponse;
Expand Down Expand Up @@ -69,14 +68,15 @@ public class B2BUABuilderProcessor extends DefaultProcessor implements Processor
private LocationManager locationManager;
private SipApplicationSession aSession;


public B2BUABuilderProcessor() {
// just to notify spi instantiation
super();
this.type = Type.SINGLE_PROCESSOR;
}
public B2BUABuilderProcessor(ProcessorChain chain) {
super(chain);
this.chain = chain;
locationManager = LocationManager.getLocationManager();



locationManager = LocationManager.getLocationManager();
}

public B2BUABuilderProcessor(String name, ProcessorChain chain) {
Expand Down Expand Up @@ -534,8 +534,8 @@ public void doProcess(Message message) throws ProcessorParsingException {
}

@Override
public String getVersion() {
return "1.0.0";
public double getVersion() {
return 1.0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
*/
public class DispatchDPIProcessor extends DefaultDPIProcessor implements ProcessorCallBack {

private String name="Dispatch DPI Processor";
private static transient Logger LOG = Logger.getLogger(DispatchDPIProcessor.class);

public DispatchDPIProcessor(ProcessorChain processorChain) {
Expand All @@ -54,13 +53,15 @@ public DispatchDPIProcessor(String name, ProcessorChain processorChain) {
}

public String getName() {
return name;
return "Dispatch DPI Processor";
}

public int getId() {
return this.hashCode();
}



public SipServletMessage doProcess(SIPMutableMessage message) throws ProcessorParsingException {
SipServletMessage m=(SipServletMessage) message.getContent();
SipServletResponse r=null;
Expand Down Expand Up @@ -112,8 +113,8 @@ public void doProcess(Message message) throws ProcessorParsingException {
}

@Override
public String getVersion() {
return "1.0.0";
public double getVersion() {
return 1.0;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*******************************************************************************
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2016, Telestax Inc, Eolos IT Corp and individual contributors
* by the @authors tag.
*
* This program is free software: you can redistribute it and/or modify
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*******************************************************************************/

package org.restcomm.sbc.chain.impl;



import javax.servlet.sip.SipServletMessage;


import org.apache.log4j.Logger;
import org.restcomm.chain.ProcessorChain;
import org.restcomm.chain.processor.Message;
import org.restcomm.chain.processor.ProcessorCallBack;
import org.restcomm.chain.processor.impl.DefaultDPIProcessor;
import org.restcomm.chain.processor.impl.ProcessorParsingException;
import org.restcomm.chain.processor.impl.SIPMutableMessage;



/**
* @author [email protected] (Oscar Andres Carriles)
* @date 3/5/2019 14:33:56
* @class GeoACLDPIProcessor.java
*
*/
public class GeoACLDPIProcessor extends DefaultDPIProcessor implements ProcessorCallBack {

private String name="Geo IP ACL Processor";
private static transient Logger LOG = Logger.getLogger(GeoACLDPIProcessor.class);


public GeoACLDPIProcessor(ProcessorChain processorChain) {
super(processorChain);
}

public GeoACLDPIProcessor(String name, ProcessorChain processorChain) {
super(name, processorChain);
}

public String getName() {
return name;
}

public int getId() {
return this.hashCode();
}

public SipServletMessage doProcess(SIPMutableMessage message) throws ProcessorParsingException {
if(LOG.isTraceEnabled()){
LOG.trace(">> doProcess()");
}
SipServletMessage m=(SipServletMessage) message.getContent();


return m;
}

@Override
public void setName(String name) {
this.name=name;

}

@Override
public ProcessorCallBack getCallback() {
return this;
}

@Override
public void doProcess(Message message) throws ProcessorParsingException {
doProcess((SIPMutableMessage)message);
}

@Override
public double getVersion() {
return 1.0;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import java.io.IOException;



import javax.servlet.sip.SipServletMessage;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipServletResponse;
Expand All @@ -45,6 +47,8 @@
import org.restcomm.sbc.managers.ProtocolAdapterFactory;
import org.restcomm.sbc.managers.RouteManager;
import org.restcomm.sbc.media.MediaController.StreamProfile;
import org.restcomm.sbc.media.helpers.ExtendedSessionDescription;
import org.restcomm.sbc.media.helpers.SessionDescriptionParser;
import org.restcomm.sbc.media.MediaSession;


Expand Down Expand Up @@ -91,8 +95,8 @@ public ProcessorCallBack getCallback() {


@Override
public String getVersion() {
return "1.0.0";
public double getVersion() {
return 1.0;
}


Expand All @@ -117,7 +121,9 @@ private void processRequest(Message message) throws ProcessorParsingException {
m.setTargetTransport(connector.getTransport().toString());

} catch (Exception e) {
LOG.error("ERROR", e);
LOG.error("ERROR "+e.getMessage()+" aborting message!");
message.abort();
return;
}
}
else {
Expand Down Expand Up @@ -151,8 +157,10 @@ private void processRequest(Message message) throws ProcessorParsingException {
sm.getContentType().equals("application/sdp")) {
try {
mediaSession=callManager.getMediaSession(sm.getSession().getId());
StreamProfile streamProfile=(m.getSourceTransport().equals(ProtocolAdapterFactory.PROTOCOL_WSS)?StreamProfile.WEBRTC:StreamProfile.AVP);
mediaSession.buildOffer(streamProfile, new String(sm.getRawContent()), m.getTargetLocalAddress());
ExtendedSessionDescription sdp = SessionDescriptionParser.parse(new String(sm.getRawContent()));

//StreamProfile streamProfile=(m.getSourceTransport().equals(ProtocolAdapterFactory.PROTOCOL_WSS)?StreamProfile.WEBRTC:StreamProfile.AVP);
mediaSession.buildOffer(sdp, m.getTargetLocalAddress());
m.setMetadata(mediaSession);
} catch (IOException | SdpException e) {
LOG.error("Invalid MediaMetadata!", e);
Expand Down Expand Up @@ -195,12 +203,13 @@ private void processResponse(Message message) {
Location location = null;

try {
location = LocationManager.getLocationManager().getLocation(fromURI.getUser() + "@" + ConfigurationCache.getDomain());
m.setTargetLocalAddress(ConfigurationCache.getIpOfDomain());
location = LocationManager.getLocationManager().getLocation(fromURI.getUser() + "@" + ConfigurationCache.getDomain());

m.setTargetRemoteAddress(location.getHost());
m.setTargetTransport(location.getTransport().toUpperCase());
} catch (Exception e) {
LOG.error("ERROR", e);
LOG.warn("May be an incoming trunk call, let's handle that " + e.getMessage());
}
}
}
Expand All @@ -212,8 +221,10 @@ private void processResponse(Message message) {
SipServletResponse response=(SipServletResponse) sm;
String callSessionId=getCallSessionId(response.getRequest());
mediaSession=callManager.getMediaSession(callSessionId);
StreamProfile streamProfile=(m.getSourceTransport().equals(ProtocolAdapterFactory.PROTOCOL_WSS)?StreamProfile.WEBRTC:StreamProfile.AVP);
mediaSession.buildAnswer(streamProfile, new String(sm.getRawContent()), m.getTargetLocalAddress());
ExtendedSessionDescription sdp = SessionDescriptionParser.parse(new String(sm.getRawContent()));

//StreamProfile streamProfile=(m.getSourceTransport().equals(ProtocolAdapterFactory.PROTOCOL_WSS)?StreamProfile.WEBRTC:StreamProfile.AVP);
mediaSession.buildAnswer(sdp, m.getTargetLocalAddress());
m.setMetadata(mediaSession);
} catch (IOException | SdpException e) {
LOG.error("Invalid MediaMetadata!", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public class NATHelperProcessor extends DefaultProcessor implements ProcessorCal
private static transient Logger LOG = Logger.getLogger(NATHelperProcessor.class);
private LocationManager locationManager=LocationManager.getLocationManager();

public NATHelperProcessor() {
// just to notify spi instantiation
super();
}

public NATHelperProcessor(ProcessorChain callback) {
super(callback);
Expand Down Expand Up @@ -190,10 +194,9 @@ public ProcessorCallBack getCallback() {


@Override
public String getVersion() {
return "1.0.0";
public double getVersion() {
return 1.0;
}

@Override
public void doProcess(Message message) throws ProcessorParsingException {
SIPMutableMessage m = (SIPMutableMessage) message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public class ProtocolAdaptProcessor extends DefaultProcessor
implements ProcessorCallBack {

private static transient Logger LOG = Logger.getLogger(ProtocolAdaptProcessor.class);
private String name="Protocol Adapt Processor";


protected ProtocolAdapterFactory protocolAdapterFactory;
protected RouteManager routeManager;

Expand Down Expand Up @@ -107,20 +106,18 @@ private void processRequest(Message message) {


public String getName() {
return name;
return "Protocol Adapt Processor";
}



public int getId() {
return this.hashCode();
}


@Override
public void setName(String name) {
this.name=name;
this.name = name;

}


Expand All @@ -145,8 +142,8 @@ public void doProcess(Message message) throws ProcessorParsingException {
}

@Override
public String getVersion() {
return "1.0.0";
public double getVersion() {
return 1.0;
}


Expand Down
Loading

0 comments on commit df1bc99

Please sign in to comment.