Author: nextgens Date: 2006-10-19 16:30:37 +0000 (Thu, 19 Oct 2006) New Revision: 10674
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java Log: Some untested code reverting r10661 wich was controversial. http://archives.freenetproject.org/thread/20061016.213156.f88b95f3.en.html Please test and help me to find a better wording. Maybe we should tell users why it's bad (ghost connections, churn, bad user experience, ...) Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java 2006-10-18 20:17:15 UTC (rev 10673) +++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java 2006-10-19 16:30:37 UTC (rev 10674) @@ -767,12 +767,21 @@ PeerNode[] peerNodes = node.getDarknetConnections(); for(int i = 0; i < peerNodes.length; i++) { if (request.isPartSet("node_"+peerNodes[i].hashCode())) { - if((peerNodes[i].timeLastConnectionCompleted() < (System.currentTimeMillis() - 1000*60*60*24*7) /* one week */) || (peerNodes[i].peerNodeStatus == Node.PEER_NODE_STATUS_NEVER_CONNECTED)){ + if((peerNodes[i].timeLastConnectionCompleted() < (System.currentTimeMillis() - 1000*60*60*24*7) /* one week */) || (peerNodes[i].peerNodeStatus == Node.PEER_NODE_STATUS_NEVER_CONNECTED)){ this.node.removeDarknetConnection(peerNodes[i]); if(logMINOR) Logger.minor(this, "Removed node: node_"+peerNodes[i].hashCode()); }else{ - if(logMINOR) Logger.minor(this, "Refusing to remove : node_"+peerNodes[i].hashCode()+" (trying to prevent network churn)"); - this.sendErrorPage(ctx, 401, "Error while removing the node", "Sorry, you can't remove nodes until they have reached one week of inactivity."); + if(logMINOR) Logger.minor(this, "Refusing to remove : node_"+peerNodes[i].hashCode()+" (trying to prevent network churn) : let's display the warning message."); + HTMLNode pageNode = ctx.getPageMaker().getPageNode("Please confirm"); + HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode); + HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-warning", "Node removal")); + HTMLNode content = ctx.getPageMaker().getContentNode(infobox); + content.addChild("p").addChild("#", "Are you sure you wish to remove "+peerNodes[i].getName()+" ? Before it has at least one week downtime, it's not recommended to do so."); + HTMLNode removeForm = content.addChild("p").addChild("form", new String[] { "action", "method" }, new String[] { "/darknet/", "post" }); + removeForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "node_"+peerNodes[i].hashCode(), "remove" }); + removeForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "cancel", "Cancel" }); + removeForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "remove", "Remove it!" }); + writeReply(ctx, 200, "text/html", "OK", pageNode.generate()); return; // FIXME: maybe it breaks multi-node removing } } else {
