fix for bad node flag setting with IPv6

pull/1/head
Michael Peter Christen 11 years ago
parent ae58b22f5b
commit 92c5d97486

@ -1076,26 +1076,37 @@ public class Domains {
return localHostAddresses;
}
/**
* this method is deprecated in some way because it is not applicable on IPv6
* TODO: remove / replace
* @param hostName
* @return
*/
public static boolean isThisHostIP(final String hostName) {
if ((hostName == null) || (hostName.isEmpty())) return false;
if (hostName.indexOf(':') > 0) return false; // IPv6 addresses do not count because they are always host IPs
return isThisHostIP(Domains.dnsResolve(hostName));
}
/**
* this method is deprecated in some way because it is not applicable on IPv6
* TODO: remove / replace
* @param hostName
* @return
*/
public static boolean isThisHostIP(final Set<String> hostNames) {
if ((hostNames == null) || (hostNames.isEmpty())) return false;
for (String hostName: hostNames) {
if (hostName.indexOf(':') > 0) return false; // IPv6 addresses do not count because they are always host IPs
if (isThisHostIP(Domains.dnsResolve(hostName))) return true;
}
return false;
}
public static boolean isThisHostIP(final InetAddress clientAddress) {
if (clientAddress == null) return false;
boolean isThisHostIP = false;
try {
if (clientAddress.isAnyLocalAddress() || clientAddress.isLoopbackAddress()) return true;
for (final InetAddress a: myHostAddresses) {
if (a.equals(clientAddress)) {
isThisHostIP = true;
break;
}
}
} catch (final Exception e) {}
return isThisHostIP;
if (clientAddress.isAnyLocalAddress() || clientAddress.isLoopbackAddress()) return true;
return myHostAddresses.contains(clientAddress);
}
public static int getDomainID(final String host, final InetAddress hostaddress) {

@ -246,8 +246,8 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {
* adds specific header elements for the connection of the internal
* httpclient to the remote server according to local config
*
* @param header header f<EFBFBD><EFBFBD>r http client (already preset with headers from
* original ServletRequest
* @param header header for http client (already preset with headers from
* original ServletRequest)
* @param origServletRequest original request/header
*/
private void setProxyHeaderForClient(final HttpServletRequest origServletRequest, final HeaderFramework header) {

@ -265,7 +265,8 @@ public final class Protocol {
}
mySeed.setFlagRootNode(
(mytype.equals(Seed.PEERTYPE_SENIOR) || mytype.equals(Seed.PEERTYPE_PRINCIPAL)) &&
responseTime < 1000 && Domains.isThisHostIP(mySeed.getIP())
Switchboard.getSwitchboard().index.fulltext().connectedLocalSolr() &&
responseTime < 1000 && Domains.isThisHostIP(mySeed.getIPs())
);
// change our seed-type

Loading…
Cancel
Save