From 19ccfd4b359a93bf5998e267eaab34e986eff842 Mon Sep 17 00:00:00 2001 From: Bastian Triller Date: Mon, 19 Nov 2012 12:14:35 +0100 Subject: [PATCH] - add ip6-localhost to localhostips - additionally let WOHostUtilities automatically add all IPs from all interfaces through property er.extensions.WOHostUtilities.autoaddlocalhostips=true --- .../appserver/_private/WOHostUtilities.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Frameworks/Core/ERExtensions/Sources/com/webobjects/appserver/_private/WOHostUtilities.java b/Frameworks/Core/ERExtensions/Sources/com/webobjects/appserver/_private/WOHostUtilities.java index 38c279957da..f6ebb2aa27f 100644 --- a/Frameworks/Core/ERExtensions/Sources/com/webobjects/appserver/_private/WOHostUtilities.java +++ b/Frameworks/Core/ERExtensions/Sources/com/webobjects/appserver/_private/WOHostUtilities.java @@ -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; @@ -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

* + *

Alternatively you can set er.extensions.WOHostUtilities.autoaddlocalhostips=true + * to automatically add all addresses, that are not link-local.

+ * * @author Miguel Arroz (survs.com) * */ @@ -70,6 +76,13 @@ static NSArray initLocalHosts() } catch (Exception localException3) { NSLog.err.appendln(": 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(": Couldn't get InetAddress for '[::1]': " + localException3); + } NSArray ips = ERXProperties.arrayForKey( LOCALHOST_IPS_PROPERTY_KEY ); @@ -85,6 +98,22 @@ static NSArray initLocalHosts() } } + if (ERXProperties.booleanForKeyWithDefault("er.extensions.WOHostUtilities.autoaddlocalhostips", false)) { + try { + for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements();) { + for (Enumeration 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);