Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix for http://bugs.yacy.net/view.php?id=42
orbitera65ecffef6d6
diff --git a/htroot/SettingsAck_p.html b/htroot/SettingsAck_p.htmlindex 79d8f0be6..73ca05cb5 100644--- a/htroot/SettingsAck_p.html+++ b/htroot/SettingsAck_p.html@@ -28,7 +28,7 @@::<!-- 6 --><p><strong>Your proxy access setting has been changed.<br />- Your proxy account check has been disabled, since you did not supply a password.</strong>+ Your proxy account check has been disabled.</strong>The new proxy IP filter is set to <span class="settingsValue">#[filter]#</span><br />The proxy port is: <span class="settingsValue">#[port]#</span>#(restart)#diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.javaindex 5dcdb3998..7d6fd0277 100644--- a/htroot/SettingsAck_p.java+++ b/htroot/SettingsAck_p.java@@ -41,9 +41,8 @@ import net.yacy.cora.protocol.RequestHeader;import net.yacy.kelondro.order.Base64Order;import net.yacy.kelondro.order.Digest;import net.yacy.kelondro.util.Formatter;--import de.anomic.http.server.HTTPDemon;import de.anomic.http.server.HTTPDProxyHandler;+import de.anomic.http.server.HTTPDemon;import de.anomic.search.Switchboard;import de.anomic.search.SwitchboardConstants;import de.anomic.server.serverCore;@@ -55,24 +54,24 @@ import de.anomic.yacy.yacySeed;import de.anomic.yacy.yacySeedUploader;public class SettingsAck_p {-+private static boolean nothingChanged = false;-+public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {// return variable that accumulates replacementsfinal serverObjects prop = new serverObjects();final Switchboard sb = (Switchboard) env;-+// get referer for backlinkfinal MultiProtocolURI referer = header.referer();- prop.put("referer", (referer == null) ? "Settings_p.html" : referer.toNormalform(true, true));+ prop.put("referer", (referer == null) ? "Settings_p.html" : referer.toNormalform(true, true));//if (post == null) System.out.println("POST: NULL"); else System.out.println("POST: " + post.toString());-+if (post == null) {prop.put("info", "1");//no information submittedreturn prop;}-+// admin passwordif (post.containsKey("adminaccount")) {// read and process data@@ -99,11 +98,11 @@ public class SettingsAck_p {prop.putHTML("info_user", user);return prop;}--++// proxy passwordif (post.containsKey("proxyaccount")) {- /*+ /** set new port*/final String port = post.get("port");@@ -117,10 +116,10 @@ public class SettingsAck_p {prop.put("info_restart", "1");prop.put("info_restart_ip",(hostName.equals("0.0.0.0"))? "localhost" : hostName);prop.put("info_restart_port", theNewAddress.getPort());-+env.setConfig("port", port);-- theServerCore.reconnect(5000);++ theServerCore.reconnect(5000);} catch (final SocketException e) {prop.put("info", "26");return prop;@@ -128,12 +127,12 @@ public class SettingsAck_p {} else {prop.put("info_restart", "0");}-+// read and process dataString filter = (post.get("proxyfilter")).trim();final boolean useProxyAccounts = post.containsKey("use_proxyaccounts") && post.get("use_proxyaccounts").equals("on");// do checks- if ((filter == null) || (!post.containsKey("use_proxyaccounts"))) {+ if (filter == null) {prop.put("info", "1");//error with submitted informationreturn prop;}@@ -145,14 +144,14 @@ public class SettingsAck_p {prop.put("info", 3);//pw check failedreturn prop;}*/-+if (filter.length() == 0) filter = "*";else if (!filter.equals("*")){- // testing proxy filter+ // testing proxy filterint patternCount = 0;String patternStr = null;try {- final StringTokenizer st = new StringTokenizer(filter,",");+ final StringTokenizer st = new StringTokenizer(filter,",");while (st.hasMoreTokens()) {patternCount++;patternStr = st.nextToken();@@ -167,7 +166,7 @@ public class SettingsAck_p {return prop;}}-+// check passed. set account:env.setConfig("proxyClient", filter);env.setConfig("use_proxyAccounts", useProxyAccounts);@@ -181,32 +180,32 @@ public class SettingsAck_p {}return prop;}-+// http networkingif (post.containsKey("httpNetworking")) {-+// set transparent proxy flagHTTPDProxyHandler.isTransparentProxy = post.containsKey("isTransparentProxy");env.setConfig("isTransparentProxy", HTTPDProxyHandler.isTransparentProxy);prop.put("info_isTransparentProxy", HTTPDProxyHandler.isTransparentProxy ? "on" : "off");-+// setting the keep alive propertyHTTPDemon.keepAliveSupport = post.containsKey("connectionKeepAliveSupport");env.setConfig("connectionKeepAliveSupport", HTTPDemon.keepAliveSupport);- prop.put("info_connectionKeepAliveSupport", HTTPDemon.keepAliveSupport ? "on" : "off");-+ prop.put("info_connectionKeepAliveSupport", HTTPDemon.keepAliveSupport ? "on" : "off");+// setting via header propertyenv.setConfig("proxy.sendViaHeader", post.containsKey("proxy.sendViaHeader"));prop.put("info_proxy.sendViaHeader", post.containsKey("proxy.sendViaHeader")? "on" : "off");-+// setting X-Forwarded-for header propertyenv.setConfig("proxy.sendXForwardedForHeader", post.containsKey("proxy.sendXForwardedForHeader"));- prop.put("info_proxy.sendXForwardedForHeader", post.containsKey("proxy.sendXForwardedForHeader")? "on" : "off");-+ prop.put("info_proxy.sendXForwardedForHeader", post.containsKey("proxy.sendXForwardedForHeader")? "on" : "off");+prop.put("info", "20");return prop;}-+// server accessif (post.containsKey("serveraccount")) {@@ -250,7 +249,7 @@ public class SettingsAck_p {}*/if (filter.length() == 0) filter = "*";else if (!filter.equals("*")){- // testing proxy filter+ // testing proxy filterint patternCount = 0;String patternStr = null;try {@@ -268,35 +267,35 @@ public class SettingsAck_p {prop.putHTML("info_pattern", patternStr);return prop;}- }-+ }+// check passed. set account:env.setConfig("serverClient", filter);-+prop.put("info", "8");//server access filter updated//prop.put("info_user", user);prop.putHTML("info_filter", filter);return prop;}-+if (post.containsKey("proxysettings")) {-+/* ====================================================================- * Reading out the remote proxy settings+ * Reading out the remote proxy settings* ==================================================================== */final boolean useRemoteProxy = post.containsKey("remoteProxyUse");final boolean useRemoteProxy4Yacy = post.containsKey("remoteProxyUse4Yacy");final boolean useRemoteProxy4SSL = post.containsKey("remoteProxyUse4SSL");-+final String remoteProxyHost = post.get("remoteProxyHost", "");final int remoteProxyPort = post.getInt("remoteProxyPort", 3128);-+final String remoteProxyUser = post.get("remoteProxyUser", "");final String remoteProxyPwd = post.get("remoteProxyPwd", "");-+final String remoteProxyNoProxyStr = post.get("remoteProxyNoProxy", "");//String[] remoteProxyNoProxyPatterns = remoteProxyNoProxyStr.split(",");-+/* ====================================================================* Storing settings into config file* ==================================================================== */@@ -308,20 +307,20 @@ public class SettingsAck_p {env.setConfig("remoteProxyUse", useRemoteProxy);env.setConfig("remoteProxyUse4Yacy", useRemoteProxy4Yacy);env.setConfig("remoteProxyUse4SSL", useRemoteProxy4SSL);-+/* ====================================================================* Enabling settings* ==================================================================== */- sb.initRemoteProxy();-+ sb.initRemoteProxy();+prop.put("info", "15"); // The remote-proxy setting has been changedreturn prop;}-+if (post.containsKey("seedUploadRetry")) {String error;if ((error = yacyCore.saveSeedList(sb)) == null) {- // trying to upload the seed-list file+ // trying to upload the seed-list fileprop.put("info", "13");prop.put("info_success", "1");} else {@@ -331,24 +330,24 @@ public class SettingsAck_p {}return prop;}-+if (post.containsKey("seedSettings")) {// get the currently used uploading methodfinal String oldSeedUploadMethod = env.getConfig("seedUploadMethod","none");final String newSeedUploadMethod = post.get("seedUploadMethod");final String oldSeedURLStr = sb.peers.mySeed().get(yacySeed.SEEDLISTURL, "");final String newSeedURLStr = post.get("seedURL");-+final boolean seedUrlChanged = !oldSeedURLStr.equals(newSeedURLStr);boolean uploadMethodChanged = !oldSeedUploadMethod.equals(newSeedUploadMethod);if (uploadMethodChanged) {uploadMethodChanged = yacyCore.changeSeedUploadMethod(newSeedUploadMethod);}-+if (seedUrlChanged || uploadMethodChanged) {env.setConfig("seedUploadMethod", newSeedUploadMethod);sb.peers.mySeed().put(yacySeed.SEEDLISTURL, newSeedURLStr);-+// try an uploadString error;if ((error = yacyCore.saveSeedList(sb)) == null) {@@ -365,41 +364,41 @@ public class SettingsAck_p {return prop;}}-- /*- * Loop through the available seed uploaders to see if the- * configuration of one of them has changed++ /*+ * Loop through the available seed uploaders to see if the+ * configuration of one of them has changed*/final HashMap<String, String> uploaders = yacyCore.getSeedUploadMethods();final Iterator<String> uploaderKeys = uploaders.keySet().iterator();while (uploaderKeys.hasNext()) {// get the uploader module namefinal String uploaderName = uploaderKeys.next();--++// determining if the user has reconfigured the settings of this uploaderif (post.containsKey("seed" + uploaderName + "Settings")) {nothingChanged = true;final yacySeedUploader theUploader = yacyCore.getSeedUploader(uploaderName);final String[] configOptions = theUploader.getConfigurationOptions();if (configOptions != null) {- for (int i=0; i<configOptions.length; i++) {- final String newSettings = post.get(configOptions[i],"");- final String oldSettings = env.getConfig(configOptions[i],"");+ for (final String configOption : configOptions) {+ final String newSettings = post.get(configOption,"");+ final String oldSettings = env.getConfig(configOption,"");// bitwise AND with boolean is same as logic AND- nothingChanged &= newSettings.equals(oldSettings);+ nothingChanged &= newSettings.equals(oldSettings);if (!nothingChanged) {- env.setConfig(configOptions[i],newSettings);+ env.setConfig(configOption,newSettings);}}- }+ }if (!nothingChanged) {// if the seed upload method is equal to the seed uploader whose settings// were changed, we now try to upload the seed list with the new settingsif (env.getConfig("seedUploadMethod","none").equalsIgnoreCase(uploaderName)) {String error;if ((error = yacyCore.saveSeedList(sb)) == null) {-+// we have successfully uploaded the seed fileprop.put("info", "13");prop.put("info_success", "1");@@ -407,8 +406,8 @@ public class SettingsAck_p {// if uploading failed we print out an error messageprop.put("info", "14");prop.putHTML("info_errormsg",error.replaceAll("\n","<br>"));- env.setConfig("seedUploadMethod","none");- }+ env.setConfig("seedUploadMethod","none");+ }} else {prop.put("info", "13");prop.put("info_success", "0");@@ -418,9 +417,9 @@ public class SettingsAck_p {prop.put("info_success", "0");}return prop;- }+ }}-+/** Message forwarding configuration*/@@ -428,22 +427,22 @@ public class SettingsAck_p {env.setConfig("msgForwardingEnabled", post.containsKey("msgForwardingEnabled"));env.setConfig("msgForwardingCmd", post.get("msgForwardingCmd"));env.setConfig("msgForwardingTo", post.get("msgForwardingTo"));-+prop.put("info", "21");prop.put("info_msgForwardingEnabled", post.containsKey("msgForwardingEnabled") ? "on" : "off");prop.putHTML("info_msgForwardingCmd", post.get("msgForwardingCmd"));prop.putHTML("info_msgForwardingTo", post.get("msgForwardingTo"));-+return prop;}-+// Crawler settingsif (post.containsKey("crawlerSettings")) {-+// get Crawler TimeoutString timeoutStr = post.get("crawler.clientTimeout");if (timeoutStr==null||timeoutStr.length()==0) timeoutStr = "10000";-+int crawlerTimeout;try {crawlerTimeout = Integer.parseInt(timeoutStr);@@ -454,11 +453,11 @@ public class SettingsAck_p {prop.putHTML("info_crawler.clientTimeout",post.get("crawler.clientTimeout"));return prop;}-+// get maximum http file sizeString maxSizeStr = post.get("crawler.http.maxFileSize");if (maxSizeStr==null||maxSizeStr.length()==0) maxSizeStr = "-1";-+long maxHttpSize;try {maxHttpSize = Integer.parseInt(maxSizeStr);@@ -471,11 +470,11 @@ public class SettingsAck_p {prop.putHTML("info_crawler.http.maxFileSize",post.get("crawler.http.maxFileSize"));return prop;}-+// get maximum ftp file sizemaxSizeStr = post.get("crawler.ftp.maxFileSize");if (maxSizeStr==null||maxSizeStr.length()==0) maxSizeStr = "-1";-+long maxFtpSize;try {maxFtpSize = Integer.parseInt(maxSizeStr);@@ -484,11 +483,11 @@ public class SettingsAck_p {prop.put("info", "31");prop.putHTML("info_crawler.ftp.maxFileSize",post.get("crawler.ftp.maxFileSize"));return prop;- }-+ }+maxSizeStr = post.get("crawler.smb.maxFileSize");if (maxSizeStr==null||maxSizeStr.length()==0) maxSizeStr = "-1";-+long maxSmbSize;try {maxSmbSize = Integer.parseInt(maxSizeStr);@@ -497,11 +496,11 @@ public class SettingsAck_p {prop.put("info", "31");prop.putHTML("info_crawler.smb.maxFileSize",post.get("crawler.smb.maxFileSize"));return prop;- }-+ }+maxSizeStr = post.get("crawler.file.maxFileSize");if (maxSizeStr==null||maxSizeStr.length()==0) maxSizeStr = "-1";-+long maxFileSize;try {maxFileSize = Integer.parseInt(maxSizeStr);@@ -510,8 +509,8 @@ public class SettingsAck_p {prop.put("info", "31");prop.putHTML("info_crawler.file.maxFileSize",post.get("crawler.file.maxFileSize"));return prop;- }-+ }+// everything is okprop.put("info_crawler.clientTimeout",(crawlerTimeout==0) ? "0" :yacyPeerActions.formatInterval(crawlerTimeout));prop.put("info_crawler.http.maxFileSize",(maxHttpSize==-1)? "-1":Formatter.bytesToString(maxHttpSize));@@ -521,11 +520,11 @@ public class SettingsAck_p {prop.put("info", "28");return prop;}--++// nothing madeprop.put("info", "1");//no information submittedreturn prop;}-+}