Commit 19ab15c5 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Create a route to the remote server if the domain belongs to a remote server. JM-6


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1375 b35dd754-fafc-0310-a699-88a17e54d16e
parent bbe64a3b
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
package org.jivesoftware.messenger.spi; package org.jivesoftware.messenger.spi;
import org.jivesoftware.messenger.*; import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.server.OutgoingServerSession;
import org.jivesoftware.messenger.container.BasicModule; import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
...@@ -42,6 +43,7 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable { ...@@ -42,6 +43,7 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable {
* locks access to the routing tale * locks access to the routing tale
*/ */
private ReadWriteLock routeLock = new ReentrantReadWriteLock(); private ReadWriteLock routeLock = new ReentrantReadWriteLock();
private String serverName;
public RoutingTableImpl() { public RoutingTableImpl() {
super("Routing table"); super("Routing table");
...@@ -81,6 +83,13 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable { ...@@ -81,6 +83,13 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable {
String nodeJID = node.getNode() == null ? "" : node.getNode(); String nodeJID = node.getNode() == null ? "" : node.getNode();
String resourceJID = node.getResource() == null ? "" : node.getResource(); String resourceJID = node.getResource() == null ? "" : node.getResource();
// Check if the address belongs to a remote server
if (!node.getDomain().contains(serverName)) {
// Authenticate this hostname with the remote server so that the remote server can
// accept packets from this server.
OutgoingServerSession.authenticateDomain(serverName, node.getDomain());
}
routeLock.readLock().lock(); routeLock.readLock().lock();
try { try {
Object nameRoutes = routes.get(node.getDomain()); Object nameRoutes = routes.get(node.getDomain());
...@@ -253,4 +262,9 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable { ...@@ -253,4 +262,9 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable {
} }
return route; return route;
} }
public void initialize(XMPPServer server) {
super.initialize(server);
serverName = server.getServerInfo().getName();
}
} }
\ 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