From 606c5a9b40e001cee5339f627c0e0cbd24afe228 Mon Sep 17 00:00:00 2001 From: orbiter Date: Fri, 12 Aug 2011 10:31:01 +0000 Subject: [PATCH] added a serlvet that shows all scanned servers inside of the yacyinteractive search page git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7869 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ServerScannerList.html | 62 ++++++++++++++++++++++ htroot/ServerScannerList.java | 96 +++++++++++++++++++++++++++++++++++ htroot/yacyinteractive.html | 8 +++ 3 files changed, 166 insertions(+) create mode 100644 htroot/ServerScannerList.html create mode 100644 htroot/ServerScannerList.java diff --git a/htroot/ServerScannerList.html b/htroot/ServerScannerList.html new file mode 100644 index 000000000..2fe2efc6c --- /dev/null +++ b/htroot/ServerScannerList.html @@ -0,0 +1,62 @@ + + + + YaCy '#[clientname]#': Network Scanner Monitor + #%env/templates/metas.template%# + + +#(embedded)# +#%env/templates/header.template%# +

Network Scanner Monitor

+:: +#%env/templates/embeddedheader.template%# +#(/embedded)# + + #(servertable)#:: +

+ The following servers can be searched: +

+
+ + + + #(edit)#:: + + #(/edit)# + + + + + + + #{list}# + + #(edit)#:: + + #(/edit)# + + + + #(accessUnknown)#::#(/accessUnknown)# + #(accessEmpty)#::#(/accessEmpty)# + #(accessGranted)#::#(/accessGranted)# + #(accessDenied)#::#(/accessDenied)# + #(process)#::#(/process)# + + #{/list}# +
+ + ProtocolIPURLAccessProcess
#[protocol]##[ip]##[url]#unknownemptygranteddeniednot in indexindexed
+ #(edit)#:: +

+ + +

+ #(/edit)# +
+ #(/servertable)# + + + #%env/templates/footer.template%# + + diff --git a/htroot/ServerScannerList.java b/htroot/ServerScannerList.java new file mode 100644 index 000000000..274bae9e9 --- /dev/null +++ b/htroot/ServerScannerList.java @@ -0,0 +1,96 @@ +/** + * CrawlStartScanner_p + * Copyright 2010 by Michael Peter Christen, mc@yacy.net, Frankfurt am Main, Germany + * First released 12.08.2011 at http://yacy.net + * + * 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.net.MalformedURLException; +import java.util.ConcurrentModificationException; +import java.util.Iterator; +import java.util.Map; + +import net.yacy.cora.document.ASCII; +import net.yacy.cora.protocol.RequestHeader; +import net.yacy.cora.protocol.Scanner; +import net.yacy.cora.protocol.Scanner.Access; +import net.yacy.kelondro.data.meta.DigestURI; +import net.yacy.kelondro.logging.Log; + +import de.anomic.data.WorkTables; +import de.anomic.search.Switchboard; +import de.anomic.server.serverObjects; +import de.anomic.server.serverSwitch; + +public class ServerScannerList { + + public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { + + final serverObjects prop = new serverObjects(); + final Switchboard sb = (Switchboard)env; + + prop.put("servertable_edit", post == null ? 0 : post.containsKey("edit") ? 1 : 0); + prop.put("servertable_list_edit", post == null ? 0 : post.containsKey("edit") ? 1 : 0); + prop.put("embedded", post == null ? 0 : post.containsKey("embedded") ? 1 : 0); + prop.put("servertable", 0); + + // write scan table + if (Scanner.scancacheSize() > 0) { + // make a comment cache + final Map apiCommentCache = WorkTables.commentCache(sb); + + // show scancache table + prop.put("servertable", 1); + String urlString; + DigestURI u; + table: while (true) { + try { + int i = 0; + final Iterator> se = Scanner.scancacheEntries(); + Map.Entry host; + while (se.hasNext()) { + host = se.next(); + try { + u = new DigestURI(host.getKey().url()); + urlString = u.toNormalform(true, false); + prop.put("servertable_list_" + i + "_edit_pk", ASCII.String(u.hash())); + prop.put("servertable_list_" + i + "_edit_count", i); + prop.putHTML("servertable_list_" + i + "_protocol", u.getProtocol()); + prop.putHTML("servertable_list_" + i + "_ip", host.getKey().getInetAddress().getHostAddress()); + prop.putHTML("servertable_list_" + i + "_url", urlString); + prop.put("servertable_list_" + i + "_accessUnknown", host.getValue() == Access.unknown ? 1 : 0); + prop.put("servertable_list_" + i + "_accessEmpty", host.getValue() == Access.empty ? 1 : 0); + prop.put("servertable_list_" + i + "_accessGranted", host.getValue() == Access.granted ? 1 : 0); + prop.put("servertable_list_" + i + "_accessDenied", host.getValue() == Access.denied ? 1 : 0); + prop.put("servertable_list_" + i + "_process", Scanner.inIndex(apiCommentCache, urlString) == null ? 0 : 1); + prop.put("servertable_list_" + i + "_edit_preselected", host.getValue() == Access.granted && Scanner.inIndex(apiCommentCache, urlString) == null ? 1 : 0); + i++; + } catch (MalformedURLException e) { + Log.logException(e); + } + } + prop.put("servertable_list", i); + prop.put("servertable_edit_num", i); + break table; + } catch (ConcurrentModificationException e) { + continue table; + } + } + } + return prop; + } + +} diff --git a/htroot/yacyinteractive.html b/htroot/yacyinteractive.html index 462cc4909..fb00ebcc6 100644 --- a/htroot/yacyinteractive.html +++ b/htroot/yacyinteractive.html @@ -72,6 +72,14 @@ To see a list of all APIs, please visit the
+