Commit 67730f24 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Enabling or modifying listeners ports does not require a server restart. JM-320


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1583 b35dd754-fafc-0310-a699-88a17e54d16e
parent 657a0189
......@@ -40,4 +40,134 @@ public interface ConnectionManager {
*/
public void addSocket(Socket socket, boolean isSecure, ServerPort serverPort)
throws XmlPullParserException;
/**
* Sets if the port listener for unsecured clients will be available or not. When disabled
* there won't be a port listener active. Therefore, new clients won't be able to connect to
* the server.
*
* @param enabled true if new unsecured clients will be able to connect to the server.
*/
public void enableClientListener(boolean enabled);
/**
* Returns true if the port listener for unsecured clients is available. When disabled
* there won't be a port listener active. Therefore, new clients won't be able to connect to
* the server.
*
* @return true if the port listener for unsecured clients is available.
*/
public boolean isClientListenerEnabled();
/**
* Sets if the port listener for secured clients will be available or not. When disabled
* there won't be a port listener active. Therefore, new secured clients won't be able to
* connect to the server.
*
* @param enabled true if new secured clients will be able to connect to the server.
*/
public void enableClientSSLListener(boolean enabled);
/**
* Returns true if the port listener for secured clients is available. When disabled
* there won't be a port listener active. Therefore, new secured clients won't be able to
* connect to the server.
*
* @return true if the port listener for unsecured clients is available.
*/
public boolean isClientSSLListenerEnabled();
/**
* Sets if the port listener for external components will be available or not. When disabled
* there won't be a port listener active. Therefore, new external components won't be able to
* connect to the server.
*
* @param enabled true if new external components will be able to connect to the server.
*/
public void enableComponentListener(boolean enabled);
/**
* Returns true if the port listener for external components is available. When disabled
* there won't be a port listener active. Therefore, new external components won't be able to
* connect to the server.
*
* @return true if the port listener for external components is available.
*/
public boolean isComponentListenerEnabled();
/**
* Sets if the port listener for remote servers will be available or not. When disabled
* there won't be a port listener active. Therefore, new remote servers won't be able to
* connect to the server.
*
* @param enabled true if new remote servers will be able to connect to the server.
*/
public void enableServerListener(boolean enabled);
/**
* Returns true if the port listener for remote servers is available. When disabled
* there won't be a port listener active. Therefore, new remote servers won't be able to
* connect to the server.
*
* @return true if the port listener for remote servers is available.
*/
public boolean isServerListenerEnabled();
/**
* Sets the port to use for unsecured clients. Default port: 5222.
*
* @param port the port to use for unsecured clients.
*/
public void setClientListenerPort(int port);
/**
* Returns the port to use for unsecured clients. Default port: 5222.
*
* @return the port to use for unsecured clients.
*/
public int getClientListenerPort();
/**
* Sets the port to use for secured clients. Default port: 5223.
*
* @param port the port to use for secured clients.
*/
public void setClientSSLListenerPort(int port);
/**
* Returns the port to use for secured clients. Default port: 5223.
*
* @return the port to use for secured clients.
*/
public int getClientSSLListenerPort();
/**
* Sets the port to use for external components.
*
* @param port the port to use for external components.
*/
public void setComponentListenerPort(int port);
/**
* Returns the port to use for external components.
*
* @return the port to use for external components.
*/
public int getComponentListenerPort();
/**
* Sets the port to use for remote servers. This port is used for remote servers to connect
* to this server. Default port: 5269.
*
* @param port the port to use for remote servers.
*/
public void setServerListenerPort(int port);
/**
* Returns the port to use for remote servers. This port is used for remote servers to connect
* to this server. Default port: 5269.
*
* @return the port to use for remote servers.
*/
public int getServerListenerPort();
}
......@@ -123,17 +123,10 @@ public class XMPPServer {
* @return the server information current at the time of the method call.
*/
public XMPPServerInfo getServerInfo() {
Iterator ports;
if (getConnectionManager() == null) {
ports = Collections.EMPTY_LIST.iterator();
}
else {
ports = getConnectionManager().getPorts();
}
if (!initialized) {
throw new IllegalStateException("Not initialized yet");
}
return new XMPPServerInfoImpl(name, version, startDate, stopDate, ports);
return new XMPPServerInfoImpl(name, version, startDate, stopDate, getConnectionManager());
}
/**
......
......@@ -102,6 +102,15 @@ public class SSLSocketAcceptThread extends Thread {
return serverSocket.getLocalPort();
}
/**
* Returns information about the port on which the server is listening for connections.
*
* @return information about the port on which the server is listening for connections.
*/
public ServerPort getServerPort() {
return serverPort;
}
/**
* Unblock the thread and force it to terminate.
*/
......
......@@ -90,6 +90,15 @@ public class SocketAcceptThread extends Thread {
return serverPort.getPort();
}
/**
* Returns information about the port on which the server is listening for connections.
*
* @return information about the port on which the server is listening for connections.
*/
public ServerPort getServerPort() {
return serverPort;
}
/**
* Unblock the thread and force it to terminate.
*/
......
......@@ -13,10 +13,12 @@ package org.jivesoftware.messenger.spi;
import org.jivesoftware.util.Version;
import org.jivesoftware.messenger.XMPPServerInfo;
import org.jivesoftware.messenger.ConnectionManager;
import org.jivesoftware.util.JiveGlobals;
import java.util.Date;
import java.util.Iterator;
import java.util.Collections;
/**
* Implements the server info for a basic server. Optimization opportunities
......@@ -30,7 +32,7 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
private Date stopDate;
private String name;
private Version ver;
private Iterator ports;
private ConnectionManager connectionManager;
/**
* Simple constructor
......@@ -41,16 +43,16 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
* it hasn't been started).
* @param stopDate the server's last stop time (can be null indicating it
* is running or hasn't been started).
* @param portIter the portIter active on the server.
* @param connectionManager the object that keeps track of the active ports.
*/
public XMPPServerInfoImpl(String serverName, Version version, Date startDate, Date stopDate,
Iterator portIter)
ConnectionManager connectionManager)
{
this.name = serverName;
this.ver = version;
this.startDate = startDate;
this.stopDate = stopDate;
this.ports = portIter;
this.connectionManager = connectionManager;
}
public Version getVersion() {
......@@ -80,6 +82,11 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
}
public Iterator getServerPorts() {
return ports;
if (connectionManager == null) {
return Collections.EMPTY_LIST.iterator();
}
else {
return connectionManager.getPorts();
}
}
}
\ No newline at end of file
......@@ -57,6 +57,7 @@
boolean deleteSuccess = false;
String serverName = XMPPServer.getInstance().getServerInfo().getName();
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
// Update the session kick policy if requested
......@@ -74,11 +75,11 @@
// If no errors, continue:
if (errors.isEmpty()) {
if (!componentEnabled) {
JiveGlobals.setProperty("xmpp.component.socket.active", "false");
connectionManager.enableComponentListener(false);
}
else {
JiveGlobals.setProperty("xmpp.component.socket.active", "true");
JiveGlobals.setProperty("xmpp.component.socket.port", String.valueOf(port));
connectionManager.enableComponentListener(true);
connectionManager.setComponentListenerPort(port);
ExternalComponentManager.setDefaultSecret(defaultSecret);
}
updateSucess = true;
......@@ -131,8 +132,8 @@
// Set page vars
if (errors.size() == 0) {
componentEnabled = JiveGlobals.getBooleanProperty("xmpp.component.socket.active", true);
port = JiveGlobals.getIntProperty("xmpp.component.socket.port", SocketAcceptThread.DEFAULT_COMPONENT_PORT);
componentEnabled = connectionManager.isComponentListenerEnabled();
port = connectionManager.getComponentListenerPort();
defaultSecret = ExternalComponentManager.getDefaultSecret();
permissionFilter = ExternalComponentManager.getPermissionPolicy().toString();
subdomain = "";
......@@ -140,7 +141,7 @@
}
else {
if (port == 0) {
port = JiveGlobals.getIntProperty("xmpp.component.socket.port", SocketAcceptThread.DEFAULT_COMPONENT_PORT);
port = connectionManager.getComponentListenerPort();
}
if (defaultSecret == null) {
defaultSecret = ExternalComponentManager.getDefaultSecret();
......@@ -291,22 +292,22 @@
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="<%= ExternalComponentManager.PermissionPolicy.blacklist %>" id="rb01"
<input type="radio" name="permissionFilter" value="<%= ExternalComponentManager.PermissionPolicy.blacklist %>" id="rb03"
<%= (ExternalComponentManager.PermissionPolicy.blacklist.toString().equals(permissionFilter) ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb01">
<label for="rb03">
<b><fmt:message key="component.settings.anyone" /></b> - <fmt:message key="component.settings.anyone_info" />
</label>
</td>
</tr>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="<%= ExternalComponentManager.PermissionPolicy.whitelist %>" id="rb02"
<input type="radio" name="permissionFilter" value="<%= ExternalComponentManager.PermissionPolicy.whitelist %>" id="rb04"
<%= (ExternalComponentManager.PermissionPolicy.whitelist.toString().equals(permissionFilter) ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb02">
<label for="rb04">
<b><fmt:message key="component.settings.whitelist" /></b> - <fmt:message key="component.settings.whitelist_info" />
</label>
</td>
......
......@@ -18,7 +18,8 @@
java.net.InetAddress,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.messenger.net.SSLSocketAcceptThread,
org.jivesoftware.messenger.net.SocketAcceptThread"
org.jivesoftware.messenger.net.SocketAcceptThread,
org.jivesoftware.messenger.ConnectionManager"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
......@@ -62,6 +63,7 @@
}
XMPPServer server = admin.getXMPPServer();
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
Map errors = new HashMap();
if (save) {
if (serverName == null) {
......@@ -96,25 +98,40 @@
}
}
if (errors.size() == 0) {
boolean needRestart = false;
if (!serverName.equals(server.getServerInfo().getName())) {
server.getServerInfo().setName(serverName);
JiveGlobals.setProperty("xmpp.socket.plain.port", String.valueOf(port));
JiveGlobals.setProperty("xmpp.socket.ssl.active", String.valueOf(sslEnabled));
JiveGlobals.setProperty("xmpp.socket.ssl.port", String.valueOf(sslPort));
JiveGlobals.setProperty("xmpp.component.socket.port", String.valueOf(componentPort));
JiveGlobals.setProperty("xmpp.server.socket.port", String.valueOf(serverPort));
needRestart = true;
}
connectionManager.setClientListenerPort(port);
connectionManager.enableClientSSLListener(sslEnabled);
connectionManager.setClientSSLListenerPort(sslPort);
connectionManager.setComponentListenerPort(componentPort);
connectionManager.setServerListenerPort(serverPort);
if (!String.valueOf(embeddedPort).equals(JiveGlobals.getXMLProperty("adminConsole.port"))) {
JiveGlobals.setXMLProperty("adminConsole.port", String.valueOf(embeddedPort));
needRestart = true;
}
if (!String.valueOf(embeddedSecurePort).equals(JiveGlobals.getXMLProperty("adminConsole.securePort"))) {
JiveGlobals.setXMLProperty("adminConsole.securePort", String.valueOf(embeddedSecurePort));
needRestart = true;
}
if (needRestart) {
response.sendRedirect("server-props.jsp?success=true&restart=true");
}
else {
response.sendRedirect("server-props.jsp?success=true");
}
return;
}
}
else {
serverName = server.getServerInfo().getName();
sslEnabled = "true".equals(JiveGlobals.getProperty("xmpp.socket.ssl.active"));
try { port = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.plain.port", String.valueOf(SocketAcceptThread.DEFAULT_PORT))); } catch (Exception ignored) {}
try { sslPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.ssl.port", String.valueOf(SSLSocketAcceptThread.DEFAULT_PORT))); } catch (Exception ignored) {}
try { componentPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.component.socket.port", String.valueOf(SocketAcceptThread.DEFAULT_COMPONENT_PORT))); } catch (Exception ignored) {}
try { serverPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.server.socket.port", String.valueOf(SocketAcceptThread.DEFAULT_SERVER_PORT))); } catch (Exception ignored) {}
sslEnabled = connectionManager.isClientSSLListenerEnabled();
port = connectionManager.getClientListenerPort();
sslPort = connectionManager.getClientSSLListenerPort();
componentPort = connectionManager.getComponentListenerPort();
serverPort = connectionManager.getServerListenerPort();
try { embeddedPort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.port")); } catch (Exception ignored) {}
try { embeddedSecurePort = Integer.parseInt(JiveGlobals.getXMLProperty("adminConsole.securePort")); } catch (Exception ignored) {}
}
......@@ -148,7 +165,11 @@
<tbody>
<tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
<% if ("true".equals(request.getParameter("restart"))) { %>
<fmt:message key="server.props.update" /> <b><fmt:message key="global.restart" /></b> <fmt:message key="server.props.update2" /> <a href="index.jsp"><fmt:message key="global.server_status" /></a>).
<% } else { %>
<fmt:message key="server.props.update.norestart" />.
<% } %>
</td></tr>
</tbody>
</table>
......
......@@ -19,7 +19,8 @@
java.text.DateFormat,
org.jivesoftware.admin.AdminPageBean,
org.jivesoftware.messenger.server.RemoteServerManager,
org.jivesoftware.messenger.server.RemoteServerConfiguration"
org.jivesoftware.messenger.server.RemoteServerConfiguration,
org.jivesoftware.messenger.component.ExternalComponentManager"
errorPage="error.jsp"
%>
......@@ -27,6 +28,9 @@
<% admin.init(request, response, session, application, out ); %>
<% // Get parameters
boolean update = request.getParameter("update") != null;
boolean s2sEnabled = ParamUtils.getBooleanParameter(request,"s2sEnabled");
int port = ParamUtils.getIntParameter(request,"port", 0);
boolean closeEnabled = ParamUtils.getBooleanParameter(request,"closeEnabled");
String idletime = ParamUtils.getParameter(request,"idletime");
boolean closeSettings = request.getParameter("closeSettings") != null;
......@@ -45,8 +49,29 @@
// Get muc server
SessionManager sessionManager = admin.getSessionManager();
ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
Map errors = new HashMap();
if (update) {
// Validate params
if (s2sEnabled) {
if (port <= 0) {
errors.put("port","");
}
}
// If no errors, continue:
if (errors.isEmpty()) {
if (!s2sEnabled) {
connectionManager.enableServerListener(false);
}
else {
connectionManager.enableServerListener(true);
connectionManager.setServerListenerPort(port);
}
updateSucess = true;
}
}
// Handle an update of the kicking task settings
if (closeSettings) {
if (!closeEnabled) {
......@@ -131,11 +156,16 @@
// Set page vars
if (errors.size() == 0) {
s2sEnabled = connectionManager.isServerListenerEnabled();
port = connectionManager.getServerListenerPort();
permissionFilter = RemoteServerManager.getPermissionPolicy().toString();
domain = "";
remotePort = "0";
}
else {
if (port == 0) {
port = connectionManager.getServerListenerPort();
}
if (permissionFilter == null) {
permissionFilter = RemoteServerManager.getPermissionPolicy().toString();
}
......@@ -217,6 +247,65 @@
<% } %>
<form action="server2server-settings.jsp" method="post">
<fieldset>
<legend><fmt:message key="server2server.settings.enabled.legend" /></legend>
<div>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="s2sEnabled" value="false" id="rb01"
<%= (!s2sEnabled ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb01">
<b><fmt:message key="server2server.settings.label_disable" /></b> - <fmt:message key="server2server.settings.label_disable_info" />
</label>
</td>
</tr>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="s2sEnabled" value="true" id="rb02"
<%= (s2sEnabled ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb02">
<b><fmt:message key="server2server.settings.label_enable" /></b> - <fmt:message key="server2server.settings.label_enable_info" />
</label>
</td>
</tr>
<tr valign="top">
<td width="1%" nowrap>
&nbsp;
</td>
<td width="99%">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr valign="top">
<td width="1%" nowrap class="c1">
<fmt:message key="server2server.settings.port" />
</td>
<td width="99%">
<input type="text" size="15" maxlength="50" name="port"
value="<%= port %>">
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
<br>
<input type="submit" name="update" value="<fmt:message key="global.save_settings" />">
</form>
<br>
<form action="server2server-settings.jsp?closeSettings" method="post">
<fieldset>
......@@ -226,20 +315,20 @@
<tbody>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="closeEnabled" value="false" id="rb01"
<input type="radio" name="closeEnabled" value="false" id="rb03"
<%= ((admin.getSessionManager().getServerSessionIdleTime() < 0) ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb01"><fmt:message key="server2server.settings.never_close" /></label>
<label for="rb03"><fmt:message key="server2server.settings.never_close" /></label>
</td>
</tr>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="closeEnabled" value="true" id="rb02"
<input type="radio" name="closeEnabled" value="true" id="rb04"
<%= ((admin.getSessionManager().getServerSessionIdleTime() > -1) ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb02"><fmt:message key="server2server.settings.close_session" /></label>
<label for="rb04"><fmt:message key="server2server.settings.close_session" /></label>
<input type="text" name="idletime" size="5" maxlength="5"
onclick="this.form.closeEnabled[1].checked=true;"
value="<%= admin.getSessionManager().getServerSessionIdleTime() == -1 ? 30 : admin.getSessionManager().getServerSessionIdleTime() / 1000 / 60 %>">
......@@ -268,22 +357,22 @@
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="<%= RemoteServerManager.PermissionPolicy.blacklist %>" id="rb01"
<input type="radio" name="permissionFilter" value="<%= RemoteServerManager.PermissionPolicy.blacklist %>" id="rb05"
<%= (RemoteServerManager.PermissionPolicy.blacklist.toString().equals(permissionFilter) ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb01">
<label for="rb05">
<b><fmt:message key="server2server.settings.anyone" /></b> - <fmt:message key="server2server.settings.anyone_info" />
</label>
</td>
</tr>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="permissionFilter" value="<%= RemoteServerManager.PermissionPolicy.whitelist %>" id="rb02"
<input type="radio" name="permissionFilter" value="<%= RemoteServerManager.PermissionPolicy.whitelist %>" id="rb06"
<%= (RemoteServerManager.PermissionPolicy.whitelist.toString().equals(permissionFilter) ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb02">
<label for="rb06">
<b><fmt:message key="server2server.settings.whitelist" /></b> - <fmt:message key="server2server.settings.whitelist_info" />
</label>
</td>
......
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