Commit 936f4683 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Refactored interface properties to use a single propertY (JM-522)

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3329 b35dd754-fafc-0310-a699-88a17e54d16e
parent acb142d2
......@@ -41,6 +41,16 @@
<locale>en</locale>
<!-- Network settings. By default, Wildfire will bind to all network interfaces.
Alternatively, you can specify a specific network interfaces that the server
will listen on. For example, 127.0.0.1. This setting is generally only useful
on multi-homed servers. -->
<!--
<network>
<interface></interface>
</network>
-->
<!-- Example LDAP settings -->
<!--
<ldap>
......
......@@ -24,19 +24,17 @@ import java.util.ArrayList;
public class ServerPort {
private int port;
private String interfaceName;
private ArrayList names;
private ArrayList<String> names;
private String address;
private boolean secure;
private String algorithm;
private Type type;
public ServerPort(int port, String interfaceName, String name, String address,
public ServerPort(int port, String name, String address,
boolean isSecure, String algorithm, Type type)
{
this.port = port;
this.interfaceName = interfaceName;
this.names = new ArrayList(1);
this.names = new ArrayList<String>(1);
this.names.add(name);
this.address = address;
this.secure = isSecure;
......@@ -53,16 +51,12 @@ public class ServerPort {
return port;
}
public String getInterfaceName() {
return interfaceName;
}
/**
* Returns the logical domains for this server port. As multiple
* domains may point to the same server, this helps to define what
* the server considers "local".
*
* @return The server domain name(s) as Strings
* @return the server domain name(s) as Strings.
*/
public Iterator getDomainNames() {
return names.iterator();
......
......@@ -94,7 +94,7 @@ public class AdminConsolePlugin implements Plugin {
// Configure HTTP socket listener. Setting the interface property to a
// non null value will imply that the Jetty server will only
// accept connect requests to that IP address.
String interfaceName = JiveGlobals.getXMLProperty("adminConsole.interface");
String interfaceName = JiveGlobals.getXMLProperty("network.interface");
port = JiveGlobals.getXMLProperty("adminConsole.port", 9090);
InetAddrPort address = new InetAddrPort(interfaceName, port);
if (port > 0) {
......@@ -205,13 +205,13 @@ public class AdminConsolePlugin implements Plugin {
Log.info(warning);
System.out.println(warning);
}
else if (plainListener == null && secureListener != null) {
else if (plainListener == null) {
Log.info(listening + " https://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort);
System.out.println(listening + " https://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + securePort);
}
else if (secureListener == null && plainListener != null) {
else if (secureListener == null) {
Log.info(listening + " http://" +
XMPPServer.getInstance().getServerInfo().getName() + ":" + port);
System.out.println(listening + " http://" +
......
......@@ -15,6 +15,7 @@ import org.jivesoftware.wildfire.ConnectionManager;
import org.jivesoftware.wildfire.ServerPort;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import java.io.IOException;
import java.net.InetAddress;
......@@ -49,11 +50,6 @@ public class SocketAcceptThread extends Thread {
*/
private ServerPort serverPort;
/**
* Interface to bind to.
*/
private InetAddress bindInterface;
/**
* True while this thread should continue running.
*/
......@@ -71,8 +67,9 @@ public class SocketAcceptThread extends Thread {
super("Socket Listener at port " + serverPort.getPort());
this.connManager = connManager;
this.serverPort = serverPort;
String interfaceName = serverPort.getInterfaceName();
bindInterface = null;
// Listen on a specific network interface if it's been set.
String interfaceName = JiveGlobals.getXMLProperty("network.interface");
InetAddress bindInterface = null;
if (interfaceName != null) {
if (interfaceName.trim().length() > 0) {
bindInterface = InetAddress.getByName(interfaceName);
......
......@@ -83,8 +83,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
// Start servers socket unless it's been disabled.
if (isServerListenerEnabled()) {
int port = getServerListenerPort();
String interfaceName = JiveGlobals.getProperty("xmpp.server.socket.interface");
ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress,
ServerPort serverPort = new ServerPort(port, serverName, localIPAddress,
false, null, ServerPort.Type.server);
try {
serverSocketThread = new SocketAcceptThread(this, serverPort);
......@@ -117,8 +116,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
// Start components socket unless it's been disabled.
if (isComponentListenerEnabled()) {
int port = getComponentListenerPort();
String interfaceName = JiveGlobals.getProperty("xmpp.component.socket.interface");
ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress,
ServerPort serverPort = new ServerPort(port, serverName, localIPAddress,
false, null, ServerPort.Type.component);
try {
componentSocketThread = new SocketAcceptThread(this, serverPort);
......@@ -151,8 +149,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
// Start clients plain socket unless it's been disabled.
if (isClientListenerEnabled()) {
int port = getClientListenerPort();
String interfaceName = JiveGlobals.getProperty("xmpp.socket.plain.interface");
ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress,
ServerPort serverPort = new ServerPort(port, serverName, localIPAddress,
false, null, ServerPort.Type.client);
try {
socketThread = new SocketAcceptThread(this, serverPort);
......@@ -185,12 +182,11 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
// Start clients SSL unless it's been disabled.
if (isClientSSLListenerEnabled()) {
int port = getClientSSLListenerPort();
String interfaceName = JiveGlobals.getProperty("xmpp.socket.ssl.interface");
String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm");
if ("".equals(algorithm) || algorithm == null) {
algorithm = "TLS";
}
ServerPort serverPort = new ServerPort(port, interfaceName, serverName, localIPAddress,
ServerPort serverPort = new ServerPort(port, serverName, localIPAddress,
true, algorithm, ServerPort.Type.client);
try {
sslSocketThread = new SSLSocketAcceptThread(this, serverPort);
......
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