Commit db528c1e authored by Thiago Camargo's avatar Thiago Camargo Committed by thiago

[OF-408] - Jingle Nodes 0.0.2 - Updated Library and Admin Page

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11986 b35dd754-fafc-0310-a699-88a17e54d16e
parent d93645fd
......@@ -57,5 +57,11 @@
<li>Auto Discovery of IP with Public Interface</li>
</ul>
<p><b>0.0.2</b> -- October 12, 2010</p>
<ul>
<li>Public IP Verification</li>
</ul>
</body>
</html>
......@@ -5,7 +5,18 @@
<name>Jingle Nodes Plugin</name>
<description>Provides support for Jingle Nodes</description>
<author>Jingle Nodes (Rodrigo Martins)</author>
<version>0.0.1</version>
<date>16/7/2010</date>
<version>0.0.2</version>
<date>16/10/2010</date>
<minServerVersion>3.7.0</minServerVersion>
<adminconsole>
<tab id="tab-server">
<sidebar id="siderbar-jn" name="${admin.item.jn}">
<item id="jingle-nodes" name="${admin.item.jn.settings.name}"
description="${admin.item.sipark.settings.description}" url="jingle-nodes.jsp"/>
</sidebar>
</tab>
</adminconsole>
</plugin>
......@@ -54,6 +54,7 @@
Implementation of http://xmpp.org/extensions/xep-0278.html.
Provides a NIO Implementation of Jingle Nodes, which is an easy to NAT Traversal service purely based on XMPP and
aims mainly, but not limited to, Jingle Clients.
For more information please visit: <a href="http://jinglenodes.org" target="_blank">http://jinglenodes.org</a>
</p>
<h2>Installation</h2>
......
login.title = Admin Console
admin.item.jn=Jingle Nodes
admin.item.jn.settings.name=Jingle Nodes Status
jn.verified.ip=Verified Public IP
jn.active.channels=Active Channels
jn.settings.title=Jingle Nodes Status
jn.verified.ip.warning=Jingle Nodes Requires a Public IP for Internet Calling. Check your Network Settings.
\ No newline at end of file
......@@ -26,6 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.AbstractComponent;
import org.xmpp.jnodes.RelayChannel;
import org.xmpp.jnodes.RelayPublicMask;
import org.xmpp.jnodes.nio.LocalIPResolver;
import org.xmpp.jnodes.smack.JingleChannelIQ;
import org.xmpp.jnodes.smack.JingleTrackerIQ;
......@@ -82,9 +83,18 @@ class JingleNodesComponent extends AbstractComponent {
final RelayChannel channel = plugin.createRelayChannel();
if (channel != null) {
childElement.addAttribute(HOST, LocalIPResolver.getLocalIP());
childElement.addAttribute(LOCAL_PORT, Integer.toString(channel.getPortA()));
childElement.addAttribute(REMOTE_PORT, Integer.toString(channel.getPortB()));
// final RelayPublicMask rpm = new RelayPublicMask(channel);
// rpm.discover("stun.xten.com", 3478);
// childElement.addAttribute(HOST, rpm.getAddressA().getAddress().getHostAddress());
// childElement.addAttribute(LOCAL_PORT, Integer.toString(rpm.getAddressA().getPort()));
// childElement.addAttribute(REMOTE_PORT, Integer.toString(rpm.getAddressB().getPort()));
reply.setChildElement(childElement);
Log.debug("Created relay channel {}:{}, {}:{}, {}:{}", new Object[]{HOST,
......
......@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.net.InetSocketAddress;
import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;
......@@ -34,6 +35,8 @@ import org.xmpp.component.ComponentException;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.jnodes.RelayChannel;
import org.xmpp.jnodes.nio.LocalIPResolver;
import org.xmpp.jnodes.nio.PublicIPResolver;
public class JingleNodesPlugin implements Plugin {
......@@ -47,6 +50,8 @@ public class JingleNodesPlugin implements Plugin {
private final String serviceName = "relay";
private boolean hasPublicIP = false;
public void initializePlugin(PluginManager manager, File pluginDirectory) {
componentManager = ComponentManagerFactory.getComponentManager();
JingleNodesComponent component = new JingleNodesComponent(this);
......@@ -73,6 +78,17 @@ public class JingleNodesPlugin implements Plugin {
}
}, timeout, timeout, TimeUnit.MILLISECONDS);
Log.info("Jingle Nodes Loaded.");
verifyNetwork();
}
private void verifyNetwork() {
final String localAddress = LocalIPResolver.getLocalIP();
final InetSocketAddress publicAddress = PublicIPResolver.getPublicAddress("stun.xten.com", 3478);
hasPublicIP = publicAddress != null && publicAddress.getAddress().getHostAddress().equals(localAddress);
}
private void closeAllChannels() {
......@@ -84,7 +100,7 @@ public class JingleNodesPlugin implements Plugin {
public RelayChannel createRelayChannel() {
RelayChannel rc = null;
try {
rc = RelayChannel.createLocalRelayChannel("0.0.0.0", 30000, 50000);
rc = RelayChannel.createLocalRelayChannel(LocalIPResolver.getLocalIP(), 30000, 50000);
final int id = ids.incrementAndGet();
final String sId = String.valueOf(id);
rc.setAttachment(sId);
......@@ -115,4 +131,12 @@ public class JingleNodesPlugin implements Plugin {
closeAllChannels();
executor.shutdownNow();
}
public boolean hasPublicIP() {
return hasPublicIP;
}
public int getActiveChannelCount() {
return channels.size();
}
}
<%@ page import="org.jinglenodes.JingleNodesPlugin" %>
<%@ page import="org.jivesoftware.openfire.XMPPServer" %>
<%@ page import="java.util.Collection" %>
<%@ page import="org.jivesoftware.openfire.container.Plugin" %>
<%--
- $Revision: $
- $Date: $
-
- Copyright (C) 2005-2008 Jive Software. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%
// Get handle on the Monitoring plugin
JingleNodesPlugin plugin = (JingleNodesPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("jinglenodes");
%>
<html>
<head>
<title><fmt:message key="jn.settings.title"/></title>
<meta name="pageID" content="jingle-nodes"/>
</head>
<body>
<div class="jive-table">
<table class="jive-table" cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th colspan="2"><fmt:message key="jn.settings.title"/></th>
</tr>
</thead>
<tbody>
<tr>
<td><label class="jive-label"><fmt:message key="jn.verified.ip"/>:</label><br></td>
<td align="left"><% if (plugin.hasPublicIP()) { %>
<img src="/images/check.gif" width="17" height="17" border="0">
<% } else { %>
<img src="/images/x.gif" width="17" height="17" border="0"><i>&nbsp;<fmt:message key="jn.verified.ip.warning"/></i>
<% } %>
</td>
</tr>
<tr>
<td><label class="jive-label"><fmt:message key="jn.active.channels"/>:</label><br>
</td>
<td align="left"><%=plugin.getActiveChannelCount()%>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
\ No newline at end of file
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