Commit 58a369ea authored by unknown's avatar unknown

Updated plugin with the following features:

* Made ports configurable via the admin interface
* Made STUN test server default to google and configurable via the admin interface (previous hardcoded server was dead)
* Made Local/Public IP logic work for a server behind a firewall (previous code was mixing local and remote IP concepts and would only work outside of a firewall)
* Added some logging to the verify code to make it easier to find out why verification failed
parent 97d2def3
...@@ -49,6 +49,11 @@ ...@@ -49,6 +49,11 @@
Jingle Nodes Plugin Changelog Jingle Nodes Plugin Changelog
</h1> </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> <p><b>0.1.1</b> -- Jan 16, 2015</p>
<ul> <ul>
<li>OF-444 Fix i18n filename to lowercase.</li> <li>OF-444 Fix i18n filename to lowercase.</li>
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<plugin> <plugin>
<class>org.jinglenodes.JingleNodesPlugin</class> <class>org.jinglenodes.JingleNodesPlugin</class>
<name>Jingle Nodes Plugin</name> <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> <author>Jingle Nodes (Rodrigo Martins)</author>
<version>0.1.1</version> <version>0.1.2</version>
<date>01/16/2015</date> <date>04/22/2015</date>
<minServerVersion>3.9.0</minServerVersion> <minServerVersion>3.9.0</minServerVersion>
<adminconsole> <adminconsole>
......
...@@ -7,5 +7,11 @@ jn.active.channels=Active Channels ...@@ -7,5 +7,11 @@ jn.active.channels=Active Channels
jn.settings.title=Jingle Nodes Status jn.settings.title=Jingle Nodes Status
jn.verified.ip.warning=Jingle Nodes Requires a Public IP for Internet Calling. Public IP Found: jn.verified.ip.warning=Jingle Nodes Requires a Public IP for Internet Calling. Public IP Found:
jn.settings.update.settings =Update Settings jn.settings.update.settings =Update Settings
jn.settings.overrideip= Override Public IP jn.settings.localip=Local IP Address
jn.settings.invalid.publicip =Invalid Public IP Address jn.settings.publicip=Public IP Address
\ No newline at end of file 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 { ...@@ -84,14 +84,14 @@ class JingleNodesComponent extends AbstractComponent {
if (channel != null) { if (channel != null) {
childElement.addAttribute(HOST, LocalIPResolver.getLocalIP()); childElement.addAttribute(HOST, plugin.getPublicIP());
childElement.addAttribute(LOCAL_PORT, Integer.toString(channel.getPortA())); childElement.addAttribute(LOCAL_PORT, Integer.toString(channel.getPortA()));
childElement.addAttribute(REMOTE_PORT, Integer.toString(channel.getPortB())); childElement.addAttribute(REMOTE_PORT, Integer.toString(channel.getPortB()));
reply.setChildElement(childElement); reply.setChildElement(childElement);
Log.debug("Created relay channel {}:{}, {}:{}, {}:{}", new Object[]{HOST, 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())}); Integer.toString(channel.getPortB())});
} else { } else {
......
...@@ -43,7 +43,13 @@ public class JingleNodesPlugin implements Plugin { ...@@ -43,7 +43,13 @@ public class JingleNodesPlugin implements Plugin {
private static final Logger Log = LoggerFactory.getLogger(JingleNodesPlugin.class); 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 ComponentManager componentManager;
private final ConcurrentHashMap<String, RelayChannel> channels = new ConcurrentHashMap<String, RelayChannel>(); private final ConcurrentHashMap<String, RelayChannel> channels = new ConcurrentHashMap<String, RelayChannel>();
...@@ -92,10 +98,20 @@ public class JingleNodesPlugin implements Plugin { ...@@ -92,10 +98,20 @@ public class JingleNodesPlugin implements Plugin {
} }
public void verifyNetwork() { 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); LocalIPResolver.setOverrideIp(localAddress);
final InetSocketAddress publicAddress = PublicIPResolver.getPublicAddress("stun.xten.com", 3478); final InetSocketAddress publicAddress = PublicIPResolver.getPublicAddress(getTestSTUNServer(), getTestSTUNPort());
hasPublicIP = publicAddress != null && publicAddress.getAddress().getHostAddress().equals(localAddress); 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() { private void closeAllChannels() {
...@@ -108,7 +124,7 @@ public class JingleNodesPlugin implements Plugin { ...@@ -108,7 +124,7 @@ public class JingleNodesPlugin implements Plugin {
RelayChannel rc = null; RelayChannel rc = null;
try { 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 int id = ids.incrementAndGet();
final String sId = String.valueOf(id); final String sId = String.valueOf(id);
rc.setAttachment(sId); rc.setAttachment(sId);
...@@ -147,4 +163,25 @@ public class JingleNodesPlugin implements Plugin { ...@@ -147,4 +163,25 @@ public class JingleNodesPlugin implements Plugin {
public int getActiveChannelCount() { public int getActiveChannelCount() {
return channels.size(); 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 @@ ...@@ -38,13 +38,19 @@
JingleNodesPlugin plugin = (JingleNodesPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("jinglenodes"); JingleNodesPlugin plugin = (JingleNodesPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("jinglenodes");
if (update) { 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) { if (overrideIP != null) {
overrideIP = overrideIP.trim(); overrideIP = overrideIP.trim();
try { try {
InetAddress.getByName(overrideIP); InetAddress.getByName(overrideIP);
LocalIPResolver.setOverrideIp(overrideIP); LocalIPResolver.setOverrideIp(overrideIP);
JiveGlobals.setProperty(JingleNodesPlugin.JN_PUB_IP_PROPERTY, overrideIP); JiveGlobals.setProperty(JingleNodesPlugin.JN_LOCAL_IP_PROPERTY, overrideIP);
plugin.verifyNetwork(); plugin.verifyNetwork();
} catch (Exception e) { } catch (Exception e) {
errorMessage = LocaleUtils.getLocalizedString("jn.settings.invalid.publicip", "jinglenodes"); errorMessage = LocaleUtils.getLocalizedString("jn.settings.invalid.publicip", "jinglenodes");
...@@ -99,13 +105,44 @@ ...@@ -99,13 +105,44 @@
</td> </td>
</tr> </tr>
<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>
<td align="left"> <td align="left">
<input name="overrideip" type="text" maxlength="15" size="15" <input name="localip" type="text" maxlength="15" size="15"
value="<%=LocalIPResolver.getLocalIP()%>"/> value="<%=LocalIPResolver.getLocalIP()%>"/>
</td> </td>
</tr> </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> <tr>
<th colspan="2"><input type="submit" name="update" <th colspan="2"><input type="submit" name="update"
value="<fmt:message key="jn.settings.update.settings" />"></th> 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