diff --git a/defaults/yacy.init b/defaults/yacy.init index 1c6879d9c..0731e86aa 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -639,6 +639,9 @@ proxy.sendViaHeader=true # Specifies if the proxy should send the X-Forwarded-For header proxy.sendXForwardedForHeader=true +# Enable cookie monitoring +proxy.monitorCookies=false + # msgForwarding: Specifies if yacy should forward received messages via # email to the configured email address msgForwardingEnabled=false diff --git a/htroot/CookieMonitorIncoming_p.html b/htroot/CookieMonitorIncoming_p.html index 58c5b6756..501b5c817 100644 --- a/htroot/CookieMonitorIncoming_p.html +++ b/htroot/CookieMonitorIncoming_p.html @@ -26,6 +26,12 @@ #{/list}# +
+
+ #(monitorCookies.off)#::#(/monitorCookies.off)# + #(monitorCookies.on)#::#(/monitorCookies.on)# +
+
#%env/templates/footer.template%# diff --git a/htroot/CookieMonitorIncoming_p.java b/htroot/CookieMonitorIncoming_p.java index ae267160e..88c957146 100644 --- a/htroot/CookieMonitorIncoming_p.java +++ b/htroot/CookieMonitorIncoming_p.java @@ -42,6 +42,19 @@ public class CookieMonitorIncoming_p { // return variable that accumulates replacements serverObjects prop = new serverObjects(); + // handle on/off button + if(post != null) { + if(post.containsKey("enableCookieMonitoring")) { + switchboard.setConfig("proxy.monitorCookies", true); + } else if (post.containsKey("disableCookieMonitoring")) { + switchboard.setConfig("proxy.monitorCookies", false); + switchboard.incomingCookies.clear(); + switchboard.outgoingCookies.clear(); + } + } + prop.put("monitorCookies.on", switchboard.getConfigBool("proxy.monitorCookies", false) ? "1":"0"); + prop.put("monitorCookies.off", !switchboard.getConfigBool("proxy.monitorCookies", false) ? "1":"0"); + int maxCount = 100; int entCount = 0; int tmpCount = 0; @@ -80,6 +93,7 @@ public class CookieMonitorIncoming_p { prop.put("list", entCount); prop.put("num", entCount); prop.put("total", switchboard.incomingCookies.size()); + // return rewrite properties return prop; } diff --git a/htroot/CookieMonitorOutgoing_p.html b/htroot/CookieMonitorOutgoing_p.html index fe4d64084..95806a553 100644 --- a/htroot/CookieMonitorOutgoing_p.html +++ b/htroot/CookieMonitorOutgoing_p.html @@ -30,6 +30,12 @@ #{/list}# +
+
+ #(monitorCookies.off)#::#(/monitorCookies.off)# + #(monitorCookies.on)#::#(/monitorCookies.on)# +
+
#%env/templates/footer.template%# diff --git a/htroot/CookieMonitorOutgoing_p.java b/htroot/CookieMonitorOutgoing_p.java index f7f0f42f6..83e11a14f 100644 --- a/htroot/CookieMonitorOutgoing_p.java +++ b/htroot/CookieMonitorOutgoing_p.java @@ -42,6 +42,19 @@ public class CookieMonitorOutgoing_p { // return variable that accumulates replacements serverObjects prop = new serverObjects(); + // handle on/off button + if(post != null) { + if(post.containsKey("enableCookieMonitoring")) { + switchboard.setConfig("proxy.monitorCookies", true); + } else if (post.containsKey("disableCookieMonitoring")) { + switchboard.setConfig("proxy.monitorCookies", false); + switchboard.incomingCookies.clear(); + switchboard.outgoingCookies.clear(); + } + } + prop.put("monitorCookies.on", switchboard.getConfigBool("proxy.monitorCookies", false) ? "1":"0"); + prop.put("monitorCookies.off", !switchboard.getConfigBool("proxy.monitorCookies", false) ? "1":"0"); + int maxCount = 100; int entCount = 0; int tmpCount = 0; diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java index 269478d54..29db52763 100644 --- a/source/de/anomic/http/httpdProxyHandler.java +++ b/source/de/anomic/http/httpdProxyHandler.java @@ -240,10 +240,12 @@ public final class httpdProxyHandler { path = "$Path" "=" value domain = "$Domain" "=" value */ - if (requestHeader.containsKey(httpHeader.COOKIE)) { - Object[] entry = new Object[]{new Date(), clienthost, requestHeader.getMultiple(httpHeader.COOKIE)}; - synchronized(switchboard.outgoingCookies) { - switchboard.outgoingCookies.put(targethost, entry); + if (switchboard.getConfigBool("proxy.monitorCookies", false)) { + if (requestHeader.containsKey(httpHeader.COOKIE)) { + Object[] entry = new Object[]{new Date(), clienthost, requestHeader.getMultiple(httpHeader.COOKIE)}; + synchronized(switchboard.outgoingCookies) { + switchboard.outgoingCookies.put(targethost, entry); + } } } } @@ -264,10 +266,12 @@ public final class httpdProxyHandler { | "Secure" | "Version" "=" 1*DIGIT */ - if (respondHeader.containsKey(httpHeader.SET_COOKIE)) { - Object[] entry = new Object[]{new Date(), targetclient, respondHeader.getMultiple(httpHeader.SET_COOKIE)}; - synchronized(switchboard.incomingCookies) { - switchboard.incomingCookies.put(serverhost, entry); + if (switchboard.getConfigBool("proxy.monitorCookies", false)) { + if (respondHeader.containsKey(httpHeader.SET_COOKIE)) { + Object[] entry = new Object[]{new Date(), targetclient, respondHeader.getMultiple(httpHeader.SET_COOKIE)}; + synchronized(switchboard.incomingCookies) { + switchboard.incomingCookies.put(serverhost, entry); + } } } }