Commit 034fa58d authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fixed s2s between "example.com" and "foo.example.com". JM-348


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1704 b35dd754-fafc-0310-a699-88a17e54d16e
parent d89a812f
...@@ -12,17 +12,16 @@ ...@@ -12,17 +12,16 @@
package org.jivesoftware.messenger.spi; package org.jivesoftware.messenger.spi;
import org.jivesoftware.messenger.*; import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.component.InternalComponentManager;
import org.jivesoftware.messenger.server.OutgoingServerSession; 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;
import java.util.Collections; import java.util.*;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* <p>Uses simple hashtables for table storage.</p> * <p>Uses simple hashtables for table storage.</p>
...@@ -37,16 +36,18 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable { ...@@ -37,16 +36,18 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable {
/** /**
* We need a three level tree built of hashtables: host -> name -> resource * We need a three level tree built of hashtables: host -> name -> resource
*/ */
private Hashtable routes = new Hashtable(); private Map routes = new ConcurrentHashMap();
/** /**
* 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; private String serverName;
private InternalComponentManager componentManager;
public RoutingTableImpl() { public RoutingTableImpl() {
super("Routing table"); super("Routing table");
componentManager = InternalComponentManager.getInstance();
} }
public void addRoute(JID node, RoutableChannelHandler destination) { public void addRoute(JID node, RoutableChannelHandler destination) {
...@@ -84,7 +85,8 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable { ...@@ -84,7 +85,8 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable {
String resourceJID = node.getResource() == null ? "" : node.getResource(); String resourceJID = node.getResource() == null ? "" : node.getResource();
// Check if the address belongs to a remote server // Check if the address belongs to a remote server
if (!node.getDomain().contains(serverName)) { if (!serverName.equals(node.getDomain()) && routes.get(node.getDomain()) == null &&
componentManager.getComponent(node.getDomain()) == null) {
// Authenticate this hostname with the remote server so that the remote server can // Authenticate this hostname with the remote server so that the remote server can
// accept packets from this server. // accept packets from this server.
OutgoingServerSession.authenticateDomain(serverName, node.getDomain()); OutgoingServerSession.authenticateDomain(serverName, node.getDomain());
...@@ -124,7 +126,8 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable { ...@@ -124,7 +126,8 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable {
public Iterator getRoutes(JID node) { public Iterator getRoutes(JID node) {
// Check if the address belongs to a remote server // Check if the address belongs to a remote server
if (!node.getDomain().contains(serverName)) { if (!serverName.equals(node.getDomain()) && routes.get(node.getDomain()) == null &&
componentManager.getComponent(node.getDomain()) == null) {
// Authenticate this hostname with the remote server so that the remote server can // Authenticate this hostname with the remote server so that the remote server can
// accept packets from this server. // accept packets from this server.
OutgoingServerSession.authenticateDomain(serverName, node.getDomain()); OutgoingServerSession.authenticateDomain(serverName, node.getDomain());
...@@ -193,7 +196,7 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable { ...@@ -193,7 +196,7 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable {
* @param list The list to stuff entries into * @param list The list to stuff entries into
* @param table The hashtable who's values should be entered into the list * @param table The hashtable who's values should be entered into the list
*/ */
private void getRoutes(LinkedList list, Hashtable table) { private void getRoutes(LinkedList list, Map table) {
Iterator entryIter = table.values().iterator(); Iterator entryIter = table.values().iterator();
while (entryIter.hasNext()) { while (entryIter.hasNext()) {
Object entry = entryIter.next(); Object entry = entryIter.next();
......
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