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