Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
allo 'authorization by encoded password' also if requesting client is not from localhost but from the same host as yacy is running on.
orbiter617dfbbd0637
diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.javaindex 34f63c569..61434ece6 100644--- a/source/de/anomic/search/Switchboard.java+++ b/source/de/anomic/search/Switchboard.java@@ -41,7 +41,9 @@ import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.io.UnsupportedEncodingException;+import java.net.InetAddress;import java.net.MalformedURLException;+import java.net.UnknownHostException;import java.security.NoSuchAlgorithmException;import java.security.PublicKey;import java.security.spec.InvalidKeySpecException;@@ -1823,7 +1825,12 @@ public final class Switchboard extends serverSwitch {// authorization for localhost, only if flag is set to grant localhost access as adminfinal String clientIP = requestHeader.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "");final String refererHost = requestHeader.refererHost();- final boolean accessFromLocalhost = serverCore.isLocalhost(clientIP) && (refererHost.length() == 0 || serverCore.isLocalhost(refererHost));+ boolean accessFromLocalhost = serverCore.isLocalhost(clientIP) && (refererHost.length() == 0 || serverCore.isLocalhost(refererHost));+ if (!accessFromLocalhost) try {+ // the access may also be from a different IP than localhost if it is the same as the YaCy instance is running on+ InetAddress myaddress = InetAddress.getLocalHost();+ accessFromLocalhost = myaddress.equals(InetAddress.getByName(clientIP)) && (refererHost.length() == 0 || myaddress.equals(InetAddress.getByName(refererHost)));+ } catch (UnknownHostException e) {}if (getConfigBool("adminAccountForLocalhost", false) && accessFromLocalhost) return 3; // soft-authenticated for localhost// get the authorization string from the header