Skip to content

Commit

Permalink
- add ip6-localhost to localhostips
Browse files Browse the repository at this point in the history
- additionally let WOHostUtilities automatically add all IPs from all interfaces
  through property er.extensions.WOHostUtilities.autoaddlocalhostips=true
  • Loading branch information
btriller committed Nov 19, 2012
1 parent 34563d4 commit 19ccfd4
Showing 1 changed file with 29 additions and 0 deletions.
@@ -1,6 +1,9 @@
package com.webobjects.appserver._private;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;

import org.apache.log4j.Logger;

Expand Down Expand Up @@ -33,6 +36,9 @@
* not deny management requests from wotaskd instances that are running on any of the list of supplemental ip addresses
* that you provide</p>
*
* <p>Alternatively you can set <code>er.extensions.WOHostUtilities.autoaddlocalhostips=true</code>
* to automatically add all addresses, that are not link-local.</p>
*
* @author Miguel Arroz (survs.com)
*
*/
Expand Down Expand Up @@ -70,6 +76,13 @@ static NSArray initLocalHosts()
} catch (Exception localException3) {
NSLog.err.appendln("<WOHostUtilities>: Couldn't get InetAddress for '127.0.0.1': " + localException3);
}
try
{
InetAddress[] arrayOfInetAddress2 = InetAddress.getAllByName("[::1]");
_addInetAddressArray(arrayOfInetAddress2, localNSMutableArray);
} catch (Exception localException3) {
NSLog.err.appendln("<WOHostUtilities>: Couldn't get InetAddress for '[::1]': " + localException3);
}

NSArray<String> ips = ERXProperties.arrayForKey( LOCALHOST_IPS_PROPERTY_KEY );

Expand All @@ -85,6 +98,22 @@ static NSArray initLocalHosts()
}
}

if (ERXProperties.booleanForKeyWithDefault("er.extensions.WOHostUtilities.autoaddlocalhostips", false)) {
try {
for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements();) {
for (Enumeration<InetAddress> addresses = ifaces.nextElement().getInetAddresses(); addresses.hasMoreElements();) {
InetAddress addr = addresses.nextElement();
if(addr.isLinkLocalAddress())
continue;
_addInetAddress(addr, localNSMutableArray);
}
}
}
catch (SocketException e1) {
log.error("Could not get interface list");
}
}

int i = localNSMutableArray.count();
for (int j = 0; j < i; ++j) {
InetAddress localInetAddress2 = (InetAddress)localNSMutableArray.objectAtIndex(j);
Expand Down

0 comments on commit 19ccfd4

Please sign in to comment.