Commit 95be5c49 authored by guus's avatar guus

Makes sure that packets addressed to components are not processed by the S2S code (OF-75).

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11372 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3b25a32f
......@@ -212,9 +212,67 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
}
}
/*
* (non-Javadoc)
* @see org.jivesoftware.openfire.RoutingTable#routePacket(org.xmpp.packet.JID, org.xmpp.packet.Packet, boolean)
*
* @param jid the receipient of the packet to route.
* @param packet the packet to route.
* @param fromServer true if the packet was created by the server. This packets should
* always be delivered
* @throws PacketException thrown if the packet is malformed (results in the sender's
* session being shutdown).
*/
public void routePacket(JID jid, Packet packet, boolean fromServer) throws PacketException {
boolean routed = false;
if (serverName.equals(jid.getDomain())) {
// Packet sent to our domain.
routed = routeToLocalDomain(jid, packet, fromServer);
}
else if (jid.getDomain().contains(serverName)) {
// Packet sent to component hosted in this server
routed = routeToComponent(jid, packet, routed);
}
else {
// Packet sent to remote server
routed = routeToRemoteDomain(jid, packet, routed);
}
if (!routed) {
if (Log.isDebugEnabled()) {
Log.debug("RoutingTableImpl: Failed to route packet to JID: " + jid + " packet: " + packet);
}
if (packet instanceof IQ) {
iqRouter.routingFailed(jid, packet);
}
else if (packet instanceof Message) {
messageRouter.routingFailed(jid, packet);
}
else if (packet instanceof Presence) {
presenceRouter.routingFailed(jid, packet);
}
}
}
/**
* Routes packets that are sent to the XMPP domain itself (excluding subdomains).
*
* @param jid
* the recipient of the packet to route.
* @param packet
* the packet to route.
* @param fromServer
* true if the packet was created by the server. This packets
* should always be delivered
* @throws PacketException
* thrown if the packet is malformed (results in the sender's
* session being shutdown).
* @return <tt>true</tt> if the packet was routed successfully,
* <tt>false</tt> otherwise.
*/
private boolean routeToLocalDomain(JID jid, Packet packet,
boolean fromServer) {
boolean routed = false;
if (jid.getResource() == null) {
// Packet sent to a bare JID of a user
if (packet instanceof Message) {
......@@ -257,10 +315,33 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
}
}
}
return routed;
}
else if (jid.getDomain().contains(serverName) &&
(hasComponentRoute(jid) || ExternalComponentManager.hasConfiguration(jid.getDomain()))) {
// Packet sent to component hosted in this server
/**
* Routes packets that are sent to components of the XMPP domain (which are
* subdomains of the XMPP domain)
*
* @param jid
* the recipient of the packet to route.
* @param packet
* the packet to route.
* @param fromServer
* true if the packet was created by the server. This packets
* should always be delivered
* @throws PacketException
* thrown if the packet is malformed (results in the sender's
* session being shutdown).
* @return <tt>true</tt> if the packet was routed successfully,
* <tt>false</tt> otherwise.
*/
private boolean routeToComponent(JID jid, Packet packet,
boolean routed) {
if (!hasComponentRoute(jid)
&& !ExternalComponentManager.hasConfiguration(jid.getDomain())) {
return false;
}
// First check if the component is being hosted in this JVM
RoutableChannelHandler route = localRoutingTable.getRoute(jid.getDomain());
if (route != null) {
......@@ -299,9 +380,28 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
}
}
}
return routed;
}
else {
// Packet sent to remote server
/**
* Routes packets that are sent to other XMPP domains than the local XMPP
* domain.
*
* @param jid
* the recipient of the packet to route.
* @param packet
* the packet to route.
* @param fromServer
* true if the packet was created by the server. This packets
* should always be delivered
* @throws PacketException
* thrown if the packet is malformed (results in the sender's
* session being shutdown).
* @return <tt>true</tt> if the packet was routed successfully,
* <tt>false</tt> otherwise.
*/
private boolean routeToRemoteDomain(JID jid, Packet packet,
boolean routed) {
byte[] nodeID = serversCache.get(jid.getDomain());
if (nodeID != null) {
if (server.getNodeID().equals(nodeID)) {
......@@ -326,22 +426,7 @@ public class RoutingTableImpl extends BasicModule implements RoutingTable, Clust
OutgoingSessionPromise.getInstance().process(packet);
routed = true;
}
}
if (!routed) {
if (Log.isDebugEnabled()) {
Log.debug("RoutingTableImpl: Failed to route packet to JID: " + jid + " packet: " + packet);
}
if (packet instanceof IQ) {
iqRouter.routingFailed(jid, packet);
}
else if (packet instanceof Message) {
messageRouter.routingFailed(jid, packet);
}
else if (packet instanceof Presence) {
presenceRouter.routingFailed(jid, packet);
}
}
return routed;
}
/**
......
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