Commit 3f295e7b authored by Thiago Camargo's avatar Thiago Camargo Committed by thiago

STUN Discovery and Public Address from Media Proxy Service

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@7560 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1d726c71
...@@ -47,6 +47,7 @@ public class MediaProxyService extends BasicModule ...@@ -47,6 +47,7 @@ public class MediaProxyService extends BasicModule
private PacketRouter router; private PacketRouter router;
private Echo echo = null; private Echo echo = null;
private int echoPort = 10020; private int echoPort = 10020;
private SessionManager sessionManager = null;
private MediaProxy mediaProxy = null; private MediaProxy mediaProxy = null;
private boolean enabled = true; private boolean enabled = true;
...@@ -63,6 +64,7 @@ public class MediaProxyService extends BasicModule ...@@ -63,6 +64,7 @@ public class MediaProxyService extends BasicModule
public void initialize(XMPPServer server) { public void initialize(XMPPServer server) {
super.initialize(server); super.initialize(server);
sessionManager = server.getSessionManager();
mediaProxy = new MediaProxy(server.getServerInfo().getName()); mediaProxy = new MediaProxy(server.getServerInfo().getName());
String defaultName = "rtpbridge"; String defaultName = "rtpbridge";
...@@ -91,7 +93,7 @@ public class MediaProxyService extends BasicModule ...@@ -91,7 +93,7 @@ public class MediaProxyService extends BasicModule
routingTable.addRoute(getAddress(), this); routingTable.addRoute(getAddress(), this);
XMPPServer.getInstance().getIQDiscoItemsHandler().addServerItemsProvider(this); XMPPServer.getInstance().getIQDiscoItemsHandler().addServerItemsProvider(this);
} else { } else {
if(echo!=null) echo.cancel(); if (echo != null) echo.cancel();
XMPPServer.getInstance().getIQDiscoItemsHandler().removeComponentItem(getAddress().toString()); XMPPServer.getInstance().getIQDiscoItemsHandler().removeComponentItem(getAddress().toString());
} }
} }
...@@ -101,7 +103,7 @@ public class MediaProxyService extends BasicModule ...@@ -101,7 +103,7 @@ public class MediaProxyService extends BasicModule
mediaProxy.stopProxy(); mediaProxy.stopProxy();
XMPPServer.getInstance().getIQDiscoItemsHandler().removeComponentItem(getAddress().toString()); XMPPServer.getInstance().getIQDiscoItemsHandler().removeComponentItem(getAddress().toString());
routingTable.removeRoute(getAddress()); routingTable.removeRoute(getAddress());
if(echo!=null) echo.cancel(); if (echo != null) echo.cancel();
} }
// Component Interface // Component Interface
...@@ -192,6 +194,25 @@ public class MediaProxyService extends BasicModule ...@@ -192,6 +194,25 @@ public class MediaProxyService extends BasicModule
} }
} }
childElementCopy.remove(candidateElement); childElementCopy.remove(candidateElement);
} else {
candidateElement = childElementCopy.element("publicip");
if (candidateElement != null) {
childElementCopy.remove(candidateElement);
Element publicIp = childElementCopy.addElement("publicip");
try {
String ip = sessionManager.getSession(iq.getFrom()).getConnection().getInetAddress().getHostAddress();
if (ip != null) {
publicIp.addAttribute("ip", ip);
}
} catch (UnknownHostException e) {
e.printStackTrace();
}
} else {
childElementCopy.remove(candidateElement);
reply.setError(PacketError.Condition.forbidden);
}
} }
} }
} else { } else {
......
...@@ -56,6 +56,9 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou ...@@ -56,6 +56,9 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou
private int primaryPort = 3478; private int primaryPort = 3478;
private int secondaryPort = 3479; private int secondaryPort = 3479;
private String externalServerAddress = null;
private int externalServerPort = 3478;
public static final String NAMESPACE = "google:jingleinfo"; public static final String NAMESPACE = "google:jingleinfo";
/** /**
...@@ -72,6 +75,9 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou ...@@ -72,6 +75,9 @@ public class STUNService extends BasicModule implements ServerItemsProvider, Rou
primaryAddress = JiveGlobals.getProperty("stun.address.primary"); primaryAddress = JiveGlobals.getProperty("stun.address.primary");
secondaryAddress = JiveGlobals.getProperty("stun.address.secondary"); secondaryAddress = JiveGlobals.getProperty("stun.address.secondary");
externalServerAddress = JiveGlobals.getProperty("stun.external.address");
externalServerAddress = JiveGlobals.getProperty("stun.external.port");
if (primaryAddress == null || primaryAddress.equals("")) if (primaryAddress == null || primaryAddress.equals(""))
primaryAddress = JiveGlobals.getProperty("xmpp.domain", primaryAddress = JiveGlobals.getProperty("xmpp.domain",
JiveGlobals.getXMLProperty("network.interface", "localhost")); JiveGlobals.getXMLProperty("network.interface", "localhost"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment