From zothar at freenetproject.org Tue Jan 2 15:56:00 2007 From: zothar at freenetproject.org (zothar at freenetproject.org) Date: Tue, 2 Jan 2007 15:56:00 +0000 (UTC) Subject: [freenet-cvs] r11541 - trunk/freenet/src/freenet/node Message-ID: <20070102155600.98AC99BBD2@emu.freenetproject.org> Author: zothar Date: 2007-01-02 15:55:59 +0000 (Tue, 02 Jan 2007) New Revision: 11541 Modified: trunk/freenet/src/freenet/node/PeerNode.java Log: Stop any ARK fetcher for a peer if we set it ListenOnly. Modified: trunk/freenet/src/freenet/node/PeerNode.java =================================================================== --- trunk/freenet/src/freenet/node/PeerNode.java 2007-01-01 20:01:13 UTC (rev 11540) +++ trunk/freenet/src/freenet/node/PeerNode.java 2007-01-02 15:55:59 UTC (rev 11541) @@ -2492,6 +2492,7 @@ if(setting && isBurstOnly()) { setBurstOnly(false); } + stopARKFetcher(); setPeerNodeStatus(System.currentTimeMillis()); node.peers.writePeers(); } From zothar at freenetproject.org Wed Jan 3 02:10:49 2007 From: zothar at freenetproject.org (zothar at freenetproject.org) Date: Wed, 3 Jan 2007 02:10:49 +0000 (UTC) Subject: [freenet-cvs] r11548 - trunk/freenet/src/freenet/support Message-ID: <20070103021049.7490A9BB57@emu.freenetproject.org> Author: zothar Date: 2007-01-03 02:10:48 +0000 (Wed, 03 Jan 2007) New Revision: 11548 Modified: trunk/freenet/src/freenet/support/Fields.java Log: Comment about an NPE I got in support/Fields.java; I'm not familiar enough with the code to be sure a if null test is smart there. Modified: trunk/freenet/src/freenet/support/Fields.java =================================================================== --- trunk/freenet/src/freenet/support/Fields.java 2007-01-03 00:07:06 UTC (rev 11547) +++ trunk/freenet/src/freenet/support/Fields.java 2007-01-03 02:10:48 UTC (rev 11548) @@ -157,6 +157,11 @@ public static final String[] commaList(String ls) { StringTokenizer st = new StringTokenizer(ls, ","); + // FIXME: Next line can NPE + // at java.lang.String.charAt(String.java:560) + // at java.util.StringTokenizer.skipDelimiters(StringTokenizer.java:234) + // at java.util.StringTokenizer.countTokens(StringTokenizer.java:406) + // at freenet.support.Fields.commaList(Fields.java:160) String[] r = new String[st.countTokens()]; for (int i = 0; i < r.length; i++) { r[i] = st.nextToken().trim(); From zothar at freenetproject.org Wed Jan 3 04:34:31 2007 From: zothar at freenetproject.org (zothar at freenetproject.org) Date: Wed, 3 Jan 2007 04:34:31 +0000 (UTC) Subject: [freenet-cvs] r11550 - trunk/freenet/src/freenet/node Message-ID: <20070103043431.25D8B9BB57@emu.freenetproject.org> Author: zothar Date: 2007-01-03 04:34:29 +0000 (Wed, 03 Jan 2007) New Revision: 11550 Modified: trunk/freenet/src/freenet/node/PeerNode.java Log: Only stop ARK fetcher if we're setting ListenOnly, but not if clearing it. Modified: trunk/freenet/src/freenet/node/PeerNode.java =================================================================== --- trunk/freenet/src/freenet/node/PeerNode.java 2007-01-03 04:12:02 UTC (rev 11549) +++ trunk/freenet/src/freenet/node/PeerNode.java 2007-01-03 04:34:29 UTC (rev 11550) @@ -2492,7 +2492,9 @@ if(setting && isBurstOnly()) { setBurstOnly(false); } - stopARKFetcher(); + if(setting) { + stopARKFetcher(); + } setPeerNodeStatus(System.currentTimeMillis()); node.peers.writePeers(); } From zothar at freenetproject.org Wed Jan 3 05:44:29 2007 From: zothar at freenetproject.org (zothar at freenetproject.org) Date: Wed, 3 Jan 2007 05:44:29 +0000 (UTC) Subject: [freenet-cvs] r11551 - in trunk/freenet/src/freenet/node: . useralerts Message-ID: <20070103054429.3BDD79BB47@emu.freenetproject.org> Author: zothar Date: 2007-01-03 05:44:28 +0000 (Wed, 03 Jan 2007) New Revision: 11551 Modified: trunk/freenet/src/freenet/node/Node.java trunk/freenet/src/freenet/node/useralerts/N2NTMUserAlert.java Log: Add compose/send/receive times to N2NTM user alert display Modified: trunk/freenet/src/freenet/node/Node.java =================================================================== --- trunk/freenet/src/freenet/node/Node.java 2007-01-03 04:34:29 UTC (rev 11550) +++ trunk/freenet/src/freenet/node/Node.java 2007-01-03 05:44:28 UTC (rev 11551) @@ -2975,15 +2975,21 @@ String source_nodename = null; String target_nodename = null; String text = null; + long composedTime = -1; + long sentTime = -1; + long receivedTime = -1; try { source_nodename = new String(Base64.decode(fs.get("source_nodename"))); target_nodename = new String(Base64.decode(fs.get("target_nodename"))); text = new String(Base64.decode(fs.get("text"))); + composedTime = fs.getLong("composedTime", -1); + sentTime = fs.getLong("sentTime", -1); + receivedTime = fs.getLong("receivedTime", -1); } catch (IllegalBase64Exception e) { Logger.error(this, "Bad Base64 encoding when decoding a N2NTM SimpleFieldSet", e); return; } - N2NTMUserAlert userAlert = new N2NTMUserAlert(source, source_nodename, target_nodename, text, fileNumber); + N2NTMUserAlert userAlert = new N2NTMUserAlert(source, source_nodename, target_nodename, text, fileNumber, composedTime, sentTime, receivedTime); clientCore.alerts.register(userAlert); } else { Logger.error(this, "Received unknown node to node message type '"+type+"' from "+source.getPeer()); Modified: trunk/freenet/src/freenet/node/useralerts/N2NTMUserAlert.java =================================================================== --- trunk/freenet/src/freenet/node/useralerts/N2NTMUserAlert.java 2007-01-03 04:34:29 UTC (rev 11550) +++ trunk/freenet/src/freenet/node/useralerts/N2NTMUserAlert.java 2007-01-03 05:44:28 UTC (rev 11551) @@ -3,6 +3,9 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.node.useralerts; +import java.text.DateFormat; +import java.util.Date; + import freenet.node.PeerNode; import freenet.support.HTMLEncoder; import freenet.support.HTMLNode; @@ -15,13 +18,19 @@ private String targetNodename; private String messageText; private int fileNumber; + private long composedTime; + private long sentTime; + private long receivedTime; - public N2NTMUserAlert(PeerNode sourcePeerNode, String source, String target, String message, int fileNumber) { - this.sourcePeerNode = sourcePeerNode; + public N2NTMUserAlert(PeerNode sourcePeerNode, String source, String target, String message, int fileNumber, long composedTime, long sentTime, long receivedTime) { + this.sourcePeerNode = sourcePeerNode; this.sourceNodename = source; this.targetNodename = target; this.messageText = message; this.fileNumber = fileNumber; + this.composedTime = composedTime; + this.sentTime = sentTime; + this.receivedTime = receivedTime; isValid=true; } @@ -52,7 +61,7 @@ public HTMLNode getHTMLText() { HTMLNode alertNode = new HTMLNode("div"); - alertNode.addChild("p", "From: " + sourceNodename); + alertNode.addChild("p", "From: " + sourceNodename + " (composed: " + DateFormat.getInstance().format(new Date(composedTime)) + "/sent: " + DateFormat.getInstance().format(new Date(sentTime)) + "/received: " + DateFormat.getInstance().format(new Date(receivedTime)) + ')'); String[] lines = messageText.split("\n"); for (int i = 0, c = lines.length; i < c; i++) { alertNode.addChild("div", lines[i]); From nextgens at freenetproject.org Wed Jan 3 13:50:48 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 3 Jan 2007 13:50:48 +0000 (UTC) Subject: [freenet-cvs] r11553 - in trunk/freenet/src/freenet: node support Message-ID: <20070103135048.ED3D59BB46@emu.freenetproject.org> Author: nextgens Date: 2007-01-03 13:50:48 +0000 (Wed, 03 Jan 2007) New Revision: 11553 Modified: trunk/freenet/src/freenet/node/Version.java trunk/freenet/src/freenet/support/Fields.java Log: Fix an NPE reported by zothar: [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | java.lang.NullPointerException [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at java.lang.String.charAt(String.java:560) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at java.util.StringTokenizer.skipDelimiters(StringTokenizer.java:234) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at java.util.StringTokenizer.countTokens(StringTokenizer.java:406) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at freenet.support.Fields.commaList(Fields.java:160) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at freenet.node.Version.checkArbitraryGoodVersion(Version.java:197) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at freenet.node.PeerNode.publicReverseInvalidVersion(PeerNode.java:1608) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at freenet.node.PeerNodeStatus.(PeerNodeStatus.java:117) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at freenet.node.PeerNode.getStatus(PeerNode.java:1823) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at freenet.node.Node.getPeerNodeStatuses(Node.java:3161) [13:41] < Zothar_Work> | INFO | jvm 2 | 2007/01/02 10:01:41 | at freenet.node.Node.maybeLogPeerNodeStatusSummary(Node.java:2819) Modified: trunk/freenet/src/freenet/node/Version.java =================================================================== --- trunk/freenet/src/freenet/node/Version.java 2007-01-03 07:32:39 UTC (rev 11552) +++ trunk/freenet/src/freenet/node/Version.java 2007-01-03 13:50:48 UTC (rev 11553) @@ -196,10 +196,10 @@ String[] v = Fields.commaList(version); String[] lgv = Fields.commaList(lastGoodVersion); - if ((v.length < 3) || !goodProtocol(v[2])) { + if ((v == null || v.length < 3) || !goodProtocol(v[2])) { return false; } - if ((lgv.length < 3) || !goodProtocol(lgv[2])) { + if ((lgv == null || lgv.length < 3) || !goodProtocol(lgv[2])) { return false; } if (sameArbitraryVersion(v,lgv)) { Modified: trunk/freenet/src/freenet/support/Fields.java =================================================================== --- trunk/freenet/src/freenet/support/Fields.java 2007-01-03 07:32:39 UTC (rev 11552) +++ trunk/freenet/src/freenet/support/Fields.java 2007-01-03 13:50:48 UTC (rev 11553) @@ -156,12 +156,8 @@ } public static final String[] commaList(String ls) { + if(ls == null) return null; StringTokenizer st = new StringTokenizer(ls, ","); - // FIXME: Next line can NPE - // at java.lang.String.charAt(String.java:560) - // at java.util.StringTokenizer.skipDelimiters(StringTokenizer.java:234) - // at java.util.StringTokenizer.countTokens(StringTokenizer.java:406) - // at freenet.support.Fields.commaList(Fields.java:160) String[] r = new String[st.countTokens()]; for (int i = 0; i < r.length; i++) { r[i] = st.nextToken().trim(); From nextgens at freenetproject.org Wed Jan 3 14:09:26 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 3 Jan 2007 14:09:26 +0000 (UTC) Subject: [freenet-cvs] r11554 - trunk/apps/new_installer/src Message-ID: <20070103140926.1BC979BB46@emu.freenetproject.org> Author: nextgens Date: 2007-01-03 14:09:25 +0000 (Wed, 03 Jan 2007) New Revision: 11554 Modified: trunk/apps/new_installer/src/Sha1Test.java Log: new_installer: fix #1050 - bin/1run.sh tries to write at fs root Modified: trunk/apps/new_installer/src/Sha1Test.java =================================================================== --- trunk/apps/new_installer/src/Sha1Test.java 2007-01-03 13:50:48 UTC (rev 11553) +++ trunk/apps/new_installer/src/Sha1Test.java 2007-01-03 14:09:25 UTC (rev 11554) @@ -14,7 +14,7 @@ public static void main(String[] args) { final String URI2 = args[0]; - final String path = args[1]+"/"; + final String path = (args[1] == null ? '.' : args[1] )+"/"; int count = 0; if(URI2 == null) System.exit(2); From nextgens at freenetproject.org Wed Jan 3 14:14:01 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 3 Jan 2007 14:14:01 +0000 (UTC) Subject: [freenet-cvs] r11555 - trunk/apps/new_installer/src Message-ID: <20070103141401.EDFF39BB46@emu.freenetproject.org> Author: nextgens Date: 2007-01-03 14:14:00 +0000 (Wed, 03 Jan 2007) New Revision: 11555 Modified: trunk/apps/new_installer/src/Sha1Test.java Log: doh Modified: trunk/apps/new_installer/src/Sha1Test.java =================================================================== --- trunk/apps/new_installer/src/Sha1Test.java 2007-01-03 14:09:25 UTC (rev 11554) +++ trunk/apps/new_installer/src/Sha1Test.java 2007-01-03 14:14:00 UTC (rev 11555) @@ -14,7 +14,7 @@ public static void main(String[] args) { final String URI2 = args[0]; - final String path = (args[1] == null ? '.' : args[1] )+"/"; + final String path = (args[1] == null ? "." : args[1] )+"/"; int count = 0; if(URI2 == null) System.exit(2); From nextgens at freenetproject.org Wed Jan 3 14:39:09 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 3 Jan 2007 14:39:09 +0000 (UTC) Subject: [freenet-cvs] r11556 - in trunk/apps/new_installer: res/unix/bin src Message-ID: <20070103143909.9130C9BBA8@emu.freenetproject.org> Author: nextgens Date: 2007-01-03 14:39:08 +0000 (Wed, 03 Jan 2007) New Revision: 11556 Modified: trunk/apps/new_installer/res/unix/bin/1run.sh trunk/apps/new_installer/src/Sha1Test.java Log: Doh, part 2 Modified: trunk/apps/new_installer/res/unix/bin/1run.sh =================================================================== --- trunk/apps/new_installer/res/unix/bin/1run.sh 2007-01-03 14:14:00 UTC (rev 11555) +++ trunk/apps/new_installer/res/unix/bin/1run.sh 2007-01-03 14:39:08 UTC (rev 11556) @@ -4,6 +4,7 @@ then DST="$INSTALL_PATH" else + echo "Installing from tarball" DST="." fi Modified: trunk/apps/new_installer/src/Sha1Test.java =================================================================== --- trunk/apps/new_installer/src/Sha1Test.java 2007-01-03 14:14:00 UTC (rev 11555) +++ trunk/apps/new_installer/src/Sha1Test.java 2007-01-03 14:39:08 UTC (rev 11556) @@ -14,7 +14,7 @@ public static void main(String[] args) { final String URI2 = args[0]; - final String path = (args[1] == null ? "." : args[1] )+"/"; + final String path = (args.length < 2 ? "." : args[1] )+"/"; int count = 0; if(URI2 == null) System.exit(2); From nextgens at freenetproject.org Wed Jan 3 14:44:29 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 3 Jan 2007 14:44:29 +0000 (UTC) Subject: [freenet-cvs] r11557 - trunk/freenet/src/freenet/config Message-ID: <20070103144429.B93309BB99@emu.freenetproject.org> Author: nextgens Date: 2007-01-03 14:44:28 +0000 (Wed, 03 Jan 2007) New Revision: 11557 Modified: trunk/freenet/src/freenet/config/FilePersistentConfig.java Log: Fix #786 - ERROR: Initialization not finished, refusing to write config ; it ought to be logged at MINOR Modified: trunk/freenet/src/freenet/config/FilePersistentConfig.java =================================================================== --- trunk/freenet/src/freenet/config/FilePersistentConfig.java 2007-01-03 14:39:08 UTC (rev 11556) +++ trunk/freenet/src/freenet/config/FilePersistentConfig.java 2007-01-03 14:44:28 UTC (rev 11557) @@ -114,7 +114,7 @@ public void store() { synchronized(this) { if(!finishedInit) { - Logger.error(this, "Initialization not finished, refusing to write config", new Exception("error")); + Logger.minor(this, "Initialization not finished, refusing to write config", new Exception("error")); return; } } From nextgens at freenetproject.org Wed Jan 3 14:52:24 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 3 Jan 2007 14:52:24 +0000 (UTC) Subject: [freenet-cvs] r11558 - trunk/apps/new_installer/res/unix/bin Message-ID: <20070103145224.9B3CC9BB99@emu.freenetproject.org> Author: nextgens Date: 2007-01-03 14:52:23 +0000 (Wed, 03 Jan 2007) New Revision: 11558 Modified: trunk/apps/new_installer/res/unix/bin/1run.sh Log: new_installer: from the man : -n STRING the length of STRING is nonzero STRING equivalent to -n STRING ... cool but they forgot to say that -n is a valid string Modified: trunk/apps/new_installer/res/unix/bin/1run.sh =================================================================== --- trunk/apps/new_installer/res/unix/bin/1run.sh 2007-01-03 14:44:28 UTC (rev 11557) +++ trunk/apps/new_installer/res/unix/bin/1run.sh 2007-01-03 14:52:23 UTC (rev 11558) @@ -1,6 +1,6 @@ #!/bin/sh -if test -n $DST +if test $DST then DST="$INSTALL_PATH" else From nextgens at freenetproject.org Wed Jan 3 15:37:39 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 3 Jan 2007 15:37:39 +0000 (UTC) Subject: [freenet-cvs] r11559 - trunk/apps/new_installer/res/unix/bin Message-ID: <20070103153739.B95AE9BB2A@emu.freenetproject.org> Author: nextgens Date: 2007-01-03 15:37:38 +0000 (Wed, 03 Jan 2007) New Revision: 11559 Modified: trunk/apps/new_installer/res/unix/bin/1run.sh Log: new_installer: simplify the script ; thanks to aga for suggesting improvments Modified: trunk/apps/new_installer/res/unix/bin/1run.sh =================================================================== --- trunk/apps/new_installer/res/unix/bin/1run.sh 2007-01-03 14:52:23 UTC (rev 11558) +++ trunk/apps/new_installer/res/unix/bin/1run.sh 2007-01-03 15:37:38 UTC (rev 11559) @@ -1,15 +1,8 @@ #!/bin/sh -if test $DST -then - DST="$INSTALL_PATH" -else - echo "Installing from tarball" - DST="." -fi +INSTALL_PATH=${INSTALL_PATH:-$PWD} -echo "Installing freenet in $INSTALL_PATH" -cd "$DST" +cd $INSTALL_PATH if test -s freenet-ext.jar then echo "This script isn't meant to be used more than once." @@ -93,13 +86,13 @@ echo -e "console.enabled=true\nconsole.port=$CONSOLE_PORT" >> freenet.ini echo "Downloading freenet-stable-latest.jar" -java -jar bin/sha1test.jar freenet-stable-latest.jar "$DST" &>/dev/null || exit 1 +java -jar bin/sha1test.jar freenet-stable-latest.jar $INSTALL_PATH &>/dev/null || exit 1 ln -s freenet-stable-latest.jar freenet.jar echo "Downloading freenet-ext.jar" -java -jar bin/sha1test.jar freenet-ext.jar "$DST" &>/dev/null || exit 1 +java -jar bin/sha1test.jar freenet-ext.jar $INSTALL_PATH &>/dev/null || exit 1 echo "Downloading update.sh" -java -jar bin/sha1test.jar update/update.sh "$DST" &>/dev/null || exit 1 -chmod +x $DST/update.sh +java -jar bin/sha1test.jar update/update.sh $INSTALL_PATH &>/dev/null || exit 1 +chmod +x $INSTALL_PATH/update.sh # Starting the node up ./run.sh start @@ -130,7 +123,7 @@ echo "Starting up a browser" java -cp bin/browser.jar BareBonesBrowserLaunch "http://127.0.0.1:$FPROXY_PORT/" -java -cp bin/browser.jar BareBonesBrowserLaunch "file:///$INSTALL_PATH/welcome.html" +java -cp bin/browser.jar BareBonesBrowserLaunch "file://$INSTALL_PATH/welcome.html" echo "Finished" From zothar at freenetproject.org Wed Jan 3 20:49:49 2007 From: zothar at freenetproject.org (zothar at freenetproject.org) Date: Wed, 3 Jan 2007 20:49:49 +0000 (UTC) Subject: [freenet-cvs] r11561 - trunk/freenet/src/freenet/node/useralerts Message-ID: <20070103204949.3A3109BBA6@emu.freenetproject.org> Author: zothar Date: 2007-01-03 20:49:48 +0000 (Wed, 03 Jan 2007) New Revision: 11561 Modified: trunk/freenet/src/freenet/node/useralerts/N2NTMUserAlert.java Log: Tweaked compose/send/receive times separator for N2NTM user alert display Modified: trunk/freenet/src/freenet/node/useralerts/N2NTMUserAlert.java =================================================================== --- trunk/freenet/src/freenet/node/useralerts/N2NTMUserAlert.java 2007-01-03 18:01:33 UTC (rev 11560) +++ trunk/freenet/src/freenet/node/useralerts/N2NTMUserAlert.java 2007-01-03 20:49:48 UTC (rev 11561) @@ -61,7 +61,7 @@ public HTMLNode getHTMLText() { HTMLNode alertNode = new HTMLNode("div"); - alertNode.addChild("p", "From: " + sourceNodename + " (composed: " + DateFormat.getInstance().format(new Date(composedTime)) + "/sent: " + DateFormat.getInstance().format(new Date(sentTime)) + "/received: " + DateFormat.getInstance().format(new Date(receivedTime)) + ')'); + alertNode.addChild("p", "From: " + sourceNodename + " (composed: " + DateFormat.getInstance().format(new Date(composedTime)) + " | sent: " + DateFormat.getInstance().format(new Date(sentTime)) + " | received: " + DateFormat.getInstance().format(new Date(receivedTime)) + ')'); String[] lines = messageText.split("\n"); for (int i = 0, c = lines.length; i < c; i++) { alertNode.addChild("div", lines[i]); From nextgens at freenetproject.org Wed Jan 3 23:26:34 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 3 Jan 2007 23:26:34 +0000 (UTC) Subject: [freenet-cvs] r11563 - trunk/apps/new_installer/res/unix/bin Message-ID: <20070103232634.8FA809BBE4@emu.freenetproject.org> Author: nextgens Date: 2007-01-03 23:26:33 +0000 (Wed, 03 Jan 2007) New Revision: 11563 Modified: trunk/apps/new_installer/res/unix/bin/1run.sh Log: new_installer: what if the path contains spaces ? it will probably break because the lack of urlencoding anyway :/ Modified: trunk/apps/new_installer/res/unix/bin/1run.sh =================================================================== --- trunk/apps/new_installer/res/unix/bin/1run.sh 2007-01-03 22:29:36 UTC (rev 11562) +++ trunk/apps/new_installer/res/unix/bin/1run.sh 2007-01-03 23:26:33 UTC (rev 11563) @@ -1,8 +1,8 @@ #!/bin/sh -INSTALL_PATH=${INSTALL_PATH:-$PWD} +INSTALL_PATH="${INSTALL_PATH:-$PWD}" -cd $INSTALL_PATH +cd "$INSTALL_PATH" if test -s freenet-ext.jar then echo "This script isn't meant to be used more than once." @@ -86,12 +86,12 @@ echo -e "console.enabled=true\nconsole.port=$CONSOLE_PORT" >> freenet.ini echo "Downloading freenet-stable-latest.jar" -java -jar bin/sha1test.jar freenet-stable-latest.jar $INSTALL_PATH &>/dev/null || exit 1 +java -jar bin/sha1test.jar freenet-stable-latest.jar "$INSTALL_PATH" &>/dev/null || exit 1 ln -s freenet-stable-latest.jar freenet.jar echo "Downloading freenet-ext.jar" -java -jar bin/sha1test.jar freenet-ext.jar $INSTALL_PATH &>/dev/null || exit 1 +java -jar bin/sha1test.jar freenet-ext.jar "$INSTALL_PATH" &>/dev/null || exit 1 echo "Downloading update.sh" -java -jar bin/sha1test.jar update/update.sh $INSTALL_PATH &>/dev/null || exit 1 +java -jar bin/sha1test.jar update/update.sh "$INSTALL_PATH" &>/dev/null || exit 1 chmod +x $INSTALL_PATH/update.sh # Starting the node up From nextgens at freenetproject.org Thu Jan 4 20:19:50 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Thu, 4 Jan 2007 20:19:50 +0000 (UTC) Subject: [freenet-cvs] r11565 - trunk/apps/new_installer Message-ID: <20070104201950.32E979BBA8@emu.freenetproject.org> Author: nextgens Date: 2007-01-04 20:19:49 +0000 (Thu, 04 Jan 2007) New Revision: 11565 Modified: trunk/apps/new_installer/Unix_shortcutSpec.xml Log: new_installer: create icons for both thaw and frost even on unix Modified: trunk/apps/new_installer/Unix_shortcutSpec.xml =================================================================== --- trunk/apps/new_installer/Unix_shortcutSpec.xml 2007-01-04 20:11:06 UTC (rev 11564) +++ trunk/apps/new_installer/Unix_shortcutSpec.xml 2007-01-04 20:19:49 UTC (rev 11565) @@ -59,6 +59,50 @@ createForAll="false" description="This uninstalls Freenet"> - + + + + + + + + + + + From nextgens at freenetproject.org Thu Jan 4 23:06:36 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Thu, 4 Jan 2007 23:06:36 +0000 (UTC) Subject: [freenet-cvs] r11567 - trunk/apps/new_installer Message-ID: <20070104230636.52CF19BBAE@emu.freenetproject.org> Author: nextgens Date: 2007-01-04 23:06:34 +0000 (Thu, 04 Jan 2007) New Revision: 11567 Modified: trunk/apps/new_installer/Unix_shortcutSpec.xml Log: doh Modified: trunk/apps/new_installer/Unix_shortcutSpec.xml =================================================================== --- trunk/apps/new_installer/Unix_shortcutSpec.xml 2007-01-04 20:42:12 UTC (rev 11566) +++ trunk/apps/new_installer/Unix_shortcutSpec.xml 2007-01-04 23:06:34 UTC (rev 11567) @@ -70,7 +70,7 @@ startMenu="no" startup="no" target="java" - commandLine="-jar "$INSTALL_PATH/thaw.jar"" + commandLine="-jar "$INSTALL_PATH/Thaw.jar"" initialState="noShow" iconFile="trashcan_full" From Jogy at freenetproject.org Fri Jan 5 13:23:47 2007 From: Jogy at freenetproject.org (Jogy at freenetproject.org) Date: Fri, 5 Jan 2007 13:23:47 +0000 (UTC) Subject: [freenet-cvs] r11570 - in trunk/freenet/src/freenet/clients/http: . staticfiles/themes/boxed staticfiles/themes/clean staticfiles/themes/grayandblue staticfiles/themes/sky Message-ID: <20070105132347.1992B9BC04@emu.freenetproject.org> Author: Jogy Date: 2007-01-05 13:23:46 +0000 (Fri, 05 Jan 2007) New Revision: 11570 Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java trunk/freenet/src/freenet/clients/http/staticfiles/themes/boxed/theme.css trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css trunk/freenet/src/freenet/clients/http/staticfiles/themes/grayandblue/theme.css trunk/freenet/src/freenet/clients/http/staticfiles/themes/sky/theme.css Log: * Center the peer circles within their boxes * Make the peer histogram distinguish between connected and disconnected peers Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java 2007-01-05 06:55:26 UTC (rev 11569) +++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java 2007-01-05 13:23:46 UTC (rev 11570) @@ -552,12 +552,13 @@ private final static int PEER_CIRCLE_RADIUS = 100; private final static int PEER_CIRCLE_INNER_RADIUS = 60; private final static long MAX_CIRCLE_AGE_THRESHOLD = 24l*60*60*1000; // 24 hours + private final static int HISTOGRAM_LENGTH = 10; private final DecimalFormat fix1p2 = new DecimalFormat("0.00"); private final DecimalFormat fix3p1US = new DecimalFormat("##0.0", new DecimalFormatSymbols(Locale.US)); private final DecimalFormat fix3pctUS = new DecimalFormat("##0%", new DecimalFormatSymbols(Locale.US)); private void addNodeCircle (HTMLNode htmlNode) { - HTMLNode nodeCircleInfoboxContentDiv = htmlNode.addChild("div", new String[] { "style", "class" }, new String[] {"position: relative; height: " + (PEER_CIRCLE_RADIUS * 2 + 15) + "px", "peercircle" }); + HTMLNode nodeCircleInfoboxContentDiv = htmlNode.addChild("div", new String[] { "style", "class" }, new String[] {"position: relative; height: " + (PEER_CIRCLE_RADIUS * 2 + 10) + "px; width: " + (PEER_CIRCLE_RADIUS * 2 + 10) + "px", "peercircle" }); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0, false, 1.0), "mark" }, "|"); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.125, false, 1.0), "mark" }, "+"); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.25, false, 1.0), "mark" }, "--"); @@ -589,9 +590,11 @@ } private void addPeerCircle (HTMLNode circleTable) { - int[] histogram = new int[ 10 ]; - for (int i = 0; i < histogram.length; i++) { - histogram[ i ] = 0; + int[] histogramConnected = new int[HISTOGRAM_LENGTH]; + int[] histogramDisconnected = new int[HISTOGRAM_LENGTH]; + for (int i = 0; i < HISTOGRAM_LENGTH; i++) { + histogramConnected[i] = 0; + histogramDisconnected[i] = 0; } HTMLNode peerCircleTableRow = circleTable.addChild("tr"); HTMLNode peerHistogramLegendTableRow = circleTable.addChild("tr"); @@ -599,7 +602,7 @@ HTMLNode peerCircleTableCell = peerCircleTableRow.addChild("td", new String[] { "class", "colspan" }, new String[] {"first", "10"}); HTMLNode peerHistogramLegendCell; HTMLNode peerHistogramGraphCell; - HTMLNode peerCircleInfoboxContent = peerCircleTableCell.addChild("div", new String[] { "style", "class" }, new String[] {"position: relative; height: " + (PEER_CIRCLE_RADIUS * 2 + 15) + "px; padding-bottom: 10px;", "peercircle" }); + HTMLNode peerCircleInfoboxContent = peerCircleTableCell.addChild("div", new String[] { "style", "class" }, new String[] {"position: relative; height: " + (PEER_CIRCLE_RADIUS * 2 + 10) + "px; width: " + (PEER_CIRCLE_RADIUS * 2 + 10) + "px", "peercircle" }); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0, false, 1.0), "mark" }, "|"); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.125, false, 1.0), "mark" }, "+"); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.25, false, 1.0), "mark" }, "--"); @@ -620,20 +623,28 @@ peerNodeStatus = peerNodeStatuses[peerIndex]; peerLocation = peerNodeStatus.getLocation(); peerDistance = PeerManager.distance( myLocation, peerLocation ); - histogramIndex = (int) (Math.floor(peerDistance * 10 * 2)); - histogram[ histogramIndex ] += 1; - peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(peerLocation, false, (1.0 - peerNodeStatus.getPReject())), ((peerNodeStatus.isConnected())?"connected":"disconnected") }, "x"); + histogramIndex = (int) (Math.floor(peerDistance * HISTOGRAM_LENGTH * 2)); + if (peerNodeStatus.isConnected()) { + histogramConnected[histogramIndex]++; + } else { + histogramDisconnected[histogramIndex]++; + } + peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(peerLocation, false, (1.0 - peerNodeStatus.getPReject())), ((peerNodeStatus.isConnected())?"connected":"disconnected") }, "x"); } - double histogramPercent; - for (int i = 0; i < histogram.length; i++) { + peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(myLocation, true, 1.0), "me" }, "x"); + // + double histogramPercent; + for (int i = 0; i < HISTOGRAM_LENGTH; i++) { peerHistogramLegendCell = peerHistogramLegendTableRow.addChild("td"); peerHistogramGraphCell = peerHistogramGraphTableRow.addChild("td", "style", "height: 100px;"); - histogramPercent = ((double) histogram[ i ] ) / peerCount; - peerHistogramLegendCell.addChild("div", "style", "font-size: 60%; margin-left: 3px; margin-right: 3px;").addChild("#", fix1p2.format(((double) i) / ( 10 * 2 ))); - peerHistogramGraphCell.addChild("div", new String[] { "class", "style" }, new String[] { "progressbar-done", "height: " + fix3pctUS.format(histogramPercent) + "; width: 100%;" }, "\u00a0"); + peerHistogramLegendCell.addChild("div", "class", "histogramLabel").addChild("#", fix1p2.format(((double) i) / ( 10 * 2 ))); + // + histogramPercent = ((double) histogramConnected[ i ] ) / peerCount; + peerHistogramGraphCell.addChild("div", new String[] { "class", "style" }, new String[] { "histogramConnected", "height: " + fix3pctUS.format(histogramPercent) + "; width: 100%;" }, "\u00a0"); + // + histogramPercent = ((double) histogramDisconnected[ i ] ) / peerCount; + peerHistogramGraphCell.addChild("div", new String[] { "class", "style" }, new String[] { "histogramDisconnected", "height: " + fix3pctUS.format(histogramPercent) + "; width: 100%;" }, "\u00a0"); } - // - peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(myLocation, true, 1.0), "me" }, "x"); } private String generatePeerCircleStyleString (double peerLocation, boolean offsetMe, double strength) { Modified: trunk/freenet/src/freenet/clients/http/staticfiles/themes/boxed/theme.css =================================================================== --- trunk/freenet/src/freenet/clients/http/staticfiles/themes/boxed/theme.css 2007-01-05 06:55:26 UTC (rev 11569) +++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/boxed/theme.css 2007-01-05 13:23:46 UTC (rev 11570) @@ -186,6 +186,10 @@ color: #840; } +div.peercircle { + margin: 0 auto; +} + div.peercircle span.mark { color: #d0d0d0; } @@ -210,6 +214,20 @@ font-weight: bold; } +div.histogramLabel { + margin-left: 3px; + margin-right: 3px; + font-size: 60%; +} + +div.histogramConnected { + background-color: #008000; +} + +div.histogramDisconnected { + background-color: #d0d0d0; +} + th { text-align: center; background-color: #aaa; Modified: trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css =================================================================== --- trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css 2007-01-05 06:55:26 UTC (rev 11569) +++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css 2007-01-05 13:23:46 UTC (rev 11570) @@ -358,6 +358,12 @@ font-size: 7pt; } +/* statistics page */ + +div.peercircle { + margin: 0 auto; +} + div.peercircle span.mark { color: #d0d0d0; } @@ -382,6 +388,20 @@ font-weight: bold; } +div.histogramLabel { + margin-left: 3px; + margin-right: 3px; + font-size: 60%; +} + +div.histogramConnected { + background-color: #008000; +} + +div.histogramDisconnected { + background-color: #d0d0d0; +} + /* queue page */ table.queue th, table.queue td { Modified: trunk/freenet/src/freenet/clients/http/staticfiles/themes/grayandblue/theme.css =================================================================== --- trunk/freenet/src/freenet/clients/http/staticfiles/themes/grayandblue/theme.css 2007-01-05 06:55:26 UTC (rev 11569) +++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/grayandblue/theme.css 2007-01-05 13:23:46 UTC (rev 11570) @@ -372,6 +372,12 @@ font-size: 7pt; } +/* statistics page */ + +div.peercircle { + margin: 0 auto; +} + div.peercircle span.mark { color: #d0d0d0; } @@ -396,6 +402,20 @@ font-weight: bold; } +div.histogramLabel { + margin-left: 3px; + margin-right: 3px; + font-size: 60%; +} + +div.histogramConnected { + background-color: #008000; +} + +div.histogramDisconnected { + background-color: #d0d0d0; +} + /* queue page */ table.queue th, table.queue td { Modified: trunk/freenet/src/freenet/clients/http/staticfiles/themes/sky/theme.css =================================================================== --- trunk/freenet/src/freenet/clients/http/staticfiles/themes/sky/theme.css 2007-01-05 06:55:26 UTC (rev 11569) +++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/sky/theme.css 2007-01-05 13:23:46 UTC (rev 11570) @@ -366,6 +366,24 @@ font-size: 7pt; } +#reftext { + width: 100%; +} + +#refurl { + width: 100%; +} + +#reffile { + width: 100%; +} + +/* statistics page */ + +div.peercircle { + margin: 0 auto; +} + div.peercircle span.mark { color: #d0d0d0; } @@ -390,16 +408,18 @@ font-weight: bold; } -#reftext { - width: 100%; +div.histogramLabel { + margin-left: 3px; + margin-right: 3px; + font-size: 60%; } -#refurl { - width: 100%; +div.histogramConnected { + background-color: #008000; } -#reffile { - width: 100%; +div.histogramDisconnected { + background-color: #d0d0d0; } /* queue page */ From Jogy at freenetproject.org Fri Jan 5 13:35:43 2007 From: Jogy at freenetproject.org (Jogy at freenetproject.org) Date: Fri, 5 Jan 2007 13:35:43 +0000 (UTC) Subject: [freenet-cvs] r11571 - trunk/freenet/src/freenet/clients/http Message-ID: <20070105133543.AF9489BB99@emu.freenetproject.org> Author: Jogy Date: 2007-01-05 13:35:42 +0000 (Fri, 05 Jan 2007) New Revision: 11571 Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java Log: * Make the peer circles really centered :/ Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java 2007-01-05 13:23:46 UTC (rev 11570) +++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java 2007-01-05 13:35:42 UTC (rev 11571) @@ -551,6 +551,7 @@ private final static int PEER_CIRCLE_RADIUS = 100; private final static int PEER_CIRCLE_INNER_RADIUS = 60; + private final static int PEER_CIRCLE_ADDITIONAL_FREE_SPACE = 10; private final static long MAX_CIRCLE_AGE_THRESHOLD = 24l*60*60*1000; // 24 hours private final static int HISTOGRAM_LENGTH = 10; private final DecimalFormat fix1p2 = new DecimalFormat("0.00"); @@ -558,7 +559,7 @@ private final DecimalFormat fix3pctUS = new DecimalFormat("##0%", new DecimalFormatSymbols(Locale.US)); private void addNodeCircle (HTMLNode htmlNode) { - HTMLNode nodeCircleInfoboxContentDiv = htmlNode.addChild("div", new String[] { "style", "class" }, new String[] {"position: relative; height: " + (PEER_CIRCLE_RADIUS * 2 + 10) + "px; width: " + (PEER_CIRCLE_RADIUS * 2 + 10) + "px", "peercircle" }); + HTMLNode nodeCircleInfoboxContentDiv = htmlNode.addChild("div", new String[] { "style", "class" }, new String[] {"position: relative; height: " + ((PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) * 2) + "px; width: " + ((PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) * 2) + "px", "peercircle" }); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0, false, 1.0), "mark" }, "|"); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.125, false, 1.0), "mark" }, "+"); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.25, false, 1.0), "mark" }, "--"); @@ -568,7 +569,7 @@ nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.75, false, 1.0), "mark" }, "--"); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.875, false, 1.0), "mark" }, "+"); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.875, false, 1.0), "mark" }, "+"); - nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { "position: absolute; top: " + PEER_CIRCLE_RADIUS + "px; left: " + PEER_CIRCLE_RADIUS + "px", "mark" }, "+"); + nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { "position: absolute; top: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px; left: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px", "mark" }, "+"); HashMap knownLocsCopy = node.getKnownLocations(-1); Double location = new Double(0.0); Long locationTime = new Long(0); @@ -602,7 +603,7 @@ HTMLNode peerCircleTableCell = peerCircleTableRow.addChild("td", new String[] { "class", "colspan" }, new String[] {"first", "10"}); HTMLNode peerHistogramLegendCell; HTMLNode peerHistogramGraphCell; - HTMLNode peerCircleInfoboxContent = peerCircleTableCell.addChild("div", new String[] { "style", "class" }, new String[] {"position: relative; height: " + (PEER_CIRCLE_RADIUS * 2 + 10) + "px; width: " + (PEER_CIRCLE_RADIUS * 2 + 10) + "px", "peercircle" }); + HTMLNode peerCircleInfoboxContent = peerCircleTableCell.addChild("div", new String[] { "style", "class" }, new String[] {"position: relative; height: " + ((PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) * 2) + "px; width: " + ((PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) * 2) + "px", "peercircle" }); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0, false, 1.0), "mark" }, "|"); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.125, false, 1.0), "mark" }, "+"); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.25, false, 1.0), "mark" }, "--"); @@ -610,7 +611,7 @@ peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.5, false, 1.0), "mark" }, "|"); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.625, false, 1.0), "mark" }, "+"); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.75, false, 1.0), "mark" }, "--"); - peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { "position: absolute; top: " + PEER_CIRCLE_RADIUS + "px; left: " + PEER_CIRCLE_RADIUS + "px", "mark" }, "+"); + peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { "position: absolute; top: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px; left: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px", "mark" }, "+"); // double myLocation = node.getLocation(); PeerNodeStatus[] peerNodeStatuses = node.getPeerNodeStatuses(); @@ -657,8 +658,8 @@ } else { offset = (int) (((double) PEER_CIRCLE_INNER_RADIUS) * (1.0 - strength)); } - double x = PEER_CIRCLE_RADIUS + Math.sin(peerLocation) * (PEER_CIRCLE_RADIUS - offset); - double y = PEER_CIRCLE_RADIUS - Math.cos(peerLocation) * (PEER_CIRCLE_RADIUS - offset); + double x = PEER_CIRCLE_ADDITIONAL_FREE_SPACE + PEER_CIRCLE_RADIUS + Math.sin(peerLocation) * (PEER_CIRCLE_RADIUS - offset); + double y = PEER_CIRCLE_RADIUS - Math.cos(peerLocation) * (PEER_CIRCLE_RADIUS - offset); // no PEER_CIRCLE_ADDITIONAL_FREE_SPACE for y-disposition // return "position: absolute; top: " + fix3p1US.format(y) + "px; left: " + fix3p1US.format(x) + "px"; } From Jogy at freenetproject.org Fri Jan 5 13:44:59 2007 From: Jogy at freenetproject.org (Jogy at freenetproject.org) Date: Fri, 5 Jan 2007 13:44:59 +0000 (UTC) Subject: [freenet-cvs] r11572 - trunk/freenet/src/freenet/clients/http Message-ID: <20070105134459.51FA69BC06@emu.freenetproject.org> Author: Jogy Date: 2007-01-05 13:44:58 +0000 (Fri, 05 Jan 2007) New Revision: 11572 Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java Log: *sigh* smee again... the center "+" was off Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java 2007-01-05 13:35:42 UTC (rev 11571) +++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java 2007-01-05 13:44:58 UTC (rev 11572) @@ -569,7 +569,7 @@ nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.75, false, 1.0), "mark" }, "--"); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.875, false, 1.0), "mark" }, "+"); nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.875, false, 1.0), "mark" }, "+"); - nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { "position: absolute; top: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px; left: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px", "mark" }, "+"); + nodeCircleInfoboxContentDiv.addChild("span", new String[] { "style", "class" }, new String[] { "position: absolute; top: " + PEER_CIRCLE_RADIUS + "px; left: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px", "mark" }, "+"); HashMap knownLocsCopy = node.getKnownLocations(-1); Double location = new Double(0.0); Long locationTime = new Long(0); @@ -611,7 +611,7 @@ peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.5, false, 1.0), "mark" }, "|"); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.625, false, 1.0), "mark" }, "+"); peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { generatePeerCircleStyleString(0.75, false, 1.0), "mark" }, "--"); - peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { "position: absolute; top: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px; left: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px", "mark" }, "+"); + peerCircleInfoboxContent.addChild("span", new String[] { "style", "class" }, new String[] { "position: absolute; top: " + PEER_CIRCLE_RADIUS + "px; left: " + (PEER_CIRCLE_RADIUS + PEER_CIRCLE_ADDITIONAL_FREE_SPACE) + "px", "mark" }, "+"); // double myLocation = node.getLocation(); PeerNodeStatus[] peerNodeStatuses = node.getPeerNodeStatuses(); From zothar at freenetproject.org Sun Jan 7 16:23:00 2007 From: zothar at freenetproject.org (zothar at freenetproject.org) Date: Sun, 7 Jan 2007 16:23:00 +0000 (UTC) Subject: [freenet-cvs] r11580 - trunk/freenet/src/freenet/node/useralerts Message-ID: <20070107162300.2EECD9BB7C@emu.freenetproject.org> Author: zothar Date: 2007-01-07 16:22:59 +0000 (Sun, 07 Jan 2007) New Revision: 11580 Modified: trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java Log: Replace PING_TIME with nodeAveragePingTime instead of bwlimitDelayTime in PeerManagerUserAlerts. Modified: trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java =================================================================== --- trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java 2007-01-05 21:10:09 UTC (rev 11579) +++ trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java 2007-01-07 16:22:59 UTC (rev 11580) @@ -162,7 +162,7 @@ // FIXME I'm not convinced about the next one! } else if(n.nodeAveragePingAlertRelevant && (nodeAveragePingTime > Node.MAX_NODE_AVERAGE_PING_TIME_ALERT_THRESHOLD)) { - s = replace(TOO_HIGH_PING, "\\{PING_TIME\\}", Integer.toString(bwlimitDelayTime)); + s = replace(TOO_HIGH_PING, "\\{PING_TIME\\}", Integer.toString(nodeAveragePingTime)); } else if(oldestNeverConnectedPeerAge > MAX_OLDEST_NEVER_CONNECTED_PEER_AGE_ALERT_THRESHOLD) { s = NEVER_CONNECTED_TWO_WEEKS; } else throw new IllegalArgumentException("Not valid"); From toad at freenetproject.org Tue Jan 9 04:38:14 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 9 Jan 2007 04:38:14 +0000 (UTC) Subject: [freenet-cvs] r11586 - in trunk/freenet/src/freenet: crypt crypt/ciphers keys node support/io Message-ID: <20070109043814.4A8069BBC9@emu.freenetproject.org> Author: toad Date: 2007-01-09 04:38:13 +0000 (Tue, 09 Jan 2007) New Revision: 11586 Modified: trunk/freenet/src/freenet/crypt/KeyAgreementSchemeContext.java trunk/freenet/src/freenet/crypt/ciphers/Rijndael.java trunk/freenet/src/freenet/crypt/ciphers/Rijndael_Algorithm.java trunk/freenet/src/freenet/keys/CHKBlock.java trunk/freenet/src/freenet/keys/ClientCHK.java trunk/freenet/src/freenet/keys/ClientCHKBlock.java trunk/freenet/src/freenet/keys/ClientKSK.java trunk/freenet/src/freenet/keys/ClientSSK.java trunk/freenet/src/freenet/keys/ClientSSKBlock.java trunk/freenet/src/freenet/keys/InsertableClientSSK.java trunk/freenet/src/freenet/keys/InsertableUSK.java trunk/freenet/src/freenet/keys/Key.java trunk/freenet/src/freenet/keys/NodeCHK.java trunk/freenet/src/freenet/keys/NodeSSK.java trunk/freenet/src/freenet/keys/USK.java trunk/freenet/src/freenet/node/PeerNode.java trunk/freenet/src/freenet/node/Version.java trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java trunk/freenet/src/freenet/support/io/SerializableToFieldSetBucketUtil.java Log: 1010: MANDATORY SECURITY FIX Fix a serious crypto bug. Mandatory immediately (sorry folks). All old KSKs are no longer retrievable, and you will need to generate a new SSK for your inserts to be properly encrypted. Otherwise is backwards compatible with prior builds (in terms of content), so no content reset. Modified: trunk/freenet/src/freenet/crypt/KeyAgreementSchemeContext.java =================================================================== --- trunk/freenet/src/freenet/crypt/KeyAgreementSchemeContext.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/crypt/KeyAgreementSchemeContext.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -27,7 +27,7 @@ if(cipher != null) return cipher; getKey(); try { - cipher = new Rijndael(256, 256); + cipher = new Rijndael(256, 256, false); } catch (UnsupportedCipherException e1) { throw new Error(e1); } Modified: trunk/freenet/src/freenet/crypt/ciphers/Rijndael.java =================================================================== --- trunk/freenet/src/freenet/crypt/ciphers/Rijndael.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/crypt/ciphers/Rijndael.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -19,7 +19,10 @@ */ public class Rijndael implements BlockCipher { private Object sessionKey; - private int keysize, blocksize; + private final int keysize, blocksize; + // FIXME remove. This is used to simulate an old security threatening bug in order + // to have backwards compatibility with old keys. + private final int cryptBlockSize; // for Util.getCipherByName.. and yes, screw you too, java public Rijndael(Integer keysize) throws UnsupportedCipherException { @@ -27,10 +30,19 @@ } public Rijndael(int keysize) throws UnsupportedCipherException { - this(keysize, 128); + this(keysize, 128, false); } - public Rijndael(int keysize, int blocksize) throws UnsupportedCipherException { + /** + * Create a Rijndael instance. + * @param keysize The key size. + * @param blocksize The block size. + * @param fakeInsecure If true, only encrypt the first 128 bits of any block. This + * is insecure! It is used for backwards compatibility with old data encrypted with + * the old code. + * @throws UnsupportedCipherException + */ + public Rijndael(int keysize, int blocksize, boolean fakeInsecure) throws UnsupportedCipherException { if (! ((keysize == 128) || (keysize == 192) || (keysize == 256))) @@ -41,11 +53,18 @@ throw new UnsupportedCipherException("Invalid blocksize"); this.keysize=keysize; this.blocksize=blocksize; + // FIXME This is deliberate insecurity! It is used for backwards compatibility *ONLY*! + // FIXME IT MUST BE REMOVED SOON! + if(fakeInsecure) + this.cryptBlockSize = 128; + else + this.cryptBlockSize = blocksize; } public Rijndael() { this.keysize = 128; this.blocksize = 128; + this.cryptBlockSize = 128; } public final int getBlockSize() { @@ -60,7 +79,7 @@ try { byte[] nkey=new byte[keysize>>3]; System.arraycopy(key, 0, nkey, 0, nkey.length); - sessionKey=Rijndael_Algorithm.makeKey(nkey); + sessionKey=Rijndael_Algorithm.makeKey(nkey, cryptBlockSize/8); } catch (InvalidKeyException e) { e.printStackTrace(); Logger.error(this,"Invalid key"); @@ -70,13 +89,13 @@ public synchronized final void encipher(byte[] block, byte[] result) { if(block.length != blocksize/8) throw new IllegalArgumentException(); - Rijndael_Algorithm.blockEncrypt(block, result, 0, sessionKey); + Rijndael_Algorithm.blockEncrypt(block, result, 0, sessionKey, cryptBlockSize/8); } public synchronized final void decipher(byte[] block, byte[] result) { if(block.length != blocksize/8) throw new IllegalArgumentException(); - Rijndael_Algorithm.blockDecrypt(block, result, 0, sessionKey); + Rijndael_Algorithm.blockDecrypt(block, result, 0, sessionKey, cryptBlockSize/8); } public static void main(String[] args) throws UnsupportedCipherException { Modified: trunk/freenet/src/freenet/crypt/ciphers/Rijndael_Algorithm.java =================================================================== --- trunk/freenet/src/freenet/crypt/ciphers/Rijndael_Algorithm.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/crypt/ciphers/Rijndael_Algorithm.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -300,7 +300,7 @@ * @param k The 128/192/256-bit user-key to use. * @exception InvalidKeyException If the key is invalid. */ - public static final Object makeKey (byte[] k) throws InvalidKeyException { + private static final Object makeKey (byte[] k) throws InvalidKeyException { return makeKey(k, BLOCK_SIZE); } @@ -313,7 +313,7 @@ * @param inOffset Index of in from which to start considering data. * @param sessionKey The session key to use for encryption. */ - public static final void + private static final void blockEncrypt (byte[] in, byte[] result, int inOffset, Object sessionKey) { if (RDEBUG) trace(IN, "blockEncrypt("+in+", "+inOffset+", "+sessionKey+ ')'); int[][] Ke = (int[][]) ((Object[]) sessionKey)[0]; // extract encryption round keys @@ -402,7 +402,7 @@ * @param inOffset Index of in from which to start considering data. * @param sessionKey The session key to use for decryption. */ - public static final void + private static final void blockDecrypt (byte[] in, byte[] result, int inOffset, Object sessionKey) { if (RDEBUG) trace(IN, "blockDecrypt("+in+", "+inOffset+", "+sessionKey+ ')'); int[][] Kd = (int[][]) ((Object[]) sessionKey)[1]; // extract decryption round keys Modified: trunk/freenet/src/freenet/keys/CHKBlock.java =================================================================== --- trunk/freenet/src/freenet/keys/CHKBlock.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/CHKBlock.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -42,12 +42,16 @@ public byte[] getData() { return data; } - + public CHKBlock(byte[] data2, byte[] header2, NodeCHK key) throws CHKVerifyException { - this(data2, header2, key, true); + this(data2, header2, key, key.cryptoAlgorithm); } + + public CHKBlock(byte[] data2, byte[] header2, NodeCHK key, byte cryptoAlgorithm) throws CHKVerifyException { + this(data2, header2, key, true, cryptoAlgorithm); + } - public CHKBlock(byte[] data2, byte[] header2, NodeCHK key, boolean verify) throws CHKVerifyException { + public CHKBlock(byte[] data2, byte[] header2, NodeCHK key, boolean verify, byte cryptoAlgorithm) throws CHKVerifyException { data = data2; headers = header2; if(headers.length != TOTAL_HEADERS_LENGTH) @@ -69,7 +73,7 @@ md.update(data); byte[] hash = md.digest(); if(key == null) { - chk = new NodeCHK(hash); + chk = new NodeCHK(hash, cryptoAlgorithm); } else { chk = key; byte[] check = chk.routingKey; Modified: trunk/freenet/src/freenet/keys/ClientCHK.java =================================================================== --- trunk/freenet/src/freenet/keys/ClientCHK.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/ClientCHK.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -25,7 +25,7 @@ /** Is the data a control document? */ final boolean controlDocument; /** Encryption algorithm */ - final short cryptoAlgorithm; + final byte cryptoAlgorithm; /** Compression algorithm, negative means uncompressed */ final short compressionAlgorithm; @@ -49,7 +49,7 @@ * values. */ public ClientCHK(byte[] routingKey, byte[] encKey, - boolean isControlDocument, short algo, short compressionAlgorithm) { + boolean isControlDocument, byte algo, short compressionAlgorithm) { this.routingKey = routingKey; this.cryptoKey = encKey; this.controlDocument = isControlDocument; @@ -68,8 +68,10 @@ byte[] extra = uri.getExtra(); if((extra == null) || (extra.length < 5)) throw new MalformedURLException(); - cryptoAlgorithm = (short)(((extra[0] & 0xff) << 8) + (extra[1] & 0xff)); - if(cryptoAlgorithm != Key.ALGO_AES_PCFB_256_SHA256) + // byte 0 is reserved, for now + cryptoAlgorithm = extra[1]; + if((!(cryptoAlgorithm == Key.ALGO_AES_PCFB_256_SHA256 || + cryptoAlgorithm == Key.ALGO_INSECURE_AES_PCFB_256_SHA256))) throw new MalformedURLException("Invalid crypto algorithm"); controlDocument = (extra[2] & 0x02) != 0; compressionAlgorithm = (short)(((extra[3] & 0xff) << 8) + (extra[4] & 0xff)); @@ -83,8 +85,10 @@ private ClientCHK(DataInputStream dis) throws IOException { byte[] extra = new byte[EXTRA_LENGTH]; dis.readFully(extra); - cryptoAlgorithm = (short)(((extra[0] & 0xff) << 8) + (extra[1] & 0xff)); - if(cryptoAlgorithm != Key.ALGO_AES_PCFB_256_SHA256) + // byte 0 is reserved, for now + cryptoAlgorithm = extra[1]; + if((!(cryptoAlgorithm == Key.ALGO_AES_PCFB_256_SHA256 || + cryptoAlgorithm == Key.ALGO_INSECURE_AES_PCFB_256_SHA256))) throw new MalformedURLException("Invalid crypto algorithm"); compressionAlgorithm = (short)(((extra[3] & 0xff) << 8) + (extra[4] & 0xff)); controlDocument = (extra[2] & 0x02) != 0; @@ -126,7 +130,7 @@ public NodeCHK getNodeCHK() { if(nodeKey == null) - nodeKey = new NodeCHK(routingKey); + nodeKey = new NodeCHK(routingKey, cryptoAlgorithm); return nodeKey; } Modified: trunk/freenet/src/freenet/keys/ClientCHKBlock.java =================================================================== --- trunk/freenet/src/freenet/keys/ClientCHKBlock.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/ClientCHKBlock.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -44,7 +44,7 @@ * @param data The data. */ public ClientCHKBlock(byte[] data, byte[] header, ClientCHK key2, boolean verify) throws CHKVerifyException { - super(data, header, key2.getNodeCHK(), verify); + super(data, header, key2.getNodeCHK(), verify, key2.cryptoAlgorithm); this.key = key2; } @@ -75,11 +75,12 @@ */ public Bucket decode(BucketFactory bf, int maxLength, boolean dontCompress) throws CHKDecodeException, IOException { // Overall hash already verified, so first job is to decrypt. - if(key.cryptoAlgorithm != Key.ALGO_AES_PCFB_256_SHA256) + if((!(key.cryptoAlgorithm == Key.ALGO_AES_PCFB_256_SHA256 || + key.cryptoAlgorithm == Key.ALGO_INSECURE_AES_PCFB_256_SHA256))) throw new UnsupportedOperationException(); BlockCipher cipher; try { - cipher = new Rijndael(256, 256); + cipher = new Rijndael(256, 256, key.cryptoAlgorithm == Key.ALGO_INSECURE_AES_PCFB_256_SHA256); } catch (UnsupportedCipherException e) { // FIXME - log this properly throw new Error(e); @@ -178,7 +179,7 @@ // Now encrypt the header, then the data, using the same PCFB instance BlockCipher cipher; try { - cipher = new Rijndael(256, 256); + cipher = new Rijndael(256, 256, false); } catch (UnsupportedCipherException e) { // FIXME - log this properly throw new Error(e); Modified: trunk/freenet/src/freenet/keys/ClientKSK.java =================================================================== --- trunk/freenet/src/freenet/keys/ClientKSK.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/ClientKSK.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -19,7 +19,7 @@ final String keyword; private ClientKSK(String keyword, byte[] pubKeyHash, DSAPublicKey pubKey, DSAPrivateKey privKey, byte[] keywordHash) throws MalformedURLException { - super(keyword, pubKeyHash, pubKey, privKey, keywordHash); + super(keyword, pubKeyHash, pubKey, privKey, keywordHash, Key.ALGO_AES_PCFB_256_SHA256); this.keyword = keyword; } Modified: trunk/freenet/src/freenet/keys/ClientSSK.java =================================================================== --- trunk/freenet/src/freenet/keys/ClientSSK.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/ClientSSK.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -16,6 +16,8 @@ public class ClientSSK extends ClientKey { + /** Crypto type */ + public final byte cryptoAlgorithm; /** Document name */ public final String docName; /** Public key */ @@ -34,6 +36,12 @@ this.docName = docName; this.pubKey = pubKey; this.pubKeyHash = pubKeyHash; + if(extras.length < 5) + throw new MalformedURLException("Extra bytes too short: "+extras.length+" bytes"); + this.cryptoAlgorithm = extras[2]; + if(!(cryptoAlgorithm == Key.ALGO_AES_PCFB_256_SHA256 || + cryptoAlgorithm == Key.ALGO_INSECURE_AES_PCFB_256_SHA256)) + throw new MalformedURLException("Unknown encryption algorithm "+cryptoAlgorithm); if(!Arrays.equals(extras, getExtraBytes())) throw new MalformedURLException("Wrong extra bytes"); if(pubKeyHash.length != NodeSSK.PUBKEY_HASH_SIZE) @@ -56,7 +64,7 @@ } byte[] buf = md.digest(); try { - Rijndael aes = new Rijndael(256,256); + Rijndael aes = new Rijndael(256,256,cryptoAlgorithm == Key.ALGO_INSECURE_AES_PCFB_256_SHA256); aes.initialize(cryptoKey); aes.encipher(buf, buf); ehDocname = buf; @@ -80,15 +88,17 @@ public FreenetURI getURI() { return new FreenetURI("SSK", docName, pubKeyHash, cryptoKey, getExtraBytes()); } + + protected final byte[] getExtraBytes() { + return getExtraBytes(cryptoAlgorithm); + } - protected static final byte[] getExtraBytes() { + protected static byte[] getExtraBytes(byte cryptoAlgorithm) { // 5 bytes. byte[] extra = new byte[5]; - short cryptoAlgorithm = Key.ALGO_AES_PCFB_256_SHA256; - extra[0] = NodeSSK.SSK_VERSION; - extra[1] = (byte) (cryptoAlgorithm >> 8); + extra[1] = 0; // 0 = fetch (public) URI; 1 = insert (private) URI extra[2] = (byte) cryptoAlgorithm; extra[3] = (byte) (KeyBlock.HASH_SHA256 >> 8); extra[4] = (byte) KeyBlock.HASH_SHA256; @@ -97,7 +107,7 @@ public Key getNodeKey() { try { - return new NodeSSK(pubKeyHash, ehDocname, pubKey); + return new NodeSSK(pubKeyHash, ehDocname, pubKey, cryptoAlgorithm); } catch (SSKVerifyException e) { IllegalStateException x = new IllegalStateException("Have already verified and yet it fails!: "+e); Logger.error(this, "Have already verified and yet it fails!: "+e); Modified: trunk/freenet/src/freenet/keys/ClientSSKBlock.java =================================================================== --- trunk/freenet/src/freenet/keys/ClientSSKBlock.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/ClientSSKBlock.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -8,6 +8,7 @@ import freenet.crypt.PCFBMode; import freenet.crypt.UnsupportedCipherException; import freenet.crypt.ciphers.Rijndael; +import freenet.support.Logger; import freenet.support.api.Bucket; import freenet.support.api.BucketFactory; import freenet.support.io.BucketTools; @@ -47,7 +48,8 @@ System.arraycopy(headers, headersOffset, decryptedHeaders, 0, ENCRYPTED_HEADERS_LENGTH); Rijndael aes; try { - aes = new Rijndael(256,256); + Logger.minor(this, "cryptoAlgorithm="+key.cryptoAlgorithm+" for "+getClientKey().getURI()); + aes = new Rijndael(256,256,key.cryptoAlgorithm==Key.ALGO_INSECURE_AES_PCFB_256_SHA256); } catch (UnsupportedCipherException e) { throw new Error(e); } Modified: trunk/freenet/src/freenet/keys/InsertableClientSSK.java =================================================================== --- trunk/freenet/src/freenet/keys/InsertableClientSSK.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/InsertableClientSSK.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -29,8 +29,8 @@ public final DSAPrivateKey privKey; - public InsertableClientSSK(String docName, byte[] pubKeyHash, DSAPublicKey pubKey, DSAPrivateKey privKey, byte[] cryptoKey) throws MalformedURLException { - super(docName, pubKeyHash, getExtraBytes(), pubKey, cryptoKey); + public InsertableClientSSK(String docName, byte[] pubKeyHash, DSAPublicKey pubKey, DSAPrivateKey privKey, byte[] cryptoKey, byte cryptoAlgorithm) throws MalformedURLException { + super(docName, pubKeyHash, getExtraBytes(cryptoAlgorithm), pubKey, cryptoKey); if(pubKey == null) throw new NullPointerException(); this.privKey = privKey; } @@ -38,18 +38,38 @@ public static InsertableClientSSK create(FreenetURI uri) throws MalformedURLException { if(uri.getKeyType().equalsIgnoreCase("KSK")) return ClientKSK.create(uri); - if(!uri.getKeyType().equalsIgnoreCase("SSK")) - throw new MalformedURLException(); + + byte keyType; + + byte[] extra = uri.getExtra(); + if(uri.getKeyType().equals("SSK")) { + // FIXME remove once everyone is using PSKs + if(extra == null) { + keyType = Key.ALGO_INSECURE_AES_PCFB_256_SHA256; + } else { + // Formatted exactly as ,extra on fetching + if(extra.length < 5) + throw new MalformedURLException("SSK private key ,extra too short"); + if(extra[1] != 1) { + throw new MalformedURLException("SSK not a private key"); + } + keyType = extra[2]; + if(!(keyType == Key.ALGO_AES_PCFB_256_SHA256 || + keyType == Key.ALGO_INSECURE_AES_PCFB_256_SHA256)) + throw new MalformedURLException("Unrecognized crypto type in SSK private key"); + } + } else { + throw new MalformedURLException("Not a valid SSK insert URI type: "+uri.getKeyType()); + } + if((uri.getDocName() == null) || (uri.getDocName().length() == 0)) throw new MalformedURLException("SSK URIs must have a document name (to avoid ambiguity)"); - if(uri.getExtra() != null) - throw new MalformedURLException("Insertable SSK URIs must NOT have ,extra - inserting from a pubkey rather than the privkey perhaps?"); DSAGroup g = Global.DSAgroupBigA; DSAPrivateKey privKey = new DSAPrivateKey(new NativeBigInteger(1, uri.getKeyVal())); DSAPublicKey pubKey = new DSAPublicKey(g, privKey); MessageDigest md = SHA256.getMessageDigest(); md.update(pubKey.asBytes()); - return new InsertableClientSSK(uri.getDocName(), md.digest(), pubKey, privKey, uri.getCryptoKey()); + return new InsertableClientSSK(uri.getDocName(), md.digest(), pubKey, privKey, uri.getCryptoKey(), keyType); } public ClientSSKBlock encode(Bucket sourceData, boolean asMetadata, boolean dontCompress, short alreadyCompressedCodec, long sourceLength, RandomSource r) throws SSKEncodeException, IOException { @@ -89,7 +109,7 @@ Rijndael aes; try { - aes = new Rijndael(256, 256); + aes = new Rijndael(256, 256, cryptoAlgorithm == Key.ALGO_INSECURE_AES_PCFB_256_SHA256); } catch (UnsupportedCipherException e) { throw new Error("256/256 Rijndael not supported!"); } @@ -188,14 +208,24 @@ DSAPublicKey pubKey = new DSAPublicKey(g, privKey); MessageDigest md = SHA256.getMessageDigest(); try { - return new InsertableClientSSK(docName, md.digest(pubKey.asBytes()), pubKey, privKey, ckey); + return new InsertableClientSSK(docName, md.digest(pubKey.asBytes()), pubKey, privKey, ckey, Key.ALGO_AES_PCFB_256_SHA256); } catch (MalformedURLException e) { throw new Error(e); } } public FreenetURI getInsertURI() { - return new FreenetURI("SSK", docName, privKey.getX().toByteArray(), cryptoKey, null); + return new FreenetURI("SSK", docName, privKey.getX().toByteArray(), cryptoKey, getInsertExtraBytes()); } + + private byte[] getInsertExtraBytes() { + byte[] extra = getExtraBytes(); + extra[1] = 1; // insert + return extra; + } + + public DSAGroup getCryptoGroup() { + return Global.DSAgroupBigA; + } } Modified: trunk/freenet/src/freenet/keys/InsertableUSK.java =================================================================== --- trunk/freenet/src/freenet/keys/InsertableUSK.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/InsertableUSK.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -32,20 +32,14 @@ public static InsertableUSK createInsertable(FreenetURI uri) throws MalformedURLException { if(!uri.getKeyType().equalsIgnoreCase("USK")) throw new MalformedURLException(); - if((uri.getDocName() == null) || (uri.getDocName().length() == 0)) - throw new MalformedURLException("USK URIs must have a document name (to avoid ambiguity)"); - if(uri.getExtra() != null) - throw new MalformedURLException("Insertable SSK URIs must NOT have ,extra - inserting from a pubkey rather than the privkey perhaps?"); - DSAGroup g = Global.DSAgroupBigA; - DSAPrivateKey privKey = new DSAPrivateKey(new NativeBigInteger(1, uri.getKeyVal())); - DSAPublicKey pubKey = new DSAPublicKey(g, privKey); - MessageDigest md = SHA256.getMessageDigest(); - md.update(pubKey.asBytes()); - return new InsertableUSK(uri.getDocName(), md.digest(), uri.getCryptoKey(), privKey, g, uri.getSuggestedEdition()); + uri = uri.setKeyType("SSK"); + InsertableClientSSK ssk = + InsertableClientSSK.create(uri); + return new InsertableUSK(ssk.docName, ssk.pubKeyHash, ssk.cryptoKey, ssk.privKey, ssk.getCryptoGroup(), uri.getSuggestedEdition(), ssk.cryptoAlgorithm); } - InsertableUSK(String docName, byte[] pubKeyHash, byte[] cryptoKey, DSAPrivateKey key, DSAGroup group, long suggestedEdition) throws MalformedURLException { - super(pubKeyHash, cryptoKey, docName, suggestedEdition); + InsertableUSK(String docName, byte[] pubKeyHash, byte[] cryptoKey, DSAPrivateKey key, DSAGroup group, long suggestedEdition, byte cryptoAlgorithm) throws MalformedURLException { + super(pubKeyHash, cryptoKey, docName, suggestedEdition, cryptoAlgorithm); if(cryptoKey.length != ClientSSK.CRYPTO_KEY_LENGTH) throw new MalformedURLException("Decryption key wrong length: "+cryptoKey.length+" should be "+ClientSSK.CRYPTO_KEY_LENGTH); this.privKey = key; @@ -57,13 +51,13 @@ } public USK getUSK() { - return new USK(pubKeyHash, cryptoKey, siteName, suggestedEdition); + return new USK(pubKeyHash, cryptoKey, siteName, suggestedEdition, cryptoAlgorithm); } public InsertableClientSSK getInsertableSSK(long ver) { try { return new InsertableClientSSK(siteName + SEPARATOR + ver, pubKeyHash, - new DSAPublicKey(group, privKey), privKey, cryptoKey); + new DSAPublicKey(group, privKey), privKey, cryptoKey, cryptoAlgorithm); } catch (MalformedURLException e) { Logger.error(this, "Caught "+e+" should not be possible in USK.getSSK", e); throw new Error(e); @@ -73,11 +67,10 @@ public InsertableUSK privCopy(long edition) { if(edition == suggestedEdition) return this; try { - return new InsertableUSK(siteName, pubKeyHash, cryptoKey, privKey, group, edition); + return new InsertableUSK(siteName, pubKeyHash, cryptoKey, privKey, group, edition, cryptoAlgorithm); } catch (MalformedURLException e) { throw new Error(e); } } - } Modified: trunk/freenet/src/freenet/keys/Key.java =================================================================== --- trunk/freenet/src/freenet/keys/Key.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/Key.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -34,7 +34,10 @@ final byte[] routingKey; /** Code for 256-bit AES with PCFB and SHA-256 */ - static final short ALGO_AES_PCFB_256_SHA256 = 1; + static final byte ALGO_AES_PCFB_256_SHA256 = 2; + /** Code for old, insecure (only encrypts first 128 bits of block) 256-bit AES with PCFB and SHA-256. + * FIXME: REMOVE!! */ + static final byte ALGO_INSECURE_AES_PCFB_256_SHA256 = 1; protected Key(byte[] routingKey) { this.routingKey = routingKey; @@ -55,11 +58,12 @@ * @return a Key, or throw an exception, or return null if the key is not parsable. */ public static final Key read(DataInput raf) throws IOException { - short type = raf.readShort(); - if(type == NodeCHK.TYPE) { - return NodeCHK.readCHK(raf); - } else if(type == NodeSSK.TYPE) - return NodeSSK.readSSK(raf); + byte type = raf.readByte(); + byte subtype = raf.readByte(); + if(type == NodeCHK.BASE_TYPE) { + return NodeCHK.readCHK(raf, subtype); + } else if(type == NodeSSK.BASE_TYPE) + return NodeSSK.readSSK(raf, subtype); throw new IOException("Unrecognized format: "+type); } Modified: trunk/freenet/src/freenet/keys/NodeCHK.java =================================================================== --- trunk/freenet/src/freenet/keys/NodeCHK.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/NodeCHK.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -21,19 +21,22 @@ /** 32 bytes for hash, 2 bytes for type */ public static final short KEY_SIZE_ON_DISK = 34; - public NodeCHK(byte[] routingKey2) { + public NodeCHK(byte[] routingKey2, byte cryptoAlgorithm) { super(routingKey2); if(routingKey2.length != KEY_LENGTH) throw new IllegalArgumentException("Wrong length: "+routingKey2.length+" should be "+KEY_LENGTH); + this.cryptoAlgorithm = cryptoAlgorithm; } static final int KEY_LENGTH = 32; - // 01 = CHK, 01 = first version of CHK - public static final short TYPE = 0x0101; + /** Crypto algorithm */ + final byte cryptoAlgorithm; /** The size of the data */ public static final int BLOCK_SIZE = 32768; + public static final byte BASE_TYPE = 1; + public final void writeToDataOutputStream(DataOutputStream stream) throws IOException { write(stream); } @@ -43,14 +46,14 @@ } public final void write(DataOutput _index) throws IOException { - _index.writeShort(TYPE); + _index.writeShort(getType()); _index.write(routingKey); } - public static Key readCHK(DataInput raf) throws IOException { + public static Key readCHK(DataInput raf, byte algo) throws IOException { byte[] buf = new byte[KEY_LENGTH]; raf.readFully(buf); - return new NodeCHK(buf); + return new NodeCHK(buf, algo); } public boolean equals(Object key) { @@ -66,7 +69,7 @@ } public short getType() { - return TYPE; + return (short) (0x100 + (cryptoAlgorithm & 0xFF)); } public byte[] getRoutingKey(){ Modified: trunk/freenet/src/freenet/keys/NodeSSK.java =================================================================== --- trunk/freenet/src/freenet/keys/NodeSSK.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/NodeSSK.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -27,6 +27,8 @@ */ public class NodeSSK extends Key { + /** Crypto algorithm */ + final byte cryptoAlgorithm; /** Public key hash */ final byte[] pubKeyHash; /** E(H(docname)) (E = encrypt using decrypt key, which only clients know) */ @@ -39,15 +41,17 @@ static final int PUBKEY_HASH_SIZE = 32; static final int E_H_DOCNAME_SIZE = 32; + static final byte BASE_TYPE = 2; public String toString() { return super.toString()+":pkh="+HexUtil.bytesToHex(pubKeyHash)+":ehd="+HexUtil.bytesToHex(encryptedHashedDocname); } - public NodeSSK(byte[] pkHash, byte[] ehDocname, DSAPublicKey pubKey) throws SSKVerifyException { + public NodeSSK(byte[] pkHash, byte[] ehDocname, DSAPublicKey pubKey, byte cryptoAlgorithm) throws SSKVerifyException { super(makeRoutingKey(pkHash, ehDocname)); this.encryptedHashedDocname = ehDocname; this.pubKeyHash = pkHash; + this.cryptoAlgorithm = cryptoAlgorithm; this.pubKey = pubKey; if(pubKey != null) { MessageDigest md256 = SHA256.getMessageDigest(); @@ -70,22 +74,19 @@ return md256.digest(); } - // 01 = SSK, 01 = first version of SSK - public static short TYPE = 0x0201; - public void write(DataOutput _index) throws IOException { - _index.writeShort(TYPE); + _index.writeShort(getType()); _index.write(encryptedHashedDocname); _index.write(pubKeyHash); } - public static Key readSSK(DataInput raf) throws IOException { + public static Key readSSK(DataInput raf, byte cryptoAlgorithm) throws IOException { byte[] buf = new byte[E_H_DOCNAME_SIZE]; raf.readFully(buf); byte[] buf2 = new byte[PUBKEY_HASH_SIZE]; raf.readFully(buf2); try { - return new NodeSSK(buf2, buf, null); + return new NodeSSK(buf2, buf, null, cryptoAlgorithm); } catch (SSKVerifyException e) { IllegalStateException impossible = new IllegalStateException("Impossible: "+e); @@ -95,7 +96,7 @@ } public short getType() { - return TYPE; + return (short) (0x0200 + (cryptoAlgorithm & 0xff)); } public void writeToDataOutputStream(DataOutputStream stream) throws IOException { Modified: trunk/freenet/src/freenet/keys/USK.java =================================================================== --- trunk/freenet/src/freenet/keys/USK.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/keys/USK.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -25,6 +25,8 @@ * SSK form, and we don't need to go vice versa. */ static protected final String SEPARATOR = "-"; + /** Encryption type */ + public final byte cryptoAlgorithm; /** Public key hash */ public final byte[] pubKeyHash; /** Encryption key */ @@ -41,8 +43,9 @@ this.cryptoKey = cryptoKey; this.siteName = siteName; this.suggestedEdition = suggestedEdition; - if(!Arrays.equals(extra, ClientSSK.getExtraBytes())) - throw new MalformedURLException("Invalid extra bytes"); + // Verify extra bytes, get cryptoAlgorithm + ClientSSK tmp = new ClientSSK(siteName, pubKeyHash, extra, null, cryptoKey); + cryptoAlgorithm = tmp.cryptoAlgorithm; if(pubKeyHash.length != NodeSSK.PUBKEY_HASH_SIZE) throw new MalformedURLException("Pubkey hash wrong length: "+pubKeyHash.length+" should be "+NodeSSK.PUBKEY_HASH_SIZE); if(cryptoKey.length != ClientSSK.CRYPTO_KEY_LENGTH) @@ -56,11 +59,12 @@ return new USK(uri.getRoutingKey(), uri.getCryptoKey(), uri.getExtra(), uri.getDocName(), uri.getSuggestedEdition()); } - protected USK(byte[] pubKeyHash2, byte[] cryptoKey2, String siteName2, long suggestedEdition2) { + protected USK(byte[] pubKeyHash2, byte[] cryptoKey2, String siteName2, long suggestedEdition2, byte cryptoAlgorithm) { this.pubKeyHash = pubKeyHash2; this.cryptoKey = cryptoKey2; this.siteName = siteName2; this.suggestedEdition = suggestedEdition2; + this.cryptoAlgorithm = cryptoAlgorithm; hashCode = Fields.hashCode(pubKeyHash) ^ Fields.hashCode(cryptoKey) ^ siteName.hashCode() ^ (int)suggestedEdition ^ (int)(suggestedEdition >> 32); } @@ -70,17 +74,18 @@ this.cryptoKey = ssk.cryptoKey; this.siteName = ssk.docName; this.suggestedEdition = myARKNumber; + this.cryptoAlgorithm = ssk.cryptoAlgorithm; hashCode = Fields.hashCode(pubKeyHash) ^ Fields.hashCode(cryptoKey) ^ siteName.hashCode() ^ (int)suggestedEdition ^ (int)(suggestedEdition >> 32); } public FreenetURI getURI() { - return new FreenetURI(pubKeyHash, cryptoKey, ClientSSK.getExtraBytes(), siteName, suggestedEdition); + return new FreenetURI(pubKeyHash, cryptoKey, ClientSSK.getExtraBytes(cryptoAlgorithm), siteName, suggestedEdition); } public ClientSSK getSSK(long ver) { try { - return new ClientSSK(siteName + SEPARATOR + ver, pubKeyHash, ClientSSK.getExtraBytes(), null, cryptoKey); + return new ClientSSK(siteName + SEPARATOR + ver, pubKeyHash, ClientSSK.getExtraBytes(cryptoAlgorithm), null, cryptoKey); } catch (MalformedURLException e) { Logger.error(this, "Caught "+e+" should not be possible in USK.getSSK", e); throw new Error(e); @@ -93,7 +98,7 @@ public USK copy(long edition) { if(suggestedEdition == edition) return this; - return new USK(pubKeyHash, cryptoKey, siteName, edition); + return new USK(pubKeyHash, cryptoKey, siteName, edition, cryptoAlgorithm); } public USK clearCopy() { @@ -122,7 +127,7 @@ } public FreenetURI getBaseSSK() { - return new FreenetURI("SSK", siteName, pubKeyHash, cryptoKey, ClientSSK.getExtraBytes()); + return new FreenetURI("SSK", siteName, pubKeyHash, cryptoKey, ClientSSK.getExtraBytes(cryptoAlgorithm)); } public String toString() { Modified: trunk/freenet/src/freenet/node/PeerNode.java =================================================================== --- trunk/freenet/src/freenet/node/PeerNode.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/node/PeerNode.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -467,9 +467,9 @@ "\nFor: "+getPeer()); try { - incomingSetupCipher = new Rijndael(256,256); + incomingSetupCipher = new Rijndael(256,256,false); incomingSetupCipher.initialize(incomingSetupKey); - outgoingSetupCipher = new Rijndael(256,256); + outgoingSetupCipher = new Rijndael(256,256,false); outgoingSetupCipher.initialize(outgoingSetupKey); } catch (UnsupportedCipherException e1) { Logger.error(this, "Caught: "+e1); Modified: trunk/freenet/src/freenet/node/Version.java =================================================================== --- trunk/freenet/src/freenet/node/Version.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/node/Version.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -24,11 +24,11 @@ public static final String protocolVersion = "1.0"; /** The build number of the current revision */ - private static final int buildNumber = 1009; + private static final int buildNumber = 1010; /** Oldest build of Fred we will talk to */ - private static final int oldLastGoodBuild = 1007; - private static final int newLastGoodBuild = 1009; + private static final int oldLastGoodBuild = 1010; + private static final int newLastGoodBuild = 1010; private static final long transitionTime; static { Modified: trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java =================================================================== --- trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -31,6 +31,8 @@ private final Rijndael aes; /** The decryption key. May be null. */ private final byte[] key; + /** Broken (old) encryption? */ + private final boolean brokenEncryption; private long dataLength; private boolean readOnly; private int lastOutputStream; @@ -48,10 +50,11 @@ this.bucket = bucket; if(bucket.size() != 0) throw new IllegalArgumentException("Bucket must be empty"); try { - aes = new Rijndael(256, 256); + aes = new Rijndael(256, 256, false); } catch (UnsupportedCipherException e) { throw new Error(e); } + brokenEncryption = false; byte[] tempKey = new byte[32]; origRandom.nextBytes(tempKey); aes.initialize(tempKey); @@ -78,14 +81,15 @@ * @param origRandom * @throws IOException */ - public PaddedEphemerallyEncryptedBucket(Bucket bucket, int minSize, long knownSize, byte[] key, RandomSource origRandom) throws IOException { + public PaddedEphemerallyEncryptedBucket(Bucket bucket, int minSize, long knownSize, byte[] key, RandomSource origRandom, boolean oldCrypto) throws IOException { if(bucket.size() < knownSize) throw new IOException("Bucket "+bucket+" is too small on disk - knownSize="+knownSize+" but bucket.size="+bucket.size()+" for "+bucket); this.dataLength = knownSize; this.origRandom = origRandom; this.bucket = bucket; + brokenEncryption = oldCrypto; try { - aes = new Rijndael(256, 256); + aes = new Rijndael(256, 256, oldCrypto); } catch (UnsupportedCipherException e) { throw new Error(e); } @@ -113,9 +117,10 @@ tmp = fs.get("DecryptKey"); if(tmp == null) throw new CannotCreateFromFieldSetException("No key"); + brokenEncryption = fs.get("CryptoType") == null; key = HexUtil.hexToBytes(tmp); try { - aes = new Rijndael(256, 256); + aes = new Rijndael(256, 256, brokenEncryption); } catch (UnsupportedCipherException e) { throw new Error(e); } @@ -362,6 +367,8 @@ return null; } fs.put("MinPaddedSize", minPaddedSize); + if(!brokenEncryption) + fs.put("CryptoType", "aes256"); return fs; } Modified: trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java =================================================================== --- trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -120,19 +120,6 @@ } /** - * Restore an encrypted temp bucket from last time. - * @param filename The filename. Must exist unless len=0. - * @param key The encryption key for the bucket. - * @param len The data length. The file must be of at least this length. - * @return - * @throws IOException If the file doesn't exist or if it is too short. - */ - public Bucket registerEncryptedBucket(String filename, byte[] key, long len) throws IOException { - Bucket fileBucket = register(filename, len > 0); - return new DelayedFreeBucket(this, new PaddedEphemerallyEncryptedBucket(fileBucket, 1024, len, key, rand)); - } - - /** * Free an allocated bucket, but only after the change has been written to disk. */ public void delayedFreeBucket(Bucket b) { Modified: trunk/freenet/src/freenet/support/io/SerializableToFieldSetBucketUtil.java =================================================================== --- trunk/freenet/src/freenet/support/io/SerializableToFieldSetBucketUtil.java 2007-01-09 02:25:01 UTC (rev 11585) +++ trunk/freenet/src/freenet/support/io/SerializableToFieldSetBucketUtil.java 2007-01-09 04:38:13 UTC (rev 11586) @@ -47,7 +47,7 @@ FileBucket fb = new FileBucket(fnam, false, false, false, true); try { PaddedEphemerallyEncryptedBucket eb = - new PaddedEphemerallyEncryptedBucket(fb, 1024, len, decryptKey, random); + new PaddedEphemerallyEncryptedBucket(fb, 1024, len, decryptKey, random, true); return eb; } catch (IOException e) { throw new CannotCreateFromFieldSetException("Cannot create from old-format fieldset: "+e, e); From nextgens at freenetproject.org Tue Jan 9 23:37:57 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Tue, 9 Jan 2007 23:37:57 +0000 (UTC) Subject: [freenet-cvs] r11587 - trunk/freenet/src/freenet/keys Message-ID: <20070109233757.0BE0E9BBA9@emu.freenetproject.org> Author: nextgens Date: 2007-01-09 23:37:55 +0000 (Tue, 09 Jan 2007) New Revision: 11587 Modified: trunk/freenet/src/freenet/keys/InsertableUSK.java Log: Fix the bug preventing insertion of USKs ... thanks to Randan Modified: trunk/freenet/src/freenet/keys/InsertableUSK.java =================================================================== --- trunk/freenet/src/freenet/keys/InsertableUSK.java 2007-01-09 04:38:13 UTC (rev 11586) +++ trunk/freenet/src/freenet/keys/InsertableUSK.java 2007-01-09 23:37:55 UTC (rev 11587) @@ -35,7 +35,8 @@ uri = uri.setKeyType("SSK"); InsertableClientSSK ssk = InsertableClientSSK.create(uri); - return new InsertableUSK(ssk.docName, ssk.pubKeyHash, ssk.cryptoKey, ssk.privKey, ssk.getCryptoGroup(), uri.getSuggestedEdition(), ssk.cryptoAlgorithm); + uri = uri.setKeyType("USK"); + return new InsertablEusk(SSK.docName, ssk.pubKeyHash, ssk.cryptoKey, ssk.privKey, ssk.getCryptoGroup(), uri.getSuggestedEdition(), ssk.cryptoAlgorithm); } InsertableUSK(String docName, byte[] pubKeyHash, byte[] cryptoKey, DSAPrivateKey key, DSAGroup group, long suggestedEdition, byte cryptoAlgorithm) throws MalformedURLException { From nextgens at freenetproject.org Tue Jan 9 23:42:09 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Tue, 9 Jan 2007 23:42:09 +0000 (UTC) Subject: [freenet-cvs] r11588 - trunk/freenet/src/freenet/node Message-ID: <20070109234209.C55EF20AFA2@emu.freenetproject.org> Author: nextgens Date: 2007-01-09 23:42:06 +0000 (Tue, 09 Jan 2007) New Revision: 11588 Modified: trunk/freenet/src/freenet/node/Version.java Log: 1011: Fix the bug preventing the insertion of USKs ... I won't upload it into the auto-update mechanism... Toad, please do it. Modified: trunk/freenet/src/freenet/node/Version.java =================================================================== --- trunk/freenet/src/freenet/node/Version.java 2007-01-09 23:37:55 UTC (rev 11587) +++ trunk/freenet/src/freenet/node/Version.java 2007-01-09 23:42:06 UTC (rev 11588) @@ -24,7 +24,7 @@ public static final String protocolVersion = "1.0"; /** The build number of the current revision */ - private static final int buildNumber = 1010; + private static final int buildNumber = 1011; /** Oldest build of Fred we will talk to */ private static final int oldLastGoodBuild = 1010; From nextgens at freenetproject.org Tue Jan 9 23:45:40 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Tue, 9 Jan 2007 23:45:40 +0000 (UTC) Subject: [freenet-cvs] r11589 - trunk/freenet/src/freenet/keys Message-ID: <20070109234540.7F19420B244@emu.freenetproject.org> Author: nextgens Date: 2007-01-09 23:45:39 +0000 (Tue, 09 Jan 2007) New Revision: 11589 Modified: trunk/freenet/src/freenet/keys/InsertableUSK.java Log: fix the build Modified: trunk/freenet/src/freenet/keys/InsertableUSK.java =================================================================== --- trunk/freenet/src/freenet/keys/InsertableUSK.java 2007-01-09 23:42:06 UTC (rev 11588) +++ trunk/freenet/src/freenet/keys/InsertableUSK.java 2007-01-09 23:45:39 UTC (rev 11589) @@ -36,7 +36,7 @@ InsertableClientSSK ssk = InsertableClientSSK.create(uri); uri = uri.setKeyType("USK"); - return new InsertablEusk(SSK.docName, ssk.pubKeyHash, ssk.cryptoKey, ssk.privKey, ssk.getCryptoGroup(), uri.getSuggestedEdition(), ssk.cryptoAlgorithm); + return new InsertableUSK(ssk.docName, ssk.pubKeyHash, ssk.cryptoKey, ssk.privKey, ssk.getCryptoGroup(), uri.getSuggestedEdition(), ssk.cryptoAlgorithm); } InsertableUSK(String docName, byte[] pubKeyHash, byte[] cryptoKey, DSAPrivateKey key, DSAGroup group, long suggestedEdition, byte cryptoAlgorithm) throws MalformedURLException { From nextgens at freenetproject.org Wed Jan 10 00:07:38 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Wed, 10 Jan 2007 00:07:38 +0000 (UTC) Subject: [freenet-cvs] r11590 - trunk/freenet/src/freenet/keys Message-ID: <20070110000738.1B5D020B25A@emu.freenetproject.org> Author: nextgens Date: 2007-01-10 00:07:25 +0000 (Wed, 10 Jan 2007) New Revision: 11590 Modified: trunk/freenet/src/freenet/keys/InsertableUSK.java Log: cosmetic change : it's more readable like that Modified: trunk/freenet/src/freenet/keys/InsertableUSK.java =================================================================== --- trunk/freenet/src/freenet/keys/InsertableUSK.java 2007-01-09 23:45:39 UTC (rev 11589) +++ trunk/freenet/src/freenet/keys/InsertableUSK.java 2007-01-10 00:07:25 UTC (rev 11590) @@ -32,10 +32,8 @@ public static InsertableUSK createInsertable(FreenetURI uri) throws MalformedURLException { if(!uri.getKeyType().equalsIgnoreCase("USK")) throw new MalformedURLException(); - uri = uri.setKeyType("SSK"); InsertableClientSSK ssk = - InsertableClientSSK.create(uri); - uri = uri.setKeyType("USK"); + InsertableClientSSK.create(uri.setKeyType("SSK")); return new InsertableUSK(ssk.docName, ssk.pubKeyHash, ssk.cryptoKey, ssk.privKey, ssk.getCryptoGroup(), uri.getSuggestedEdition(), ssk.cryptoAlgorithm); } From toad at freenetproject.org Mon Jan 15 20:48:51 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Mon, 15 Jan 2007 20:48:51 +0000 (UTC) Subject: [freenet-cvs] r11599 - trunk/freenet/src/freenet/keys Message-ID: <20070115204851.2EFE220AFA4@emu.freenetproject.org> Author: toad Date: 2007-01-15 20:48:50 +0000 (Mon, 15 Jan 2007) New Revision: 11599 Modified: trunk/freenet/src/freenet/keys/InsertableClientSSK.java Log: Fix comment Modified: trunk/freenet/src/freenet/keys/InsertableClientSSK.java =================================================================== --- trunk/freenet/src/freenet/keys/InsertableClientSSK.java 2007-01-13 23:49:36 UTC (rev 11598) +++ trunk/freenet/src/freenet/keys/InsertableClientSSK.java 2007-01-15 20:48:50 UTC (rev 11599) @@ -43,7 +43,7 @@ byte[] extra = uri.getExtra(); if(uri.getKeyType().equals("SSK")) { - // FIXME remove once everyone is using PSKs + // FIXME: Remove once all SSKs migrated. if(extra == null) { keyType = Key.ALGO_INSECURE_AES_PCFB_256_SHA256; } else { From toad at freenetproject.org Mon Jan 15 21:00:47 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Mon, 15 Jan 2007 21:00:47 +0000 (UTC) Subject: [freenet-cvs] r11600 - trunk/freenet/src/freenet/node/fcp Message-ID: <20070115210047.F173B9BBE2@emu.freenetproject.org> Author: toad Date: 2007-01-15 21:00:40 +0000 (Mon, 15 Jan 2007) New Revision: 11600 Modified: trunk/freenet/src/freenet/node/fcp/FCPClient.java Log: Try to track down wierd NPE Modified: trunk/freenet/src/freenet/node/fcp/FCPClient.java =================================================================== --- trunk/freenet/src/freenet/node/fcp/FCPClient.java 2007-01-15 20:48:50 UTC (rev 11599) +++ trunk/freenet/src/freenet/node/fcp/FCPClient.java 2007-01-15 21:00:40 UTC (rev 11600) @@ -27,6 +27,7 @@ public FCPClient(String name2, FCPServer server, FCPConnectionHandler handler, boolean isGlobalQueue) { this.name = name2; + if(name == null) throw new NullPointerException(); this.currentConnection = handler; this.runningPersistentRequests = new HashSet(); this.completedUnackedRequests = new LRUQueue(); From toad at freenetproject.org Tue Jan 16 19:04:06 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 16 Jan 2007 19:04:06 +0000 (UTC) Subject: [freenet-cvs] r11601 - trunk/freenet/src/freenet/node/useralerts Message-ID: <20070116190406.1E3749BBD9@emu.freenetproject.org> Author: toad Date: 2007-01-16 19:04:05 +0000 (Tue, 16 Jan 2007) New Revision: 11601 Modified: trunk/freenet/src/freenet/node/useralerts/UserAlertManager.java Log: Check for == in compare() Modified: trunk/freenet/src/freenet/node/useralerts/UserAlertManager.java =================================================================== --- trunk/freenet/src/freenet/node/useralerts/UserAlertManager.java 2007-01-15 21:00:40 UTC (rev 11600) +++ trunk/freenet/src/freenet/node/useralerts/UserAlertManager.java 2007-01-16 19:04:05 UTC (rev 11601) @@ -47,6 +47,7 @@ public int compare(Object arg0, Object arg1) { UserAlert a0 = (UserAlert) arg0; UserAlert a1 = (UserAlert) arg1; + if(a0 == a1) return 0; // common case, also we should be consistent with == even with proxyuseralert's return a0.getPriorityClass() - a1.getPriorityClass(); } From toad at freenetproject.org Tue Jan 16 19:13:42 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 16 Jan 2007 19:13:42 +0000 (UTC) Subject: [freenet-cvs] r11602 - trunk/freenet/src/freenet/node/fcp Message-ID: <20070116191342.557F49BBD8@emu.freenetproject.org> Author: toad Date: 2007-01-16 19:13:41 +0000 (Tue, 16 Jan 2007) New Revision: 11602 Modified: trunk/freenet/src/freenet/node/fcp/ClientRequest.java Log: Dump old requests with no ClientName. Modified: trunk/freenet/src/freenet/node/fcp/ClientRequest.java =================================================================== --- trunk/freenet/src/freenet/node/fcp/ClientRequest.java 2007-01-16 19:04:05 UTC (rev 11601) +++ trunk/freenet/src/freenet/node/fcp/ClientRequest.java 2007-01-16 19:13:41 UTC (rev 11602) @@ -145,6 +145,11 @@ public static ClientRequest readAndRegister(BufferedReader br, FCPServer server) throws IOException { SimpleFieldSet fs = new SimpleFieldSet(br); String clientName = fs.get("ClientName"); + if(clientName == null) { + Logger.error(ClientRequest.class, "Discarding old request with no ClientName: "+fs); + System.err.println("Discarding old request with no ClientName (see logs)"); + return null; + } boolean isGlobal = Fields.stringToBool(fs.get("Global"), false); FCPClient client; if(!isGlobal) From toad at freenetproject.org Tue Jan 16 19:14:59 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 16 Jan 2007 19:14:59 +0000 (UTC) Subject: [freenet-cvs] r11603 - trunk/freenet/src/freenet/node/fcp Message-ID: <20070116191459.AD0709BBD8@emu.freenetproject.org> Author: toad Date: 2007-01-16 19:14:46 +0000 (Tue, 16 Jan 2007) New Revision: 11603 Modified: trunk/freenet/src/freenet/node/fcp/ClientRequest.java Log: Doh (see previous) Modified: trunk/freenet/src/freenet/node/fcp/ClientRequest.java =================================================================== --- trunk/freenet/src/freenet/node/fcp/ClientRequest.java 2007-01-16 19:13:41 UTC (rev 11602) +++ trunk/freenet/src/freenet/node/fcp/ClientRequest.java 2007-01-16 19:14:46 UTC (rev 11603) @@ -145,12 +145,12 @@ public static ClientRequest readAndRegister(BufferedReader br, FCPServer server) throws IOException { SimpleFieldSet fs = new SimpleFieldSet(br); String clientName = fs.get("ClientName"); - if(clientName == null) { + boolean isGlobal = Fields.stringToBool(fs.get("Global"), false); + if(clientName == null && !isGlobal) { Logger.error(ClientRequest.class, "Discarding old request with no ClientName: "+fs); System.err.println("Discarding old request with no ClientName (see logs)"); return null; } - boolean isGlobal = Fields.stringToBool(fs.get("Global"), false); FCPClient client; if(!isGlobal) client = server.registerClient(clientName, server.core, null); From toad at freenetproject.org Tue Jan 16 21:18:30 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 16 Jan 2007 21:18:30 +0000 (UTC) Subject: [freenet-cvs] r11604 - trunk/freenet/src/freenet/clients/http/filter Message-ID: <20070116211830.D556D9BB91@emu.freenetproject.org> Author: toad Date: 2007-01-16 21:18:29 +0000 (Tue, 16 Jan 2007) New Revision: 11604 Modified: trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java Log: Fix filter NPE. Modified: trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java =================================================================== --- trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java 2007-01-16 19:14:46 UTC (rev 11603) +++ trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java 2007-01-16 21:18:29 UTC (rev 11604) @@ -237,6 +237,7 @@ */ public String processForm(String method, String action) throws CommentException { if(action == null) return null; + if(method == "") method = "GET"; method = method.toUpperCase(); if(!(method.equals("POST") || method.equals("GET"))) return null; // no irregular form sending methods From toad at freenetproject.org Tue Jan 16 21:21:28 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 16 Jan 2007 21:21:28 +0000 (UTC) Subject: [freenet-cvs] r11605 - trunk/freenet/src/freenet/clients/http/filter Message-ID: <20070116212128.4C91E9BB91@emu.freenetproject.org> Author: toad Date: 2007-01-16 21:21:26 +0000 (Tue, 16 Jan 2007) New Revision: 11605 Modified: trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java Log: Doh Modified: trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java =================================================================== --- trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java 2007-01-16 21:18:29 UTC (rev 11604) +++ trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java 2007-01-16 21:21:26 UTC (rev 11605) @@ -237,7 +237,7 @@ */ public String processForm(String method, String action) throws CommentException { if(action == null) return null; - if(method == "") method = "GET"; + if(method == null) method = "GET"; method = method.toUpperCase(); if(!(method.equals("POST") || method.equals("GET"))) return null; // no irregular form sending methods From toad at freenetproject.org Thu Jan 25 17:16:38 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Thu, 25 Jan 2007 17:16:38 +0000 (UTC) Subject: [freenet-cvs] r11616 - in trunk/freenet/src/freenet: clients/http node/fcp Message-ID: <20070125171638.0739C9BBB1@emu.freenetproject.org> Author: toad Date: 2007-01-25 17:16:37 +0000 (Thu, 25 Jan 2007) New Revision: 11616 Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java Log: Better filename generation Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2007-01-25 07:38:02 UTC (rev 11615) +++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2007-01-25 17:16:37 UTC (rev 11616) @@ -561,8 +561,8 @@ * @param expectedMimeType The expected MIME type. */ private String getFilename(FetchException e, FreenetURI uri, String expectedMimeType) { - String s = getFilename(e, uri); - int dotIdx = s.indexOf('.'); + String s = uri.getPreferredFilename(); + int dotIdx = s.lastIndexOf('.'); String ext = DefaultMIMETypes.getExtension(expectedMimeType); if(ext == null) ext = "bin"; @@ -579,32 +579,4 @@ return s + '.' + ext; } - private String getFilename(FetchException e, FreenetURI uri) { - String fnam = sanitize(uri.getDocName()); - if((fnam != null) && (fnam.length() > 0)) return fnam; - String[] meta = uri.getAllMetaStrings(); - if(meta != null) { - for(int i=meta.length-1;i>=0;i++) { - String s = meta[i]; - if(s == null) continue; - if(s.length() == 0) continue; - fnam = sanitize(s); - if((s != null) && (s.length() > 0)) return fnam; - } - } - return Base64.encode(uri.getRoutingKey()); - } - - private String sanitize(String s) { - if(s == null) return null; - StringBuffer sb = new StringBuffer(s.length()); - for(int i=0;i Author: toad Date: 2007-01-27 18:27:03 +0000 (Sat, 27 Jan 2007) New Revision: 11626 Modified: trunk/freenet/src/freenet/keys/CHKBlock.java trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java Log: Maybe fix store reconstruction bug Modified: trunk/freenet/src/freenet/keys/CHKBlock.java =================================================================== --- trunk/freenet/src/freenet/keys/CHKBlock.java 2007-01-27 17:31:14 UTC (rev 11625) +++ trunk/freenet/src/freenet/keys/CHKBlock.java 2007-01-27 18:27:03 UTC (rev 11626) @@ -43,6 +43,15 @@ return data; } + public static CHKBlock construct(byte[] data, byte[] header) throws CHKVerifyException { + try { + return new CHKBlock(data, header, null, true, Key.ALGO_AES_PCFB_256_SHA256); + } catch (CHKVerifyException e) { + // FIXME remove back compatibility code + return new CHKBlock(data, header, null, true, Key.ALGO_INSECURE_AES_PCFB_256_SHA256); + } + } + public CHKBlock(byte[] data2, byte[] header2, NodeCHK key) throws CHKVerifyException { this(data2, header2, key, key.cryptoAlgorithm); } Modified: trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java =================================================================== --- trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java 2007-01-27 17:31:14 UTC (rev 11625) +++ trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java 2007-01-27 18:27:03 UTC (rev 11626) @@ -32,6 +32,7 @@ import freenet.crypt.RandomSource; import freenet.keys.CHKBlock; import freenet.keys.CHKVerifyException; +import freenet.keys.Key; import freenet.keys.KeyBlock; import freenet.keys.NodeCHK; import freenet.keys.NodeSSK; @@ -1078,7 +1079,7 @@ byte[] routingkey = null; if(type == TYPE_CHK) { try { - CHKBlock chk = new CHKBlock(data, header, null); + CHKBlock chk = CHKBlock.construct(data, header); routingkey = chk.getKey().getRoutingKey(); } catch (CHKVerifyException e) { String err = "Bogus key at slot "+l+" : "+e+" - lost block "+l; From nextgens at freenetproject.org Sat Jan 27 19:12:08 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Sat, 27 Jan 2007 19:12:08 +0000 (UTC) Subject: [freenet-cvs] r11629 - trunk/freenet/src/freenet/node/useralerts Message-ID: <20070127191208.6B5C49BB29@emu.freenetproject.org> Author: nextgens Date: 2007-01-27 19:12:07 +0000 (Sat, 27 Jan 2007) New Revision: 11629 Modified: trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java Log: Fix a typo: we weren't displaying nodeAveragePingTime but bwlimitDelayTime. Thanks to saces Modified: trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java =================================================================== --- trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java 2007-01-27 19:08:10 UTC (rev 11628) +++ trunk/freenet/src/freenet/node/useralerts/PeerManagerUserAlert.java 2007-01-27 19:12:07 UTC (rev 11629) @@ -220,7 +220,7 @@ } else if (n.bwlimitDelayAlertRelevant && (bwlimitDelayTime > Node.MAX_BWLIMIT_DELAY_TIME_ALERT_THRESHOLD)) { alertNode.addChild("#", replace(TOO_HIGH_BWLIMITDELAYTIME, "\\{BWLIMIT_DELAY_TIME\\}", Integer.toString(bwlimitDelayTime))); } else if (n.nodeAveragePingAlertRelevant && (nodeAveragePingTime > Node.MAX_NODE_AVERAGE_PING_TIME_ALERT_THRESHOLD)) { - alertNode.addChild("#", replace(TOO_HIGH_PING, "\\{PING_TIME\\}", Integer.toString(bwlimitDelayTime))); + alertNode.addChild("#", replace(TOO_HIGH_PING, "\\{PING_TIME\\}", Integer.toString(nodeAveragePingTime))); } else if (oldestNeverConnectedPeerAge > MAX_OLDEST_NEVER_CONNECTED_PEER_AGE_ALERT_THRESHOLD) { alertNode.addChild("#", NEVER_CONNECTED_TWO_WEEKS); } else throw new IllegalArgumentException("not valid"); From zothar at freenetproject.org Sun Jan 28 16:41:38 2007 From: zothar at freenetproject.org (zothar at freenetproject.org) Date: Sun, 28 Jan 2007 16:41:38 +0000 (UTC) Subject: [freenet-cvs] r11642 - in trunk/freenet/src/freenet: clients/http io/comm node support Message-ID: <20070128164138.C29A19BB47@emu.freenetproject.org> Author: zothar Date: 2007-01-28 16:41:37 +0000 (Sun, 28 Jan 2007) New Revision: 11642 Added: trunk/freenet/src/freenet/support/OOMHandler.java Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java trunk/freenet/src/freenet/io/comm/UdpSocketManager.java trunk/freenet/src/freenet/node/DNSRequester.java trunk/freenet/src/freenet/node/PacketSender.java trunk/freenet/src/freenet/node/RequestStarter.java trunk/freenet/src/freenet/support/FileLoggerHook.java Log: Factored out and updated OOM handling in some places. Added OOM and/or Throwable handling in other places. OOMs logged through the wrapper should now be much more informative in some cases. Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java =================================================================== --- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java 2007-01-28 14:53:53 UTC (rev 11641) +++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java 2007-01-28 16:41:37 UTC (rev 11642) @@ -27,8 +27,9 @@ import freenet.io.NetworkInterface; import freenet.node.NodeClientCore; import freenet.support.FileLoggerHook; +import freenet.support.FileLoggerHook.IntervalParseException; import freenet.support.Logger; -import freenet.support.FileLoggerHook.IntervalParseException; +import freenet.support.OOMHandler; import freenet.support.api.BooleanCallback; import freenet.support.api.BucketFactory; import freenet.support.api.IntCallback; @@ -397,7 +398,16 @@ public void run() { boolean logMINOR = Logger.shouldLog(Logger.MINOR, this); if(logMINOR) Logger.minor(this, "Handling connection"); - ToadletContextImpl.handle(sock, SimpleToadletServer.this, bf, pageMaker); + try { + ToadletContextImpl.handle(sock, SimpleToadletServer.this, bf, pageMaker); + } catch (OutOfMemoryError e) { + OOMHandler.handleOOM(e); + System.err.println("SimpleToadlesServer request above failed."); + } catch (Throwable t) { + System.err.println("Caught in SimpleToadletServer: "+t); + t.printStackTrace(); + Logger.error(this, "Caught in SimpleToadletServer: "+t, t); + } if(logMINOR) Logger.minor(this, "Handled connection"); } Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java =================================================================== --- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2007-01-28 14:53:53 UTC (rev 11641) +++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2007-01-28 16:41:37 UTC (rev 11642) @@ -31,6 +31,7 @@ import freenet.node.PeerNode; import freenet.support.FileLoggerHook; import freenet.support.Logger; +import freenet.support.OOMHandler; import freenet.support.TimeUtil; public class UdpSocketManager extends Thread { @@ -201,10 +202,13 @@ try { lastTimeInSeconds = (int) (System.currentTimeMillis() / 1000); realRun(); + } catch (OutOfMemoryError e) { + OOMHandler.handleOOM(e); + System.err.println("Will retry above failed operation..."); } catch (Throwable t) { - Logger.error(this, "Caught " + t, t); System.err.println("Caught "+t); t.printStackTrace(System.err); + Logger.error(this, "Caught " + t, t); } } } Modified: trunk/freenet/src/freenet/node/DNSRequester.java =================================================================== --- trunk/freenet/src/freenet/node/DNSRequester.java 2007-01-28 14:53:53 UTC (rev 11641) +++ trunk/freenet/src/freenet/node/DNSRequester.java 2007-01-28 16:41:37 UTC (rev 11642) @@ -4,6 +4,7 @@ package freenet.node; import freenet.support.Logger; +import freenet.support.OOMHandler; /** * @author amphibian @@ -33,18 +34,8 @@ try { realRun(); } catch (OutOfMemoryError e) { - Runtime r = Runtime.getRuntime(); - long usedAtStart = r.totalMemory() - r.freeMemory(); - System.gc(); - System.runFinalization(); - System.gc(); - System.runFinalization(); - System.err.println(e.getClass()); - System.err.println(e.getMessage()); - e.printStackTrace(); - long usedNow = r.totalMemory() - r.freeMemory(); - Logger.error(this, "Caught "+e, e); - Logger.error(this, "Used: "+usedAtStart+" now "+usedNow); + OOMHandler.handleOOM(e); + System.err.println("Will retry above failed operation..."); } catch (Throwable t) { Logger.error(this, "Caught in DNSRequester: "+t, t); } Modified: trunk/freenet/src/freenet/node/PacketSender.java =================================================================== --- trunk/freenet/src/freenet/node/PacketSender.java 2007-01-28 14:53:53 UTC (rev 11641) +++ trunk/freenet/src/freenet/node/PacketSender.java 2007-01-28 16:41:37 UTC (rev 11642) @@ -14,6 +14,7 @@ import freenet.io.comm.NotConnectedException; import freenet.support.FileLoggerHook; import freenet.support.Logger; +import freenet.support.OOMHandler; import freenet.support.WouldBlockException; /** @@ -122,31 +123,8 @@ logMINOR = Logger.shouldLog(Logger.MINOR, this); realRun(); } catch (OutOfMemoryError e) { - Runtime r = null; - try { - r = Runtime.getRuntime(); - long usedAtStart = r.totalMemory() - r.freeMemory(); - System.gc(); - System.runFinalization(); - System.gc(); - System.runFinalization(); - System.err.println(e.getClass()); - System.err.println(e.getMessage()); - e.printStackTrace(); - long usedNow = r.totalMemory() - r.freeMemory(); - Logger.error(this, "Caught "+e, e); - Logger.error(this, "Used: "+usedAtStart+" now "+usedNow); - } catch (Throwable t) { - // Try without GCing, it might be a thread error; GCing creates a thread - System.err.println("Caught handling OOM "+e+" : "+t); - e.printStackTrace(); - if(r != null) - System.err.println("Memory: total "+r.totalMemory()+" free "+r.freeMemory()+" max "+r.maxMemory()); - ThreadGroup tg = Thread.currentThread().getThreadGroup(); - while(tg.getParent() != null) tg = tg.getParent(); - System.err.println("Running threads: "+tg.activeCount()); - WrapperManager.requestThreadDump(); // Will probably crash, but never mind... - } + OOMHandler.handleOOM(e); + System.err.println("Will retry above failed operation..."); } catch (Throwable t) { Logger.error(this, "Caught in PacketSender: "+t, t); System.err.println("Caught in PacketSender: "+t); @@ -353,9 +331,19 @@ Logger.error(this, "Caught "+t+" running "+r, t); } } else { - Thread t = new Thread(r, "Scheduled job: "+r); - t.setDaemon(true); - t.start(); + try { + Thread t = new Thread(r, "Scheduled job: "+r); + t.setDaemon(true); + t.start(); + } catch (OutOfMemoryError e) { + OOMHandler.handleOOM(e); + System.err.println("Will retry above failed operation..."); + queueTimedJob(r, 200); + } catch (Throwable t) { + Logger.error(this, "Caught in PacketSender: "+t, t); + System.err.println("Caught in PacketSender: "+t); + t.printStackTrace(); + } } } } Modified: trunk/freenet/src/freenet/node/RequestStarter.java =================================================================== --- trunk/freenet/src/freenet/node/RequestStarter.java 2007-01-28 14:53:53 UTC (rev 11641) +++ trunk/freenet/src/freenet/node/RequestStarter.java 2007-01-28 16:41:37 UTC (rev 11642) @@ -4,6 +4,7 @@ package freenet.node; import freenet.support.Logger; +import freenet.support.OOMHandler; import freenet.support.TokenBucket; import freenet.support.math.RunningAverage; @@ -93,13 +94,14 @@ if(logMINOR) Logger.minor(this, "Started "+req+" on "+t); break; } catch (OutOfMemoryError e) { - // Probably out of threads + OOMHandler.handleOOM(e); + System.err.println("Will retry above failed operation..."); + // Possibly out of threads try { Thread.sleep(5000); } catch (InterruptedException e1) { // Ignore } - System.err.println(e.getMessage()); } } sentRequestTime = System.currentTimeMillis(); Modified: trunk/freenet/src/freenet/support/FileLoggerHook.java =================================================================== --- trunk/freenet/src/freenet/support/FileLoggerHook.java 2007-01-28 14:53:53 UTC (rev 11641) +++ trunk/freenet/src/freenet/support/FileLoggerHook.java 2007-01-28 16:41:37 UTC (rev 11642) @@ -339,6 +339,9 @@ if(altLogStream != null) myWrite(altLogStream, (byte[]) o); } catch (OutOfMemoryError e) { + System.err.println(e.getClass()); + System.err.println(e.getMessage()); + e.printStackTrace(); // FIXME //freenet.node.Main.dumpInterestingObjects(); } catch (Throwable t) { Added: trunk/freenet/src/freenet/support/OOMHandler.java =================================================================== --- trunk/freenet/src/freenet/support/OOMHandler.java (rev 0) +++ trunk/freenet/src/freenet/support/OOMHandler.java 2007-01-28 16:41:37 UTC (rev 11642) @@ -0,0 +1,51 @@ +/* This code is part of Freenet. It is distributed under the GNU General + * Public License, version 2 (or at your option any later version). See + * http://www.gnu.org/ for further details of the GPL. */ +package freenet.support; + +import org.tanukisoftware.wrapper.WrapperManager; + +import freenet.support.Logger; + +/** + * Do this processing as a standard response to an OutOfMemoryError + */ +public class OOMHandler { + + public synchronized static void handleOOM(OutOfMemoryError e) { + Runtime r = null; + try { + r = Runtime.getRuntime(); + long usedAtStart = r.totalMemory() - r.freeMemory(); + System.gc(); + System.runFinalization(); + System.gc(); + System.runFinalization(); + System.err.println(e.getClass()); + System.err.println(e.getMessage()); + e.printStackTrace(); + if(e.getMessage().equals("Java heap space")) { + Thread.dumpStack(); + } + long usedNow = r.totalMemory() - r.freeMemory(); + System.err.println("Memory: GC "+SizeUtil.formatSize(usedAtStart, false)+" -> "+SizeUtil.formatSize(usedNow, false)+": total "+SizeUtil.formatSize(r.totalMemory(), false)+" free "+SizeUtil.formatSize(r.freeMemory(), false)+" max "+SizeUtil.formatSize(r.maxMemory(), false)); + ThreadGroup tg = Thread.currentThread().getThreadGroup(); + while(tg.getParent() != null) tg = tg.getParent(); + System.err.println("Running threads: "+tg.activeCount()); + // Logger after everything else since it might throw + Logger.error(null, "Caught "+e, e); + Logger.error(null, "Memory: GC "+SizeUtil.formatSize(usedAtStart, false)+" -> "+SizeUtil.formatSize(usedNow, false)+": total "+SizeUtil.formatSize(r.totalMemory(), false)+" free "+SizeUtil.formatSize(r.freeMemory(), false)+" max "+SizeUtil.formatSize(r.maxMemory(), false)); + Logger.error(null, "Running threads: "+tg.activeCount()); + } catch (Throwable t) { + // Try without GCing, it might be a thread error; GCing creates a thread + System.err.println("Caught handling OOM "+e+" : "+t); + e.printStackTrace(); + if(r != null) + System.err.println("Memory: total "+SizeUtil.formatSize(r.totalMemory(), false)+" free "+SizeUtil.formatSize(r.freeMemory(), false)+" max "+SizeUtil.formatSize(r.maxMemory(), false)); + ThreadGroup tg = Thread.currentThread().getThreadGroup(); + while(tg.getParent() != null) tg = tg.getParent(); + System.err.println("Running threads: "+tg.activeCount()); + WrapperManager.requestThreadDump(); // Will probably crash, but never mind... + } + } +} From toad at freenetproject.org Tue Jan 30 15:22:23 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 30 Jan 2007 15:22:23 +0000 (UTC) Subject: [freenet-cvs] r11644 - trunk/freenet/src/freenet/crypt Message-ID: <20070130152223.9E5F69BC10@emu.freenetproject.org> Author: toad Date: 2007-01-30 15:22:22 +0000 (Tue, 30 Jan 2007) New Revision: 11644 Modified: trunk/freenet/src/freenet/crypt/DSAGroup.java Log: Small memory/cpu optimisation Modified: trunk/freenet/src/freenet/crypt/DSAGroup.java =================================================================== --- trunk/freenet/src/freenet/crypt/DSAGroup.java 2007-01-28 17:56:32 UTC (rev 11643) +++ trunk/freenet/src/freenet/crypt/DSAGroup.java 2007-01-30 15:22:22 UTC (rev 11644) @@ -69,6 +69,8 @@ } private void updateCachedHexStrings() { + if(pAsHexString != null && qAsHexString != null && gAsHexString != null) + return; pAsHexString = HexUtil.biToHex(p); qAsHexString = HexUtil.biToHex(q); gAsHexString = HexUtil.biToHex(g); @@ -107,6 +109,7 @@ // } public String writeAsField() { + updateCachedHexStrings(); StringBuffer b = new StringBuffer(); b.append(pAsHexString).append(','); b.append(qAsHexString).append(','); @@ -144,14 +147,17 @@ } public String getPAsHexString() { + updateCachedHexStrings(); return pAsHexString; } public String getQAsHexString() { + updateCachedHexStrings(); return qAsHexString; } public String getGAsHexString() { + updateCachedHexStrings(); return gAsHexString; } @@ -347,6 +353,8 @@ BigInteger p = new NativeBigInteger(1, Base64.decode(fs.get("p"))); BigInteger q = new NativeBigInteger(1, Base64.decode(fs.get("q"))); BigInteger g = new NativeBigInteger(1, Base64.decode(fs.get("g"))); - return new DSAGroup(p, q, g); + DSAGroup dg = new DSAGroup(p, q, g); + if(dg.equals(Global.DSAgroupBigA)) return Global.DSAgroupBigA; + return dg; } } From toad at freenetproject.org Tue Jan 30 15:23:35 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 30 Jan 2007 15:23:35 +0000 (UTC) Subject: [freenet-cvs] r11645 - trunk/freenet/src/freenet/crypt Message-ID: <20070130152335.1CCAC9BC10@emu.freenetproject.org> Author: toad Date: 2007-01-30 15:23:16 +0000 (Tue, 30 Jan 2007) New Revision: 11645 Modified: trunk/freenet/src/freenet/crypt/DSAGroup.java Log: Remove unused destroy(), make p,q,g final. Modified: trunk/freenet/src/freenet/crypt/DSAGroup.java =================================================================== --- trunk/freenet/src/freenet/crypt/DSAGroup.java 2007-01-30 15:22:22 UTC (rev 11644) +++ trunk/freenet/src/freenet/crypt/DSAGroup.java 2007-01-30 15:23:16 UTC (rev 11645) @@ -27,7 +27,7 @@ public static final int Q_BIT_LENGTH = 160; - private BigInteger p, q, g; + private final BigInteger p, q, g; private String pAsHexString, gAsHexString, qAsHexString; //Cached versions @@ -337,10 +337,6 @@ return p.hashCode() ^ q.hashCode() ^ g.hashCode(); } - public void destroy() { - p = q = g = null; - } - public SimpleFieldSet asFieldSet() { SimpleFieldSet fs = new SimpleFieldSet(); fs.put("p", Base64.encode(p.toByteArray())); From toad at freenetproject.org Tue Jan 30 16:13:47 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Tue, 30 Jan 2007 16:13:47 +0000 (UTC) Subject: [freenet-cvs] r11646 - trunk/freenet/src/freenet/crypt Message-ID: <20070130161347.9083B9BC05@emu.freenetproject.org> Author: toad Date: 2007-01-30 16:13:46 +0000 (Tue, 30 Jan 2007) New Revision: 11646 Modified: trunk/freenet/src/freenet/crypt/DSAPublicKey.java Log: be lazy Modified: trunk/freenet/src/freenet/crypt/DSAPublicKey.java =================================================================== --- trunk/freenet/src/freenet/crypt/DSAPublicKey.java 2007-01-30 15:23:16 UTC (rev 11645) +++ trunk/freenet/src/freenet/crypt/DSAPublicKey.java 2007-01-30 16:13:46 UTC (rev 11646) @@ -17,7 +17,7 @@ private final BigInteger y; /** A cache of the hexadecimal string representation of y */ - private final String yAsHexString; + private String yAsHexString; public static final int PADDED_SIZE = 1024; @@ -27,7 +27,6 @@ public DSAPublicKey(DSAGroup g, BigInteger y) { this.y=y; - this.yAsHexString = HexUtil.biToHex(y); this.group=g; if(g == null) throw new NullPointerException(); } @@ -50,7 +49,6 @@ public DSAPublicKey(InputStream is) throws IOException { group=(DSAGroup) DSAGroup.read(is); y=Util.readMPI(is); - this.yAsHexString = HexUtil.biToHex(y); } public DSAPublicKey(byte[] pubkeyAsBytes) throws IOException { @@ -62,6 +60,8 @@ } public String getYAsHexString() { + if(yAsHexString == null) + this.yAsHexString = HexUtil.biToHex(y); return yAsHexString; }