Commit e9da992c authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Allow to have multiple incoming s2s connections from the same remote server...

Allow to have multiple incoming s2s connections from the same remote server when using server dialback. JM-577

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3490 b35dd754-fafc-0310-a699-88a17e54d16e
parent 12eaa6be
...@@ -1496,6 +1496,43 @@ public class SessionManager extends BasicModule { ...@@ -1496,6 +1496,43 @@ public class SessionManager extends BasicModule {
serverName = null; serverName = null;
} }
/**
* Returns true if remote servers are allowed to have more than one connection to this
* server. Having more than one connection may improve number of packets that can be
* transfered per second. This setting only used by the server dialback mehod.<p>
*
* It is highly recommended that {@link #getServerSessionTimeout()} is enabled so that
* dead connections to this server can be easily discarded.
*
* @return true if remote servers are allowed to have more than one connection to this
* server.
*/
public boolean isMultipleServerConnectionsAllowed() {
return JiveGlobals.getBooleanProperty("xmpp.server.session.allowmultiple", true);
}
/**
* Sets if remote servers are allowed to have more than one connection to this
* server. Having more than one connection may improve number of packets that can be
* transfered per second. This setting only used by the server dialback mehod.<p>
*
* It is highly recommended that {@link #getServerSessionTimeout()} is enabled so that
* dead connections to this server can be easily discarded.
*
* @param allowed true if remote servers are allowed to have more than one connection to this
* server.
*/
public void setMultipleServerConnectionsAllowed(boolean allowed) {
JiveGlobals.setProperty("xmpp.server.session.allowmultiple", Boolean.toString(allowed));
if (allowed && JiveGlobals.getIntProperty("xmpp.server.session.idle", 10 * 60 * 1000) <= 0)
{
Log.warn("Allowing multiple S2S connections for each domain, without setting a " +
"maximum idle timeout for these connections, is unrecommended! Either " +
"set xmpp.server.session.allowmultiple to 'false' or change " +
"xmpp.server.session.idle to a (large) positive value.");
}
}
/****************************************************** /******************************************************
* Clean up code * Clean up code
*****************************************************/ *****************************************************/
...@@ -1534,6 +1571,14 @@ public class SessionManager extends BasicModule { ...@@ -1534,6 +1571,14 @@ public class SessionManager extends BasicModule {
} }
// Set the new property value // Set the new property value
JiveGlobals.setProperty("xmpp.server.session.idle", Integer.toString(idleTime)); JiveGlobals.setProperty("xmpp.server.session.idle", Integer.toString(idleTime));
if (idleTime <= 0 && isMultipleServerConnectionsAllowed() )
{
Log.warn("Allowing multiple S2S connections for each domain, without setting a " +
"maximum idle timeout for these connections, is unrecommended! Either " +
"set xmpp.server.session.allowmultiple to 'false' or change " +
"xmpp.server.session.idle to a (large) positive value.");
}
} }
public int getServerSessionIdleTime() { public int getServerSessionIdleTime() {
......
...@@ -14,15 +14,15 @@ package org.jivesoftware.wildfire.server; ...@@ -14,15 +14,15 @@ package org.jivesoftware.wildfire.server;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.io.XMPPPacketReader; import org.dom4j.io.XMPPPacketReader;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.wildfire.*; import org.jivesoftware.wildfire.*;
import org.jivesoftware.wildfire.auth.AuthFactory; import org.jivesoftware.wildfire.auth.AuthFactory;
import org.jivesoftware.wildfire.net.DNSUtil; import org.jivesoftware.wildfire.net.DNSUtil;
import org.jivesoftware.wildfire.net.SocketConnection;
import org.jivesoftware.wildfire.net.MXParser; import org.jivesoftware.wildfire.net.MXParser;
import org.jivesoftware.wildfire.net.SocketConnection;
import org.jivesoftware.wildfire.spi.BasicStreamIDFactory; import org.jivesoftware.wildfire.spi.BasicStreamIDFactory;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.util.JiveGlobals;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlPullParserFactory;
...@@ -30,7 +30,8 @@ import org.xmpp.packet.JID; ...@@ -30,7 +30,8 @@ import org.xmpp.packet.JID;
import org.xmpp.packet.StreamError; import org.xmpp.packet.StreamError;
import java.io.*; import java.io.*;
import java.net.*; import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
...@@ -432,7 +433,7 @@ class ServerDialback { ...@@ -432,7 +433,7 @@ class ServerDialback {
alreadyExists = true; alreadyExists = true;
} }
} }
if (alreadyExists) { if (alreadyExists && !sessionManager.isMultipleServerConnectionsAllowed()) {
// Remote server already has a IncomingServerSession created // Remote server already has a IncomingServerSession created
connection.deliverRawText( connection.deliverRawText(
new StreamError(StreamError.Condition.not_authorized).toXML()); new StreamError(StreamError.Condition.not_authorized).toXML());
......
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