Commit 9cc37be2 authored by Dele Olajide's avatar Dele Olajide

Merge pull request #204 from Guenther93/master

Updated jingleNodes plugin to work with Public/Private IP and Configurable Ports/Servers:
parents c99af1e7 58a369ea
......@@ -49,6 +49,11 @@
Jingle Nodes Plugin Changelog
</h1>
<p><b>0.1.2</b> -- Apr 22, 2015</p>
<ul>
<li>Not an official ignite release - fixed the plugin to allow advanced configuration of ip addresses, port numbers, and servers. Previously the code could not work right behind a firewall and the test STUN server hardcoded into the file was not operational.</li>
</ul>
<p><b>0.1.1</b> -- Jan 16, 2015</p>
<ul>
<li>OF-444 Fix i18n filename to lowercase.</li>
......
......@@ -3,10 +3,10 @@
<plugin>
<class>org.jinglenodes.JingleNodesPlugin</class>
<name>Jingle Nodes Plugin</name>
<description>Provides support for Jingle Nodes</description>
<description>Provides support for Jingle Nodes. This version is a custom modified version of 1.1.1 with a more advanced admin page exposing more properties and the ability to work behind a firewall.</description>
<author>Jingle Nodes (Rodrigo Martins)</author>
<version>0.1.1</version>
<date>01/16/2015</date>
<version>0.1.2</version>
<date>04/22/2015</date>
<minServerVersion>3.9.0</minServerVersion>
<adminconsole>
......
......@@ -7,5 +7,11 @@ jn.active.channels=Active Channels
jn.settings.title=Jingle Nodes Status
jn.verified.ip.warning=Jingle Nodes Requires a Public IP for Internet Calling. Public IP Found:
jn.settings.update.settings =Update Settings
jn.settings.overrideip= Override Public IP
jn.settings.invalid.publicip =Invalid Public IP Address
\ No newline at end of file
jn.settings.localip=Local IP Address
jn.settings.publicip=Public IP Address
jn.settings.publicip.help=Optional use if Local IP is behind a firewall
jn.settings.invalid.publicip =Invalid Public IP Address
jn.settings.portrange=Port Range
jn.settings.portrange.help=Default 30000-50000
jn.settings.teststunserver=STUN Verification Server
jn.settings.teststunserver.help=Used only to verify Public IP access
\ No newline at end of file
......@@ -84,14 +84,14 @@ class JingleNodesComponent extends AbstractComponent {
if (channel != null) {
childElement.addAttribute(HOST, LocalIPResolver.getLocalIP());
childElement.addAttribute(HOST, plugin.getPublicIP());
childElement.addAttribute(LOCAL_PORT, Integer.toString(channel.getPortA()));
childElement.addAttribute(REMOTE_PORT, Integer.toString(channel.getPortB()));
reply.setChildElement(childElement);
Log.debug("Created relay channel {}:{}, {}:{}, {}:{}", new Object[]{HOST,
LocalIPResolver.getLocalIP(), LOCAL_PORT, Integer.toString(channel.getPortA()), REMOTE_PORT,
plugin.getPublicIP(), LOCAL_PORT, Integer.toString(channel.getPortA()), REMOTE_PORT,
Integer.toString(channel.getPortB())});
} else {
......
......@@ -43,7 +43,13 @@ public class JingleNodesPlugin implements Plugin {
private static final Logger Log = LoggerFactory.getLogger(JingleNodesPlugin.class);
public static final String JN_PUB_IP_PROPERTY = "jinglenodes.publicip";
public static final String JN_LOCAL_IP_PROPERTY = "jinglenodes.localIP";
public static final String JN_PUBLIC_IP_PROPERTY = "jinglenodes.publicIP";
public static final String JN_MIN_PORT_PROPERTY = "jinglenodes.minPort";
public static final String JN_MAX_PORT_PROPERTY = "jinglenodes.maxPort";
public static final String JN_TEST_STUN_SERVER_PROPERTY = "jinglenodes.testSTUNServer";
public static final String JN_TEST_STUN_PORT_PROPERTY = "jinglenodes.testSTUNPort";
private ComponentManager componentManager;
private final ConcurrentHashMap<String, RelayChannel> channels = new ConcurrentHashMap<String, RelayChannel>();
......@@ -92,10 +98,20 @@ public class JingleNodesPlugin implements Plugin {
}
public void verifyNetwork() {
final String localAddress = JiveGlobals.getProperty(JN_PUB_IP_PROPERTY, LocalIPResolver.getLocalIP());
final String localAddress = JiveGlobals.getProperty(JN_LOCAL_IP_PROPERTY, LocalIPResolver.getLocalIP());
LocalIPResolver.setOverrideIp(localAddress);
final InetSocketAddress publicAddress = PublicIPResolver.getPublicAddress("stun.xten.com", 3478);
hasPublicIP = publicAddress != null && publicAddress.getAddress().getHostAddress().equals(localAddress);
final InetSocketAddress publicAddress = PublicIPResolver.getPublicAddress(getTestSTUNServer(), getTestSTUNPort());
hasPublicIP = publicAddress != null && publicAddress.getAddress().getHostAddress().equals(getPublicIP());
// Provide a more detailed log message to help users reasonably debug this situation
if (!hasPublicIP) {
if (publicAddress != null) {
Log.error("verifyNetwork Failed - public IP address from test STUN server [" + publicAddress.getAddress().getHostAddress() + "] does not match server configuration [" + getPublicIP() + "]");
}
else {
Log.error("verifyNetwork Failed - failed to retrieve public address from test STUN server " + getTestSTUNServer() + ":" + Integer.toString(getTestSTUNPort()));
}
}
}
private void closeAllChannels() {
......@@ -108,7 +124,7 @@ public class JingleNodesPlugin implements Plugin {
RelayChannel rc = null;
try {
rc = RelayChannel.createLocalRelayChannel(bindAllInterfaces ? "0.0.0.0" : LocalIPResolver.getLocalIP(), 30000, 50000);
rc = RelayChannel.createLocalRelayChannel(bindAllInterfaces ? "0.0.0.0" : LocalIPResolver.getLocalIP(), getMinPort(), getMaxPort());
final int id = ids.incrementAndGet();
final String sId = String.valueOf(id);
rc.setAttachment(sId);
......@@ -147,4 +163,25 @@ public class JingleNodesPlugin implements Plugin {
public int getActiveChannelCount() {
return channels.size();
}
// Changed all previous hardcoded values to be properties that can be overridden
public String getPublicIP() {
return JiveGlobals.getProperty(JN_PUBLIC_IP_PROPERTY, LocalIPResolver.getLocalIP());
}
public int getMinPort() {
return Integer.parseInt(JiveGlobals.getProperty(JN_MIN_PORT_PROPERTY, "30000"));
}
public int getMaxPort() {
return Integer.parseInt(JiveGlobals.getProperty(JN_MAX_PORT_PROPERTY, "50000"));
}
public String getTestSTUNServer() {
return JiveGlobals.getProperty(JN_TEST_STUN_SERVER_PROPERTY, "stun.l.google.com");
}
public int getTestSTUNPort() {
return Integer.parseInt(JiveGlobals.getProperty(JN_TEST_STUN_PORT_PROPERTY, "19302"));
}
}
......@@ -38,13 +38,19 @@
JingleNodesPlugin plugin = (JingleNodesPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("jinglenodes");
if (update) {
String overrideIP = request.getParameter("overrideip");
JiveGlobals.setProperty(JingleNodesPlugin.JN_PUBLIC_IP_PROPERTY, request.getParameter("publicip"));
JiveGlobals.setProperty(JingleNodesPlugin.JN_MIN_PORT_PROPERTY, request.getParameter("minport"));
JiveGlobals.setProperty(JingleNodesPlugin.JN_MAX_PORT_PROPERTY, request.getParameter("maxport"));
JiveGlobals.setProperty(JingleNodesPlugin.JN_TEST_STUN_SERVER_PROPERTY, request.getParameter("teststunserver"));
JiveGlobals.setProperty(JingleNodesPlugin.JN_TEST_STUN_PORT_PROPERTY, request.getParameter("teststunport"));
String overrideIP = request.getParameter("localip");
if (overrideIP != null) {
overrideIP = overrideIP.trim();
try {
InetAddress.getByName(overrideIP);
LocalIPResolver.setOverrideIp(overrideIP);
JiveGlobals.setProperty(JingleNodesPlugin.JN_PUB_IP_PROPERTY, overrideIP);
JiveGlobals.setProperty(JingleNodesPlugin.JN_LOCAL_IP_PROPERTY, overrideIP);
plugin.verifyNetwork();
} catch (Exception e) {
errorMessage = LocaleUtils.getLocalizedString("jn.settings.invalid.publicip", "jinglenodes");
......@@ -99,13 +105,44 @@
</td>
</tr>
<tr>
<td><label class="jive-label"><fmt:message key="jn.settings.overrideip"/>:</label><br>
<td><label class="jive-label"><fmt:message key="jn.settings.localip"/>:</label><br>
</td>
<td align="left">
<input name="overrideip" type="text" maxlength="15" size="15"
<input name="localip" type="text" maxlength="15" size="15"
value="<%=LocalIPResolver.getLocalIP()%>"/>
</td>
</tr>
<tr>
<td><label class="jive-label"><fmt:message key="jn.settings.publicip"/>:</label><br>
</td>
<td align="left">
<input name="publicip" type="text" maxlength="15" size="15"
value="<%=JiveGlobals.getProperty(plugin.JN_PUBLIC_IP_PROPERTY, "")%>"/>
<i><fmt:message key="jn.settings.publicip.help"/></i>
</td>
</tr>
<tr>
<td><label class="jive-label"><fmt:message key="jn.settings.portrange"/>:</label><br>
</td>
<td align="left">
<input name="minport" type="text" maxlength="5" size="6"
value="<%=plugin.getMinPort()%>"/> -
<input name="maxport" type="text" maxlength="5" size="6"
value="<%=plugin.getMaxPort()%>"/>
<i><fmt:message key="jn.settings.portrange.help"/></i>
</td>
</tr>
<tr>
<td><label class="jive-label"><fmt:message key="jn.settings.teststunserver"/>:</label><br>
</td>
<td align="left">
<input name="teststunserver" type="text" maxlength="30" size="15"
value="<%=plugin.getTestSTUNServer()%>"/>:
<input name="teststunport" type="text" maxlength="5" size="5"
value="<%=plugin.getTestSTUNPort()%>"/>
<i><fmt:message key="jn.settings.teststunserver.help"/></i>
</td>
</tr>
<tr>
<th colspan="2"><input type="submit" name="update"
value="<fmt:message key="jn.settings.update.settings" />"></th>
......
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