Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- added ssl configuration sign (a lock) to network statistic/table - fixed a bug in bitfield
Michael Peter Christenb9b446bca6ec
diff --git a/htroot/Network.html b/htroot/Network.htmlindex 939c893d6..8c3ac7924 100644--- a/htroot/Network.html+++ b/htroot/Network.html@@ -146,7 +146,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de#(updatedBlog)#::<a href="http://#[address]#/Blog.html?page=#[page]#" title="#[subject]#"><img src="/env/grafics/blog.gif" width="54" height="11" alt="Blog updated" /></a>#(/updatedBlog)##(isCrawling)#::<a href="#[page]#"><img src="/env/grafics/crawl.gif" width="54" height="11" alt="Crawl" /></a>#(/isCrawling)#</td>- <td #(special)#::class="TableCellActive"#(/special)#><a href="http://www.#[fullname]#.yacy">#[shortname]#</a></td>+ <td #(special)#::class="TableCellActive"#(/special)#><a href="http://www.#[fullname]#.yacy">#[shortname]#</a>#(ssl)#::<img src="/env/grafics/lock.gif" width="11" height="15" title="https supported" alt="https supported" />#(/ssl)#</td><td nowrap>#(type)##(direct)#<img src="/env/grafics/JuniorPassive.gif" width="11" height="11" title="Type: Junior | Contact: passive" alt="Junior passive" />::<img src="/env/grafics/JuniorDirect.gif" width="11" height="11" title="Type: Junior | Contact: direct" alt="Junior direct" />::<img src="/env/grafics/JuniorOffline.gif" width="11" height="11" title="Type: Junior | Contact: offline" alt="Junior offline" />#(/direct)#::#(direct)#<img src="/env/grafics/SeniorPassive.gif" width="11" height="11" title="Type: Senior | Contact: passive" alt="senior passive" />::<img src="/env/grafics/SeniorDirect.gif" width="11" height="11" title="Type: Senior | Contact: direct" alt="Senior direct" />::<img src="/env/grafics/SeniorOffline.gif" width="11" height="11" title="Type: Senior | Contact: offline" alt="Senior offline" />#(/direct)#::<a href="#[url]#">#(direct)#<img src="/env/grafics/PrincipalPassive.gif" width="11" height="11" title="Type: Principal | Contact: passive | Seed download: possible" alt="Principal passive" />::<img src="/env/grafics/PrincipalDirect.gif" width="11" height="11" title="Type: Principal | Contact: direct | Seed download: possible" alt="Principal active" />::<img src="/env/grafics/PrincipalOffline.gif" width="11" height="11" title="Type: Principal | Contact: offline | Seed download: ?" alt="Principal offline" />#(/direct)#</a>#(/type)##(acceptcrawl)#<img src="/env/grafics/CrawlNo.gif" width="11" height="11" title="Accept Crawl: no" alt="no crawl" />::<img src="/env/grafics/CrawlYes.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />::<img src="/env/grafics/CrawlYesOffline.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />#(/acceptcrawl)##(dhtreceive)#<img src="/env/grafics/DHTReceiveNo.gif" width="11" height="11" title="DHT Receive: no; #[peertags]#" alt="no DHT receive" />::<img src="/env/grafics/DHTReceiveYes.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />::<img src="/env/grafics/DHTReceiveYesOffline.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />#(/dhtreceive)##(nodestate)#<img src="/env/grafics/RootStateNo.gif" width="11" height="11" title="Not a Node Candidate" alt="no node candidate" />::<a href="http://#[ip]#:#[port]#/Network.html?page=1"><img src="/env/grafics/RootStateYes.gif" width="11" height="11" title="Node Candidate" alt="node candidate" /></a>#(/nodestate)#</td><td align="right">#[version]#</td>@@ -258,7 +258,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de<td>QPH<br/>(remote)</td></tr><tr class="TableCellDark">- <td>#[my-name]#</td>+ <td>#[my-name]##(my-ssl)#::<img src="/env/grafics/lock.gif" width="11" height="15" title="https supported" alt="https supported" />#(/my-ssl)#</td><td>#(my-info)#<img src="/env/grafics/Virgin.gif" width="11" height="11" title="Type: Virgin" alt="Virgin" />::<img src="/env/grafics/JuniorDirect.gif" width="11" height="11" title="Type: Junior" alt="Junior" />::<img src="/env/grafics/SeniorDirect.gif" width="11" height="11" title="Type: Senior" alt="Senior" />::<img src="/env/grafics/PrincipalDirect.gif" width="11" height="11" title="Type: Principal" alt="Principal" />#(/my-info)##(my-acceptcrawl)#<img src="/env/grafics/CrawlNo.gif" width="11" height="11" title="Accept Crawl: no" alt="no crawl" />::<img src="/env/grafics/CrawlYes.gif" width="11" height="11" title="Accept Crawl: yes" alt="Crawl enabled" />#(/my-acceptcrawl)##(my-dhtreceive)#<img src="/env/grafics/DHTReceiveNo.gif" width="11" height="11" title="DHT Receive: no" alt="no DHT receive" />::<img src="/env/grafics/DHTReceiveYes.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT Receive enabled" />#(/my-dhtreceive)##(my-nodestate)#<img src="/env/grafics/RootStateNo.gif" width="11" height="11" title="Not a Node Candidate" alt="no node candidate" />::<img src="/env/grafics/RootStateYes.gif" width="11" height="11" title="Node Candidate" alt="node candidate" />#(/my-nodestate)#</td><td align="right">#[my-version]#</td><td align="right">#[my-utc]#</td>diff --git a/htroot/Network.java b/htroot/Network.javaindex f73938259..c01456bfd 100644--- a/htroot/Network.java+++ b/htroot/Network.java@@ -108,6 +108,7 @@ public class Network {// my-infoprop.putHTML("table_my-name", seed.get(Seed.NAME, "-") );prop.put("table_my-hash", seed.hash );+ prop.put("table_my-ssl", sb.peers.mySeed().getFlagSSLAvailable() ? 1 : 0);if (sb.peers.mySeed().isVirgin()) {prop.put("table_my-info", 0);} else if(sb.peers.mySeed().isJunior()) {@@ -378,6 +379,7 @@ public class Network {prop.putHTML(STR_TABLE_LIST + conCount + "_shortname", shortname);prop.putHTML(STR_TABLE_LIST + conCount + "_fullname", seed.get(Seed.NAME, "deadlink"));prop.put(STR_TABLE_LIST + conCount + "_special", (seed.getFlagRootNode() && !seed.getFlagAcceptRemoteIndex()) ? 1 : 0);+ prop.put(STR_TABLE_LIST + conCount + "_ssl", (seed.getFlagSSLAvailable()) ? 1 : 0);userAgent = null;if (seed.hash != null && seed.hash.equals(sb.peers.mySeed().hash)) {userAgent = ClientIdentification.getUserAgent();diff --git a/source/net/yacy/cora/document/ASCII.java b/source/net/yacy/cora/document/ASCII.javaindex 570ef829f..5b0cd36b6 100644--- a/source/net/yacy/cora/document/ASCII.java+++ b/source/net/yacy/cora/document/ASCII.java@@ -125,7 +125,7 @@ public class ASCII implements Comparator<String> {public final static byte[] getBytes(final String s) {assert s != null;- assert s.length() < 3 || s.charAt(2) != '@';+ //assert s.length() < 3 || s.charAt(2) != '@';int count = s.length();final byte[] b = new byte[count];for (int i = 0; i < count; i++) {diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.javaindex 04291049f..3cd0cb411 100644--- a/source/net/yacy/peers/Seed.java+++ b/source/net/yacy/peers/Seed.java@@ -100,19 +100,27 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>*/public static final String URL_IN = "rU";/**- * <b>substance</b> "virgin"+ * <b>substance</b> "virgin", a peer which cannot reach any other peers*/public static final String PEERTYPE_VIRGIN = "virgin";/**- * <b>substance</b> "junior"+ * <b>substance</b> "junior", this is a peer which cannot be reached from the outside*/public static final String PEERTYPE_JUNIOR = "junior";/**- * <b>substance</b> "senior"+ * <b>substance</b> "mentee", this is a junior peer with an mentor peer attached as 'remote' server port+ */+ public static final String PEERTYPE_MENTEE = "mentee";+ /**+ * <b>substance</b> "senior", this is a peer with an open port to the public*/public static final String PEERTYPE_SENIOR = "senior";/**- * <b>substance</b> "principal"+ * <b>substance</b> "mentor", this is a senior peer which hosts server ports for mentee peers+ */+ public static final String PEERTYPE_MENTOR = "mentor";+ /**+ * <b>substance</b> "principal", a senior peer which distributes the seed list to an outside hoster (i.e. using ftp upload to a web server)*/public static final String PEERTYPE_PRINCIPAL = "principal";/**@@ -123,7 +131,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>/** static/dynamic (if the IP changes often for any reason) */private static final String IPTYPE = "IPType";private static final String FLAGS = "Flags";- private static final String FLAGSZERO = "____";+ public static final String FLAGSZERO = " ";/** the applications version */public static final String VERSION = "Version";@@ -168,6 +176,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>private static final int FLAG_ACCEPT_REMOTE_CRAWL = 1;private static final int FLAG_ACCEPT_REMOTE_INDEX = 2;private static final int FLAG_ROOT_NODE = 3;+ private static final int FLAG_SSL_AVAILABLE = 4;public static final String DFLT_NETWORK_UNIT = "freeworld";public static final String DFLT_NETWORK_GROUP = "";@@ -758,41 +767,50 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>setFlag(FLAG_DIRECT_CONNECT, value);}- public final void setFlagAcceptRemoteCrawl(final boolean value) {- setFlag(FLAG_ACCEPT_REMOTE_CRAWL, value);- }-- public final void setFlagAcceptRemoteIndex(final boolean value) {- setFlag(FLAG_ACCEPT_REMOTE_INDEX, value);- }-- public final void setFlagRootNode(final boolean value) {- setFlag(FLAG_ROOT_NODE, value);- }-public final boolean getFlagDirectConnect() {return getFlag(FLAG_DIRECT_CONNECT);}+ public final void setFlagAcceptRemoteCrawl(final boolean value) {+ setFlag(FLAG_ACCEPT_REMOTE_CRAWL, value);+ }+public final boolean getFlagAcceptRemoteCrawl() {//if (getVersion() < 0.300) return false;//if (getVersion() < 0.334) return true;return getFlag(FLAG_ACCEPT_REMOTE_CRAWL);}+ public final void setFlagAcceptRemoteIndex(final boolean value) {+ setFlag(FLAG_ACCEPT_REMOTE_INDEX, value);+ }+public final boolean getFlagAcceptRemoteIndex() {//if (getVersion() < 0.335) return false;return getFlag(FLAG_ACCEPT_REMOTE_INDEX);}+ public final void setFlagRootNode(final boolean value) {+ setFlag(FLAG_ROOT_NODE, value);+ }+public final boolean getFlagRootNode() {double v = getVersion();if (v < 1.02009142d) return false;return getFlag(FLAG_ROOT_NODE);}+ public final void setFlagSSLAvailable(final boolean value) {+ setFlag(FLAG_SSL_AVAILABLE, value);+ }++ public final boolean getFlagSSLAvailable() {+ if (getVersion() < 1.5) return false;+ return getFlag(FLAG_SSL_AVAILABLE);+ }+public final void setUnusedFlags() {- for ( int i = 4; i < 24; i++ ) {+ for ( int i = 4; i < 20; i++ ) {setFlag(i, false);}}diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.javaindex 693b7b362..9b5c72607 100644--- a/source/net/yacy/search/Switchboard.java+++ b/source/net/yacy/search/Switchboard.java@@ -3524,33 +3524,35 @@ public final class Switchboard extends serverSwitch {//the speed of indexing (pages/minute) of the peerfinal long uptime = (System.currentTimeMillis() - serverCore.startupTime) / 1000;- this.peers.mySeed().put(Seed.ISPEED, Integer.toString(currentPPM()));- this.peers.mySeed().put(Seed.RSPEED, Float.toString(averageQPM()));- this.peers.mySeed().put(Seed.UPTIME, Long.toString(uptime / 60)); // the number of minutes that the peer is up in minutes/day (moving average MA30)+ Seed mySeed = this.peers.mySeed();++ mySeed.put(Seed.ISPEED, Integer.toString(currentPPM()));+ mySeed.put(Seed.RSPEED, Float.toString(averageQPM()));+ mySeed.put(Seed.UPTIME, Long.toString(uptime / 60)); // the number of minutes that the peer is up in minutes/day (moving average MA30)long t = System.currentTimeMillis();if (t - indexSizeTime > 60000) {indeSizeCache = sb.index.fulltext().collectionSize();indexSizeTime = t;}- this.peers.mySeed().put(Seed.LCOUNT, Long.toString(indeSizeCache)); // the number of links that the peer has stored (LURL's)- this.peers.mySeed().put(Seed.NCOUNT, Integer.toString(this.crawlQueues.noticeURL.size())); // the number of links that the peer has noticed, but not loaded (NURL's)- this.peers.mySeed().put(+ mySeed.put(Seed.LCOUNT, Long.toString(indeSizeCache)); // the number of links that the peer has stored (LURL's)+ mySeed.put(Seed.NCOUNT, Integer.toString(this.crawlQueues.noticeURL.size())); // the number of links that the peer has noticed, but not loaded (NURL's)+ mySeed.put(Seed.RCOUNT,Integer.toString(this.crawlQueues.noticeURL.stackSize(NoticedURL.StackType.GLOBAL))); // the number of links that the peer provides for remote crawling (ZURL's)- this.peers.mySeed().put(Seed.ICOUNT, Long.toString(this.index.RWICount())); // the minimum number of words that the peer has indexed (as it says)- this.peers.mySeed().put(Seed.SCOUNT, Integer.toString(this.peers.sizeConnected())); // the number of seeds that the peer has stored- this.peers.mySeed().put(+ mySeed.put(Seed.ICOUNT, Long.toString(this.index.RWICount())); // the minimum number of words that the peer has indexed (as it says)+ mySeed.put(Seed.SCOUNT, Integer.toString(this.peers.sizeConnected())); // the number of seeds that the peer has stored+ mySeed.put(Seed.CCOUNT,Float.toString(((int) ((this.peers.sizeConnected() + this.peers.sizeDisconnected() + this.peers.sizePotential()) * 60.0f / (uptime + 1.01f)) * 100.0f) / 100.0f)); // the number of clients that the peer connects (as connects/hour)- this.peers.mySeed().put(Seed.VERSION, yacyBuildProperties.getLongVersion());- this.peers.mySeed().setFlagDirectConnect(true);- this.peers.mySeed().setLastSeenUTC();- this.peers.mySeed().put(Seed.UTC, GenericFormatter.UTCDiffString());- this.peers.mySeed().setFlagAcceptRemoteCrawl(getConfigBool("crawlResponse", true));- this.peers.mySeed().setFlagAcceptRemoteIndex(getConfigBool("allowReceiveIndex", true));- //mySeed.setFlagAcceptRemoteIndex(true);+ mySeed.put(Seed.VERSION, yacyBuildProperties.getLongVersion());+ mySeed.setFlagDirectConnect(true);+ mySeed.setLastSeenUTC();+ mySeed.put(Seed.UTC, GenericFormatter.UTCDiffString());+ mySeed.setFlagAcceptRemoteCrawl(getConfigBool("crawlResponse", true));+ mySeed.setFlagAcceptRemoteIndex(getConfigBool("allowReceiveIndex", true));+ mySeed.setFlagSSLAvailable(getConfigBool("server.https", false));}public void loadSeedLists() {diff --git a/source/net/yacy/utils/bitfield.java b/source/net/yacy/utils/bitfield.javaindex fe7aebd55..81c1478ce 100644--- a/source/net/yacy/utils/bitfield.java+++ b/source/net/yacy/utils/bitfield.java@@ -4,10 +4,6 @@// first published on http://www.anomic.de// Frankfurt, Germany, 2004//-// $LastChangedDate$-// $LastChangedRevision$-// $LastChangedBy$-//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or@@ -24,6 +20,9 @@package net.yacy.utils;+import net.yacy.cora.document.ASCII;++public class bitfield {private byte[] bb;@@ -34,7 +33,7 @@ public class bitfield {public bitfield(final int bytelength) {this.bb= new byte[bytelength];- for (int i = 0 ; i < bytelength; i++) bb[i] = 0;+ for (int i = 0 ; i < bytelength; i++) bb[i] = ' ';}public bitfield(final byte[] field) {@@ -43,16 +42,18 @@ public class bitfield {private static byte setAtom(final byte a, final int pos) {if ((pos > 5) || (pos < 0)) throw new RuntimeException("atom position out of bounds: " + pos);- return (byte) ((64 | ((a + 16) | (1<<pos))) - 16);+ byte b = (byte) (((a - 32) | (1<<pos)) + 32);+ return b;}private static byte unsetAtom(final byte a, final int pos) {if ((pos > 5) || (pos < 0)) throw new RuntimeException("atom position out of bounds: " + pos);- return (byte) (((a + 16) & (0xff ^ (1<<pos))) - 16);+ byte b = (byte) (((a - 32) & (0xff ^ (1<<pos))) + 32);+ return b;}public void set(final int pos, final boolean value) {- final int slot = pos / 6;+ final int slot = pos / 5;if (pos < 0) throw new RuntimeException("position out of bounds: " + pos);if (slot > bb.length) {// extend capacity@@ -61,18 +62,19 @@ public class bitfield {for (int i = bb.length; i < nb.length; i++) nb[i] = 0;bb = nb;}- bb[slot] = (value) ? setAtom(bb[slot], pos % 6) : unsetAtom(bb[slot], pos % 6);+ bb[slot] = (value) ? setAtom(bb[slot], pos % 5) : unsetAtom(bb[slot], pos % 5);}public boolean get(final int pos) {- final int slot = pos / 6;+ final int slot = pos / 5;if (pos < 0) throw new RuntimeException("position out of bounds: " + pos);if (slot > bb.length) return false;- return (bb[slot] & (1<<(pos%6))) > 0;+ boolean b = ((bb[slot] - 32) & (1 << (pos % 5))) > 0;+ return b;}public int length() {- return bb.length * 6;+ return bb.length * 5;}public byte[] getBytes() {@@ -81,15 +83,25 @@ public class bitfield {@Overridepublic String toString() {- throw new UnsupportedOperationException("testing");- /*+ //throw new UnsupportedOperationException("testing");+StringBuilder sb = new StringBuilder(length());for (int i = length() - 1; i >= 0; i--) sb.append((get(i)) ? '1' : '0');- return sb.toString();- */+ return ASCII.String(bb) + " " + sb.toString();+}public static void main(final String[] args) {+ //final bitfield f = new bitfield(ASCII.getBytes(Seed.FLAGSZERO));+ final bitfield f = new bitfield(4);+ for (int i = 0; i < 20; i++) {+ f.set(i, false);+ if (f.get(i)) System.out.println("i = " + i);+ f.set(i, true);+ if (!f.get(i)) System.out.println("!i = " + i);+ System.out.println(i + ":" + f.toString());+ }+final bitfield test = new bitfield(4);final int l = test.length();System.out.println("available: " + l);