|
|
|
@ -70,9 +70,10 @@ public class Status {
|
|
|
|
|
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
|
|
|
|
// return variable that accumulates replacements
|
|
|
|
|
final serverObjects prop = new serverObjects();
|
|
|
|
|
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
|
|
|
|
|
|
|
|
|
|
if ((post != null) && (post.containsKey("login"))) {
|
|
|
|
|
if (((plasmaSwitchboard) env).adminAuthenticated(header) < 2) {
|
|
|
|
|
if (sb.adminAuthenticated(header) < 2) {
|
|
|
|
|
prop.put("AUTHENTICATE","admin log-in");
|
|
|
|
|
} else {
|
|
|
|
|
prop.put("LOCATION","");
|
|
|
|
@ -83,20 +84,20 @@ public class Status {
|
|
|
|
|
if (post.containsKey("pauseCrawlJob")) {
|
|
|
|
|
String jobType = (String) post.get("jobType");
|
|
|
|
|
if (jobType.equals("localCrawl"))
|
|
|
|
|
((plasmaSwitchboard)env).pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);
|
|
|
|
|
sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);
|
|
|
|
|
else if (jobType.equals("remoteTriggeredCrawl"))
|
|
|
|
|
((plasmaSwitchboard)env).pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);
|
|
|
|
|
sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);
|
|
|
|
|
else if (jobType.equals("globalCrawlTrigger"))
|
|
|
|
|
((plasmaSwitchboard)env).pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_GLOBAL_CRAWL_TRIGGER);
|
|
|
|
|
sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_GLOBAL_CRAWL_TRIGGER);
|
|
|
|
|
redirect = true;
|
|
|
|
|
} else if (post.containsKey("continueCrawlJob")) {
|
|
|
|
|
String jobType = (String) post.get("jobType");
|
|
|
|
|
if (jobType.equals("localCrawl"))
|
|
|
|
|
((plasmaSwitchboard)env).continueCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);
|
|
|
|
|
sb.continueCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);
|
|
|
|
|
else if (jobType.equals("remoteTriggeredCrawl"))
|
|
|
|
|
((plasmaSwitchboard)env).continueCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);
|
|
|
|
|
sb.continueCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);
|
|
|
|
|
else if (jobType.equals("globalCrawlTrigger"))
|
|
|
|
|
((plasmaSwitchboard)env).continueCrawlJob(plasmaSwitchboard.CRAWLJOB_GLOBAL_CRAWL_TRIGGER);
|
|
|
|
|
sb.continueCrawlJob(plasmaSwitchboard.CRAWLJOB_GLOBAL_CRAWL_TRIGGER);
|
|
|
|
|
redirect = true;
|
|
|
|
|
} else if (post.containsKey("ResetTraffic")) {
|
|
|
|
|
httpdByteCountInputStream.resetCount();
|
|
|
|
@ -105,9 +106,9 @@ public class Status {
|
|
|
|
|
} else if (post.containsKey("popup")) {
|
|
|
|
|
String trigger_enabled = (String) post.get("popup");
|
|
|
|
|
if (trigger_enabled.equals("false")) {
|
|
|
|
|
env.setConfig("browserPopUpTrigger", "false");
|
|
|
|
|
sb.setConfig("browserPopUpTrigger", "false");
|
|
|
|
|
} else if (trigger_enabled.equals("true")){
|
|
|
|
|
env.setConfig("browserPopUpTrigger", "true");
|
|
|
|
|
sb.setConfig("browserPopUpTrigger", "true");
|
|
|
|
|
}
|
|
|
|
|
redirect = true;
|
|
|
|
|
}
|
|
|
|
@ -125,7 +126,7 @@ public class Status {
|
|
|
|
|
// update seed info
|
|
|
|
|
yacyCore.peerActions.updateMySeed();
|
|
|
|
|
|
|
|
|
|
boolean adminaccess = ((plasmaSwitchboard) env).adminAuthenticated(header) >= 2;
|
|
|
|
|
boolean adminaccess = sb.adminAuthenticated(header) >= 2;
|
|
|
|
|
if (adminaccess) {
|
|
|
|
|
prop.put("showPrivateTable",1);
|
|
|
|
|
prop.put("privateStatusTable", "Status_p.inc");
|
|
|
|
@ -135,7 +136,7 @@ public class Status {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// password protection
|
|
|
|
|
if (env.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() == 0) {
|
|
|
|
|
if (sb.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() == 0) {
|
|
|
|
|
prop.put("protection", 0); // not protected
|
|
|
|
|
prop.put("urgentSetPassword", 1);
|
|
|
|
|
} else {
|
|
|
|
@ -147,18 +148,18 @@ public class Status {
|
|
|
|
|
prop.put("restartEnabled", (System.getProperty("os.name").toLowerCase().startsWith("win")) ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
// version information
|
|
|
|
|
prop.put("versionpp", yacy.combined2prettyVersion(env.getConfig("version","0.1")));
|
|
|
|
|
prop.put("versionpp", yacy.combined2prettyVersion(sb.getConfig("version","0.1")));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double thisVersion = Double.parseDouble(env.getConfig("version","0.1"));
|
|
|
|
|
double thisVersion = Double.parseDouble(sb.getConfig("version","0.1"));
|
|
|
|
|
// cut off the SVN Rev in the Version
|
|
|
|
|
try {thisVersion = Math.round(thisVersion*1000.0)/1000.0;} catch (NumberFormatException e) {}
|
|
|
|
|
|
|
|
|
|
if ((adminaccess) && !(((plasmaSwitchboard) env).updaterCallback == null) && (((plasmaSwitchboard) env).updaterCallback.updateYaCyIsPossible() == true)){
|
|
|
|
|
if ((adminaccess) && (sb.updaterCallback != null) && (sb.updaterCallback.updateYaCyIsPossible())){
|
|
|
|
|
prop.put("hintVersionAvailable", 1);
|
|
|
|
|
prop.put("hintVersionAvailable_latestVersion", ((plasmaSwitchboard) env).updaterCallback.getYaCyUpdateReleaseVersion());
|
|
|
|
|
prop.put("hintVersionAvailable_latestVersion", sb.updaterCallback.getYaCyUpdateReleaseVersion());
|
|
|
|
|
if ((post != null) && (post.containsKey("aquirerelease"))) {
|
|
|
|
|
((plasmaSwitchboard) env).updaterCallback.grantYaCyUpdate();
|
|
|
|
|
sb.updaterCallback.grantYaCyUpdate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -179,8 +180,19 @@ public class Status {
|
|
|
|
|
prop.put("hintVersionAvailable_latestVersion", Double.toString(yacyVersion.latestRelease));
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// place some more hints
|
|
|
|
|
if ((adminaccess) && (sb.getThread(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL).getJobCount() == 0)) {
|
|
|
|
|
prop.put("hintCrawlStart", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((adminaccess) && (sb.getThread(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL).getJobCount() > 500)) {
|
|
|
|
|
prop.put("hintCrawlMonitor", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// hostname and port
|
|
|
|
|
String extendedPortString = env.getConfig("port", "8080");
|
|
|
|
|
String extendedPortString = sb.getConfig("port", "8080");
|
|
|
|
|
int pos = extendedPortString.indexOf(":");
|
|
|
|
|
prop.put("port",serverCore.getPortNr(extendedPortString));
|
|
|
|
|
if (pos!=-1) {
|
|
|
|
@ -192,7 +204,7 @@ public class Status {
|
|
|
|
|
prop.put("host", serverCore.publicLocalIP().getHostAddress());
|
|
|
|
|
|
|
|
|
|
// ssl support
|
|
|
|
|
prop.put("sslSupport",env.getConfig("keyStore", "").length() == 0 ? 0:1);
|
|
|
|
|
prop.put("sslSupport",sb.getConfig("keyStore", "").length() == 0 ? 0:1);
|
|
|
|
|
|
|
|
|
|
// port forwarding: hostname and port
|
|
|
|
|
if ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {
|
|
|
|
@ -204,18 +216,18 @@ public class Status {
|
|
|
|
|
prop.put("portForwarding", 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (env.getConfig("remoteProxyUse", "false").equals("true")) {
|
|
|
|
|
if (sb.getConfig("remoteProxyUse", "false").equals("true")) {
|
|
|
|
|
prop.put("remoteProxy", 1);
|
|
|
|
|
prop.put("remoteProxy_host", env.getConfig("remoteProxyHost", "<unknown>"));
|
|
|
|
|
prop.put("remoteProxy_port", env.getConfig("remoteProxyPort", "<unknown>"));
|
|
|
|
|
prop.put("remoteProxy_4Yacy", env.getConfig("remoteProxyUse4Yacy", "true").equalsIgnoreCase("true")?0:1);
|
|
|
|
|
prop.put("remoteProxy_host", sb.getConfig("remoteProxyHost", "<unknown>"));
|
|
|
|
|
prop.put("remoteProxy_port", sb.getConfig("remoteProxyPort", "<unknown>"));
|
|
|
|
|
prop.put("remoteProxy_4Yacy", sb.getConfig("remoteProxyUse4Yacy", "true").equalsIgnoreCase("true")?0:1);
|
|
|
|
|
} else {
|
|
|
|
|
prop.put("remoteProxy", 0); // not used
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// peer information
|
|
|
|
|
String thisHash = "";
|
|
|
|
|
final String thisName = env.getConfig("peerName", "<nameless>");
|
|
|
|
|
final String thisName = sb.getConfig("peerName", "<nameless>");
|
|
|
|
|
if (yacyCore.seedDB.mySeed == null) {
|
|
|
|
|
thisHash = "not assigned";
|
|
|
|
|
prop.put("peerAddress", 0); // not assigned
|
|
|
|
@ -241,7 +253,7 @@ public class Status {
|
|
|
|
|
thisHash = yacyCore.seedDB.mySeed.hash;
|
|
|
|
|
prop.put("peerAddress", 1); // Address
|
|
|
|
|
prop.put("peerAddress_address", yacyCore.seedDB.mySeed.getPublicAddress());
|
|
|
|
|
prop.put("peerAddress_peername", env.getConfig("peerName", "<nameless>").toLowerCase());
|
|
|
|
|
prop.put("peerAddress_peername", sb.getConfig("peerName", "<nameless>").toLowerCase());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
final String peerStatus = ((yacyCore.seedDB.mySeed == null) ? yacySeed.PEERTYPE_VIRGIN : yacyCore.seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN));
|
|
|
|
@ -262,31 +274,31 @@ public class Status {
|
|
|
|
|
prop.put("peerName", thisName);
|
|
|
|
|
prop.put("hash", thisHash);
|
|
|
|
|
|
|
|
|
|
final String seedUploadMethod = env.getConfig("seedUploadMethod", "");
|
|
|
|
|
final String seedUploadMethod = sb.getConfig("seedUploadMethod", "");
|
|
|
|
|
if (!seedUploadMethod.equalsIgnoreCase("none") ||
|
|
|
|
|
(seedUploadMethod.equals("") && env.getConfig("seedFTPPassword", "").length() > 0) ||
|
|
|
|
|
(seedUploadMethod.equals("") && env.getConfig("seedFilePath", "").length() > 0)) {
|
|
|
|
|
(seedUploadMethod.equals("") && sb.getConfig("seedFTPPassword", "").length() > 0) ||
|
|
|
|
|
(seedUploadMethod.equals("") && sb.getConfig("seedFilePath", "").length() > 0)) {
|
|
|
|
|
if (seedUploadMethod.equals("")) {
|
|
|
|
|
if (env.getConfig("seedFTPPassword", "").length() > 0) {
|
|
|
|
|
env.setConfig("seedUploadMethod","Ftp");
|
|
|
|
|
if (sb.getConfig("seedFTPPassword", "").length() > 0) {
|
|
|
|
|
sb.setConfig("seedUploadMethod","Ftp");
|
|
|
|
|
}
|
|
|
|
|
if (env.getConfig("seedFilePath", "").length() > 0) {
|
|
|
|
|
env.setConfig("seedUploadMethod","File");
|
|
|
|
|
if (sb.getConfig("seedFilePath", "").length() > 0) {
|
|
|
|
|
sb.setConfig("seedUploadMethod","File");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (seedUploadMethod.equalsIgnoreCase("ftp")) {
|
|
|
|
|
prop.put(SEEDSERVER, 1); // enabled
|
|
|
|
|
prop.put("seedServer_seedServer", env.getConfig("seedFTPServer", ""));
|
|
|
|
|
prop.put("seedServer_seedServer", sb.getConfig("seedFTPServer", ""));
|
|
|
|
|
} else if (seedUploadMethod.equalsIgnoreCase("scp")) {
|
|
|
|
|
prop.put(SEEDSERVER, 1); // enabled
|
|
|
|
|
prop.put("seedServer_seedServer", env.getConfig("seedScpServer", ""));
|
|
|
|
|
prop.put("seedServer_seedServer", sb.getConfig("seedScpServer", ""));
|
|
|
|
|
} else if (seedUploadMethod.equalsIgnoreCase("file")) {
|
|
|
|
|
prop.put(SEEDSERVER, 2); // enabled
|
|
|
|
|
prop.put("seedServer_seedFile", env.getConfig("seedFilePath", ""));
|
|
|
|
|
prop.put("seedServer_seedFile", sb.getConfig("seedFilePath", ""));
|
|
|
|
|
}
|
|
|
|
|
prop.put("seedServer_lastUpload",
|
|
|
|
|
serverDate.intervalToString(System.currentTimeMillis()-((plasmaSwitchboard)env).yc.lastSeedUpload_timeStamp));
|
|
|
|
|
serverDate.intervalToString(System.currentTimeMillis() - sb.yc.lastSeedUpload_timeStamp));
|
|
|
|
|
} else {
|
|
|
|
|
prop.put(SEEDSERVER, 0); // disabled
|
|
|
|
|
}
|
|
|
|
@ -298,15 +310,15 @@ public class Status {
|
|
|
|
|
prop.put("otherPeers", 0); // not online
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (env.getConfig("browserPopUpTrigger", "false").equals("false")) {
|
|
|
|
|
if (sb.getConfig("browserPopUpTrigger", "false").equals("false")) {
|
|
|
|
|
prop.put("popup", 0);
|
|
|
|
|
} else {
|
|
|
|
|
prop.put("popup", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (env.getConfig("onlineMode", "1").equals("0")) {
|
|
|
|
|
if (sb.getConfig("onlineMode", "1").equals("0")) {
|
|
|
|
|
prop.put("omode", 0);
|
|
|
|
|
} else if (env.getConfig("onlineMode", "1").equals("1")) {
|
|
|
|
|
} else if (sb.getConfig("onlineMode", "1").equals("1")) {
|
|
|
|
|
prop.put("omode", 1);
|
|
|
|
|
} else {
|
|
|
|
|
prop.put("omode", 2);
|
|
|
|
@ -326,7 +338,7 @@ public class Status {
|
|
|
|
|
prop.put("trafficCrawler",bytesToString(httpdByteCountInputStream.getAccountCount("CRAWLER")));
|
|
|
|
|
|
|
|
|
|
// connection information
|
|
|
|
|
serverCore httpd = (serverCore) env.getThread("10_httpd");
|
|
|
|
|
serverCore httpd = (serverCore) sb.getThread("10_httpd");
|
|
|
|
|
int activeSessionCount = httpd.getActiveSessionCount();
|
|
|
|
|
int idleSessionCount = httpd.getIdleSessionCount();
|
|
|
|
|
int maxSessionCount = httpd.getMaxSessionCount();
|
|
|
|
@ -335,7 +347,6 @@ public class Status {
|
|
|
|
|
prop.put("connectionsIdle",Integer.toString(idleSessionCount));
|
|
|
|
|
|
|
|
|
|
// Queue information
|
|
|
|
|
final plasmaSwitchboard sb = (plasmaSwitchboard)env;
|
|
|
|
|
int indexingJobCount = sb.getThread("80_indexing").getJobCount()+sb.indexingTasksInProcess.size();
|
|
|
|
|
int indexingMaxCount = plasmaSwitchboard.indexingSlots;
|
|
|
|
|
int indexingPercent = (indexingMaxCount==0)?0:indexingJobCount*100/indexingMaxCount;
|
|
|
|
|