Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*)added offline-browsing-support (onlineMode=0) *)online-mode now can be changed in Status.html

hydrox295aff52a3da
diff --git a/htroot/SettingsAck_p.html b/htroot/SettingsAck_p.html
index f8b1fd166..daedbbc1f 100644
--- a/htroot/SettingsAck_p.html
+++ b/htroot/SettingsAck_p.html
@@ -138,7 +138,11 @@ Seed Upload method was changed successfully.
<p><b>Port Forwarding Settings changed, but something is wrong.</b></p>
<p><font color="red">#[errormsg]#</font></p>
Port Forwarding was deactivated automatically.<br>
-Please return to the settings page and modify the data.<br>
+Please return to the settings page and modify the data.<br>
+::<!-- 24 -->
+You are now <b>event-based online</b>. After a short while you should see the effect on the <a href="Status.html">status</a> page.<br>
+::<!-- 25 -->
+You are now in <b>Cache Mode</b>. Only Proxy-cache ist available in this mode. After a short while you should see the effect on the <a href="Status.html">status</a> page.<br>
#(/info)#
</p>
<p>You can now go back to the <a href="Settings_p.html">Settings</a> page if you want to make more changes.</p>
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 39782c651..a0a34314c 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -297,10 +297,25 @@ public class SettingsAck_p {
if (post.containsKey("pmode")) {
env.setConfig("onlineMode", "2");
prop.put("info", 11);//permanent online mode
+ yacyCore.setOnlineMode(2);
yacyCore.triggerOnlineAction();
return prop;
}
+ if (post.containsKey("emode")) {
+ env.setConfig("onlineMode", "1");
+ prop.put("info", 24);//event-based online mode
+ yacyCore.setOnlineMode(1);
+ return prop;
+ }
+
+ if (post.containsKey("cmode")) {
+ env.setConfig("onlineMode", "0");
+ prop.put("info", 25);//cache mode
+ yacyCore.setOnlineMode(0);
+ return prop;
+ }
+
if (post.containsKey("generalsettings")) {
/*
// set peer language
diff --git a/htroot/Status.html b/htroot/Status.html
index 474fa400f..07c6fc404 100644
--- a/htroot/Status.html
+++ b/htroot/Status.html
@@ -78,18 +78,30 @@ Last upload: #[lastUpload]# ago.
</td></tr>
<tr class="TableCellLight"><td>Online-mode</td><td>
#(omode)#
-<!-- online Mode 0 -->
+You are in <i>Cache-browsing</i> mode.<br>
+Only Website from the Proxycache are accessable.
+To switch online-mode, press one of the following buttons:
+<form action="SettingsAck_p.html" method="get">
+<input type="submit" name="emode" value="event-based Mode">
+<input type="submit" name="pmode" value="Permanent Mode">
+</form>
::
You are in <i>event-based</i> online mode.<br>
The YaCy p2p network will boot when you start using the proxy or you switch to permanent mode.
Attention: Using the proxy in permanent mode will keep your internet connection online as long as YaCy runs.
Use this only if you have a flatrate or you have an always-on connection.
-To start permanent mode, press this button:
+To switch online-mode, press one of the following buttons:
<form action="SettingsAck_p.html" method="get">
<input type="submit" name="pmode" value="Go on-line">
+<input type="submit" name="cmode" value="Go to Cache-Mode">
</form>
::
You are in <i>permanent</i> mode. Attention: If you don't have a flatrate or are always-on, you must switch off the proxy to go off-line.
+To switch online-mode, press one of the following buttons:
+<form action="SettingsAck_p.html" method="get">
+<input type="submit" name="emode" value="event-based Mode">
+<input type="submit" name="cmode" value="Go to Cache-Mode">
+</form>
#(/omode)#
</td></tr>
</table>
@@ -100,4 +112,4 @@ You are in <i>permanent</i> mode. Attention: If you don't have a flatrate or are
#[footer]#
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/htroot/Status.java b/htroot/Status.java
index 75cda8736..45666e64b 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -225,9 +225,11 @@ public class Status {
prop.put("popup", 1);
}
- if (env.getConfig("onlineMode", "1").equals("1")) {
- prop.put("omode", 1);
- } else {
+ if (env.getConfig("onlineMode", "1").equals("0")) {
+ prop.put("omode", 0);
+ } else if (env.getConfig("onlineMode", "1").equals("1")) {
+ prop.put("omode", 1);
+ } else {
prop.put("omode", 2);
}
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index 59b8eef75..9ed502dd5 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -409,8 +409,15 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
null, // initiator
switchboard.defaultProxyProfile // profile
);
-
- if (cacheExists && cacheEntry.shallUseCacheForProxy()) {
+ if (yacyCore.getOnlineMode() == 0) {
+ if (cacheExists) {
+ fulfillRequestFromCache(conProp,url,ext,requestHeader,cachedResponseHeader,cacheFile,respond);
+ }
+ else {
+ httpd.sendRespondError(conProp,respond,4,404,null,"URL not availabe in Cache",null);
+ }
+ }
+ else if (cacheExists && cacheEntry.shallUseCacheForProxy()) {
fulfillRequestFromCache(conProp,url,ext,requestHeader,cachedResponseHeader,cacheFile,respond);
} else {
fulfillRequestFromWeb(conProp,url,ext,requestHeader,cachedResponseHeader,cacheFile,respond);
diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.java
index 068abd5bb..e14730307 100644
--- a/source/de/anomic/yacy/yacyCore.java
+++ b/source/de/anomic/yacy/yacyCore.java
@@ -105,7 +105,7 @@ public class yacyCore {
private String lastSeedUpload_myPeerType = "";
private String lastSeedUpload_myIP = "";
- private int onlineMode = 1;
+ private static int onlineMode = 1;
private plasmaSwitchboard switchboard;
private static TimeZone GMTTimeZone = TimeZone.getTimeZone("America/Los_Angeles");
@@ -221,6 +221,15 @@ public class yacyCore {
return ((onlineMode == 2) || ((System.currentTimeMillis() - lastOnlineTime) < 10000));
}
+ public static int getOnlineMode() {
+ return onlineMode;
+ }
+
+ public static void setOnlineMode(int newOnlineMode) {
+ onlineMode = newOnlineMode;
+ return;
+ }
+
public void loadSeeds() {
//new Thread(new vprobe()).start();
peerActions.loadSeedLists(); // start to bootstrap the network here
@@ -716,4 +725,4 @@ public class yacyCore {
}
}
-}
\ No newline at end of file
+}
diff --git a/yacy.init b/yacy.init
index fe73da889..97f395d0a 100644
--- a/yacy.init
+++ b/yacy.init
@@ -287,6 +287,7 @@ peerName=anomic
peerCycle=2
# The p2p maintenance can run in either of two online modes:
+# - don't process jobs and only access available in cache -> mode 0
# - process any job only if we are online, which is technically only the case
# if the proxy is used -> mode 1
# - process jobs periodically, with periodes according to peerCycle -> mode 2