diff --git a/htroot/AccessGrid_p.html b/htroot/AccessGrid_p.html new file mode 100644 index 000000000..45023795e --- /dev/null +++ b/htroot/AccessGrid_p.html @@ -0,0 +1,62 @@ + + + + YaCy '#[clientname]#': YaCy Network Access + #%env/templates/metas.template%# + + + + + + #%env/templates/header.template%# + #%env/templates/submenuAccessTracker.template%# +

Server Access Grid

+ +
+

+ The YaCy Network +

+
+ + #%env/templates/footer.template%# + + \ No newline at end of file diff --git a/htroot/AccessGrid_p.java b/htroot/AccessGrid_p.java new file mode 100644 index 000000000..f13712c9c --- /dev/null +++ b/htroot/AccessGrid_p.java @@ -0,0 +1,37 @@ +/** + * AccessGrid_p + * Copyright 2011 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany + * First released 18.02.2010 at http://yacy.net + * + * $LastChangedDate: 2010-06-16 17:11:21 +0200 (Mi, 16 Jun 2010) $ + * $LastChangedRevision: 6922 $ + * $LastChangedBy: orbiter $ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program in the file lgpl21.txt + * If not, see . + */ + +import net.yacy.cora.protocol.RequestHeader; +import de.anomic.server.serverObjects; +import de.anomic.server.serverSwitch; + + +public class AccessGrid_p { + + public static serverObjects respond(final RequestHeader requestHeader, final serverObjects post, final serverSwitch switchboard) { + final serverObjects prop = new serverObjects(); + return prop; + } + +} diff --git a/htroot/AccessPicture_p.java b/htroot/AccessPicture_p.java new file mode 100644 index 000000000..9a8b43c00 --- /dev/null +++ b/htroot/AccessPicture_p.java @@ -0,0 +1,184 @@ +/** + * AccessPicture_p + * Copyright 2011 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany + * First released 18.02.2010 at http://yacy.net + * + * $LastChangedDate: 2010-06-16 17:11:21 +0200 (Mi, 16 Jun 2010) $ + * $LastChangedRevision: 6922 $ + * $LastChangedBy: orbiter $ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program in the file lgpl21.txt + * If not, see . + */ + +import java.util.ConcurrentModificationException; +import java.util.Date; +import java.util.Iterator; +import java.util.Set; + +import net.yacy.cora.protocol.ConnectionInfo; +import net.yacy.cora.protocol.RequestHeader; +import net.yacy.visualization.HexGridPlotter; +import net.yacy.visualization.PrintTool; +import net.yacy.visualization.RasterPlotter; +import net.yacy.visualization.RasterPlotter.DrawMode; +import de.anomic.search.Switchboard; +import de.anomic.server.serverObjects; +import de.anomic.server.serverSwitch; + +public class AccessPicture_p { + + private static int[] times = new int[]{60000, 50000, 40000, 30000, 20000, 10000, 1000}; + + public static RasterPlotter respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { + final Switchboard sb = (Switchboard) env; + + String color_text = "AAAAAA"; + String color_back = "FFFFFF"; + String color_grid = "333333"; + String color_dot = "33CC33"; + String color_line = "555555"; + + int width = 1024; + int height = 576; + int cellsize = 18; + + if (post != null) { + width = post.getInt("width", 1024); + height = post.getInt("height", 576); + cellsize = post.getInt("cellsize", cellsize); + color_text = post.get("colortext", color_text); + color_back = post.get("colorback", color_back); + color_grid = post.get("colorgrid", color_grid); + color_dot = post.get("colordot", color_dot); + color_line = post.get("colorline", color_line); + } + + // too small values lead to an error, too big to huge CPU/memory consumption, resulting in possible DOS. + if (width < 32 ) width = 32; + if (width > 10000) width = 10000; + if (height < 24) height = 24; + if (height > 10000) height = 10000; + + final HexGridPlotter picture = new HexGridPlotter(width, height, DrawMode.MODE_SUB, color_back, cellsize); + picture.drawGrid(color_grid); + + // calculate dimensions for left and right column + int gridLeft = 0; + int gridRight = picture.gridWidth() - 2; + if ((gridRight & 1) == 0) gridRight--; + + // draw home peer + int centerx = (picture.gridWidth() >> 1) - 1; + int centery = picture.gridHeight() >> 1; + picture.setColor(color_dot); + picture.gridDot(centerx, centery, 5, true); + //picture.gridDot(centerx, centery, 50, false); + //picture.gridDot(centerx, centery, 31, false); + picture.setColor(color_text); + picture.gridPrint(centerx, centery, 5, "THIS YACY PEER", "\"" + sb.peers.myName().toUpperCase() + "\"", 0); + + // left column: collect data for access from outside + int verticalSlots = (picture.gridHeight() >> 1) - 1; + String[] hosts = new String[verticalSlots]; + int[] time = new int[verticalSlots]; + int[] count = new int[verticalSlots]; + for (int i = 0; i < verticalSlots; i++) {hosts[i] = null; time[i] = 0; count[i] = 0;} + + String host; + int c, h; + for (int j = 0; j < times.length; j++) { + Iterator i = sb.accessHosts(); + try { + while (i.hasNext()) { + host = i.next(); + c = sb.latestAccessCount(host, times[j]); + if (c > 0) { + h = (Math.abs(host.hashCode())) % hosts.length; + hosts[h] = host; + count[h] = c; + time[h] = times[j]; + } + } + } catch (final ConcurrentModificationException e) {} // we don't want to synchronize this + } + + // draw left column: access from outside + for (int i = 0; i < hosts.length; i++) { + if (hosts[i] != null) { + picture.setColor(color_dot); + picture.gridDot(gridLeft, i * 2 + 1, 7, false); + picture.gridDot(gridLeft, i * 2 + 1, 8, false); + picture.setColor(color_text); + picture.gridPrint(gridLeft, i * 2 + 1, 8, hosts[i].toUpperCase(), "COUNT = " + count[i] + ", TIME > " + ((time[i] >= 60000) ? ((time[i] / 60000) + " MINUTES") : ((time[i] / 1000) + " SECONDS")), -1); + picture.setColor(color_line); + picture.gridLine(gridLeft, i * 2 + 1, (centerx - gridLeft) / 2, i * 2 + 1); + picture.gridLine(centerx, centery, (centerx - gridLeft) / 2, i * 2 + 1); + } + } + + // right column: collect data for access to outside + for (int i = 0; i < verticalSlots; i++) {hosts[i] = null; time[i] = 0; count[i] = 0;} + final Set allConnections = ConnectionInfo.getAllConnections(); + c = 0; + synchronized (allConnections) { + for (final ConnectionInfo conInfo: allConnections) { + host = conInfo.getTargetHost(); + h = (Math.abs(host.hashCode())) % hosts.length; + hosts[h] = host + " - " + conInfo.getCommand(); + count[h] = (int) conInfo.getUpbytes(); + time[h] = (int) conInfo.getLifetime(); + } + } + + // draw right column: access to outside + for (int i = 0; i < hosts.length; i++) { + if (hosts[i] != null) { + picture.setColor(color_dot); + picture.gridDot(gridRight, i * 2 + 1, 7, false); + picture.gridDot(gridRight, i * 2 + 1, 8, false); + picture.setColor(color_text); + picture.gridPrint(gridRight, i * 2 + 1, 8, hosts[i].toUpperCase(), count[i] + " BYTES, " + time[i] + " MS DUE", 1); + picture.setColor(color_line); + picture.gridLine(gridRight, i * 2 + 1, centerx + (gridRight - centerx) / 2, i * 2 + 1); + picture.gridLine(centerx, centery, centerx + (gridRight - centerx) / 2, i * 2 + 1); + } + } + + // print headline + picture.setColor(color_text); + PrintTool.print(picture, 2, 6, 0, "YACY NODE ACCESS GRID", -1); + PrintTool.print(picture, width - 2, 6, 0, "SNAPSHOT FROM " + new Date().toString().toUpperCase(), 1); + + // print legend + picture.setColor(color_grid); + picture.gridLine(gridLeft, 0, centerx - 2, 0); + picture.gridLine(gridLeft, 0, gridLeft, picture.gridHeight() - 1); + picture.gridLine(centerx - 2, 0, centerx - 2, picture.gridHeight() - 1); + picture.setColor(color_dot); + picture.gridLine(gridLeft, picture.gridHeight() - 1, centerx - 2, picture.gridHeight() - 1); + picture.gridPrint(gridLeft, picture.gridHeight() - 1, 8, "", "INCOMING CONNECTIONS", -1); + + picture.setColor(color_grid); + picture.gridLine(centerx + 3, 0, gridRight + 1, 0); + picture.gridLine(centerx + 3, 0, centerx + 3, picture.gridHeight() - 1); + picture.gridLine(gridRight + 1, 0, gridRight + 1, picture.gridHeight() - 1); + picture.setColor(color_dot); + picture.gridLine(centerx + 3, picture.gridHeight() - 1, gridRight + 1, picture.gridHeight() - 1); + picture.gridPrint(gridRight + 1, picture.gridHeight() - 1, 8, "", "OUTGOING CONNECTIONS", 1); + + return picture; + + } +} diff --git a/htroot/env/templates/header.template b/htroot/env/templates/header.template index 6c17c3f1c..f61d073f7 100644 --- a/htroot/env/templates/header.template +++ b/htroot/env/templates/header.template @@ -77,7 +77,7 @@