Author: dbkr
Date: 2006-03-18 17:27:07 +0000 (Sat, 18 Mar 2006)
New Revision: 8276
Modified:
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
trunk/freenet/src/freenet/clients/http/staticfiles/themes/aqua/theme.css
trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/Version.java
Log:
545: Finish connection adding / removing support in web interface, plus a
couple of general CSS clean-ups.
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-03-18 15:18:54 UTC (rev 8275)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-03-18 17:27:07 UTC (rev 8276)
@@ -60,19 +60,20 @@
// our reference
buf.append("<div class=\"infobox\">\n");
- buf.append("<h2 class=\"boxhead\">My Reference</h2>\n");
+ buf.append("<h2>My Reference</h2>\n");
buf.append("<pre>\n");
buf.append(this.node.exportFieldSet());
buf.append("</pre>\n");
buf.append("</div>\n");
- // FIXME! 1) Probably would be better to use CSS
- // FIXME! 2) We need some nice images
+ // FIXME! We need some nice images
PeerNode[] peerNodes = node.getDarknetConnections();
long now = System.currentTimeMillis();
- buf.append("<table border=\"0\">\n");
+ buf.append("<div class=\"infobox\">\n");
+ buf.append("<h2>My Connections</h2>\n");
+ buf.append("<table class=\"darknet_connections\">\n");
buf.append("<tr><th>Status</th><th>Name</th><th>Address</th><th>Version</th><th>Location</th><th>Backoff</th><th>Backoff
length</th><th></th></tr>\n");
final Integer CONNECTED = new Integer(0);
@@ -110,12 +111,11 @@
row[4] = new Double(pn.getLocation().getValue());
row[5] = new Long(Math.max(backedOffUntil - now, 0));
row[6] = new Long(backoffLength);
- // TODO: Best way of identifying peers? Name isn't
unique and host/port can be null.
row[7] = new String("<form action=\".\"
method=\"post\">\n"
- +"<span>"
- +"<input type=\"hidden\" name=\"node\"
value=\"\" />"
+ +"<div>"
+ +"<input type=\"hidden\" name=\"node\"
value=\""+pn.hashCode()+"\" />"
+"<input type=\"submit\"
name=\"disconnect\" value=\"Disconnect\" />\n"
- +"</span>\n"
+ +"</div>\n"
+"</form>\n");
}
@@ -126,10 +126,10 @@
for(int i=0;i<rows.length;i++) {
Object[] row = rows[i];
Integer x = (Integer) row[0];
- if(x == CONNECTED) row[0] = "<font
color=\"green\">CONNECTED</font>";
- else if(x == BACKED_OFF) row[0] = "<font
color=\"red\">BACKED OFF</font>";
- else if(x == INCOMPATIBLE) row[0] = "<font
color=\"blue\">INCOMPATIBLE</font>";
- else if(x == DISCONNECTED) row[0] = "<font
color=\"black\">DISCONNECTED</font>";
+ if(x == CONNECTED) row[0] = "<span
class=\"peer_connected\">CONNECTED</span>";
+ else if(x == BACKED_OFF) row[0] = "<span
class=\"peer_backedoff\">BACKED OFF</span>";
+ else if(x == INCOMPATIBLE) row[0] = "<span
span=\"peer_incompatable\">INCOMPATIBLE</span>";
+ else if(x == DISCONNECTED) row[0] = "<span
class=\"peer_disconnected\">DISCONNECTED</span>";
}
// Turn array into HTML
@@ -144,11 +144,12 @@
buf.append("</td></tr>");
}
buf.append("</table>");
+ buf.append("</div>");
// new connection box
buf.append("<form action=\".\" method=\"post\">\n");
buf.append("<div class=\"infobox\">\n");
- buf.append("<h2 class=\"boxhead\">\n");
+ buf.append("<h2>\n");
buf.append("Connect to another node\n");
buf.append("</h2>\n");
buf.append("Reference:<br />\n");
@@ -206,8 +207,8 @@
}
} else if (reftext.length() > 0) {
// read directly from post data
- // FIXME: The regexp don't work.
- ref =
reftext.replaceAll("\\.*(\\w)\\=(\\w)(\\r?\\n)+", "\\1=\\2\\n");
+ // this slightly scary looking regexp chops any
extra characters off the beginning or ends of lines and removes extra line
breaks
+ ref =
reftext.replaceAll(".*?((?:[\\w,\\.]+\\=[\\w,\\.:]+)|(?:End)).*?(?:\\r?\\n)*",
"$1\n");
} else {
this.sendErrorPage(ctx, 200, "Failed to add
node", "Could not detect either a node reference or a URL. Please <a
href=\".\">Try again</a>.");
return;
@@ -234,6 +235,16 @@
if(!this.node.addDarknetConnection(pn)) {
this.sendErrorPage(ctx, 200, "Failed to add
node", "Unable to add the given reference as a peer. Please <a href=\".\">Try
again</a>.");
}
+ } else if (request.getParam("disconnect").length() > 0) {
+ int hashcode =
Integer.decode(request.getParam("node")).intValue();
+
+ PeerNode[] peerNodes = node.getDarknetConnections();
+ for(int i = 0; i < peerNodes.length; i++) {
+ if (hashcode == peerNodes[i].hashCode()) {
+
this.node.removeDarknetConnection(peerNodes[i]);
+ break;
+ }
+ }
}
this.handleGet(uri, ctx);
}
Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java 2006-03-18
15:18:54 UTC (rev 8275)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java 2006-03-18
17:27:07 UTC (rev 8276)
@@ -107,11 +107,14 @@
buf.append("</form>\n");
// Activity
+ buf.append("<div class=\"infobox\">\n");
+ buf.append("<h2>Current Activity</h2>\n");
buf.append("<ul id=\"activity\">\n"
+ "<li>Inserts:
"+this.node.getNumInserts()+"</li>\n"
+ "<li>Requests:
"+this.node.getNumRequests()+"</li>\n"
+ "<li>Transferring Requests:
"+this.node.getNumTransferringRequests()+"</li>\n"
+ "</ul>\n");
+ buf.append("</div>\n");
ctx.getPageMaker().makeTail(buf);
Modified:
trunk/freenet/src/freenet/clients/http/staticfiles/themes/aqua/theme.css
===================================================================
--- trunk/freenet/src/freenet/clients/http/staticfiles/themes/aqua/theme.css
2006-03-18 15:18:54 UTC (rev 8275)
+++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/aqua/theme.css
2006-03-18 17:27:07 UTC (rev 8276)
@@ -59,27 +59,24 @@
padding: 5px;
margin: 10px;
margin-bottom: 10px;
- display: table-cell;
+ display: table;
}
pre, textarea {
font-size: 70%;
}
-.boxhead {
+.infobox h2 {
text-align: left;
font-weight: bold;
margin: -5px;
margin-bottom: 10px;
border-bottom: 1px solid #5e88d8;
padding-left: 5px;
+ font-size: 110%;
}
#activity {
- border: 1px solid #5e88d8;
- padding: 5px;
- margin-bottom: 10px;
- display: table-cell;
list-style-position: inside;
}
@@ -98,3 +95,23 @@
.confirm {
float: right;
}
+
+.darknet_connections {
+ font-size: 80%;
+}
+
+.peer_connected {
+ color: green;
+}
+
+.peer_backedoff {
+ color: red;
+}
+
+.peer_incompatable {
+ color: blue;
+}
+
+.peer_disconnected {
+ color: black;
+}
Modified:
trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css
===================================================================
--- trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css
2006-03-18 15:18:54 UTC (rev 8275)
+++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css
2006-03-18 17:27:07 UTC (rev 8276)
@@ -60,28 +60,17 @@
}
.infobox h2 {
- margin:0 0 15px 0;
+ margin: -10px;
+ margin-bottom: 10px;
padding:0;
border-bottom:1px dotted #000000;
font-family:Arial;
- font-weight:normal;
- font-size:13pt;
-}
-
-.boxhead {
+ font-weight:bold;
+ font-size:110%;
background-color:#e8e8e8;
- text-align: left;
- font-weight: bold;
- margin: -10px;
- margin-bottom: 10px;
- padding-left: 5px;
}
#activity {
- margin:0 0 5px 0;
- padding:10px;
- background-color:#f0f0f0;
- border:1px solid #d0d0d0;
list-style-position: inside;
}
@@ -102,3 +91,29 @@
.confirm {
float: right;
}
+
+table.darknet_connections {
+ font-size: 80%;
+ margin: 0px;
+ padding: -5px;
+}
+
+/*.darknet_connections td {
+ border: 1px solid #d0d0d0;
+}*/
+
+.peer_connected {
+ color: green;
+}
+
+.peer_backedoff {
+ color: red;
+}
+
+.peer_incompatable {
+ color: blue;
+}
+
+.peer_disconnected {
+ color: black;
+}
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-03-18 15:18:54 UTC (rev
8275)
+++ trunk/freenet/src/freenet/node/Node.java 2006-03-18 17:27:07 UTC (rev
8276)
@@ -2116,4 +2116,8 @@
peers.writePeers();
return retval;
}
+
+ public void removeDarknetConnection(PeerNode pn) {
+ peers.disconnect(pn);
+ }
}
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-03-18 15:18:54 UTC (rev
8275)
+++ trunk/freenet/src/freenet/node/Version.java 2006-03-18 17:27:07 UTC (rev
8276)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 544;
+ private static final int buildNumber = 545;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 507;