diff --git a/src/conf/manager.xml b/src/conf/manager.xml index 48041cb..fd1a883 100644 --- a/src/conf/manager.xml +++ b/src/conf/manager.xml @@ -16,6 +16,9 @@ + + 5262 @@ -56,6 +59,7 @@ + true 5222 diff --git a/src/java/org/jivesoftware/multiplexer/ConnectionManager.java b/src/java/org/jivesoftware/multiplexer/ConnectionManager.java index 534d0c8..86c4b20 100644 --- a/src/java/org/jivesoftware/multiplexer/ConnectionManager.java +++ b/src/java/org/jivesoftware/multiplexer/ConnectionManager.java @@ -290,8 +290,10 @@ } private void startClientListeners(String localIPAddress) { - // TODO Does MINA uses MAX_PRIORITY for threads? - // TODO Are threads running as daemon? Can we stop de server? + if (!JiveGlobals.getBooleanProperty("xmpp.socket.default.active", true)) { + // Do not start listener if service is disabled + return; + } // Start clients plain socket unless it's been disabled. int port = getClientListenerPort(); // Create SocketAcceptor with correct number of processors @@ -339,6 +341,10 @@ } private void startClientSSLListeners(String localIPAddress) { + if (!JiveGlobals.getBooleanProperty("xmpp.socket.ssl.active", true)) { + // Do not start listener if service is disabled + return; + } // Start clients SSL unless it's been disabled. int port = JiveGlobals.getIntProperty("xmpp.socket.ssl.port", 5223); String algorithm = JiveGlobals.getXMLProperty("xmpp.socket.ssl.algorithm"); diff --git a/src/java/org/jivesoftware/multiplexer/ConnectionWorkerThread.java b/src/java/org/jivesoftware/multiplexer/ConnectionWorkerThread.java index 6fc0d2f..7a59c06 100644 --- a/src/java/org/jivesoftware/multiplexer/ConnectionWorkerThread.java +++ b/src/java/org/jivesoftware/multiplexer/ConnectionWorkerThread.java @@ -26,6 +26,7 @@ import org.xmlpull.v1.XmlPullParser; import javax.net.ssl.SSLHandshakeException; +import java.io.IOException; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -119,26 +120,43 @@ /** * Creates a new connection to the server + * + * @return true if a connection to the server was established */ private boolean createConnection() { String realHostname = null; int port = JiveGlobals.getIntProperty("xmpp.port", DEFAULT_MULTIPLEX_PORT); Socket socket = new Socket(); - try { - // Get the real hostname to connect to using DNS lookup of the specified hostname - DNSUtil.HostAddress address = DNSUtil.resolveXMPPServerDomain(serverName, port); - realHostname = address.getHost(); - Log.debug("CM - Trying to connect to " + serverName + ":" + port + - "(DNS lookup: " + realHostname + ":" + port + ")"); - // Establish a TCP connection to the Receiving Server - socket.connect(new InetSocketAddress(realHostname, port), 20000); - Log.debug("CM - Plain connection to " + serverName + ":" + port + " successful"); + if (JiveGlobals.getXMLProperty("xmpp.hostname") != null) { + String hostname = JiveGlobals.getXMLProperty("xmpp.hostname"); + // Use the specified hostname and port to connect to the server + try { + Log.debug("CM - Trying to connect to server at " + hostname + ":" + port); + // Establish a TCP connection to the Receiving Server + socket.connect(new InetSocketAddress(hostname, port), 20000); + Log.debug("CM - Plain connection to server at " + hostname + ":" + port + " successful"); + } catch (IOException e) { + Log.error("Error trying to connect to server at " + hostname + ":" + port, e); + return false; + } } - catch (Exception e) { - Log.error("Error trying to connect to server: " + serverName + - "(DNS lookup: " + realHostname + ":" + port + ")", e); - return false; + else { + try { + // Get the real hostname to connect to using DNS lookup of the specified hostname + DNSUtil.HostAddress address = DNSUtil.resolveXMPPServerDomain(serverName, port); + realHostname = address.getHost(); + Log.debug("CM - Trying to connect to " + serverName + ":" + port + + "(DNS lookup: " + realHostname + ":" + port + ")"); + // Establish a TCP connection to the Receiving Server + socket.connect(new InetSocketAddress(realHostname, port), 20000); + Log.debug("CM - Plain connection to " + serverName + ":" + port + " successful"); + } + catch (Exception e) { + Log.error("Error trying to connect to server: " + serverName + + "(DNS lookup: " + realHostname + ":" + port + ")", e); + return false; + } } try {