Author: toad
Date: 2006-01-25 14:18:06 +0000 (Wed, 25 Jan 2006)
New Revision: 7918
Added:
branches/async-client/src/freenet/node/fcp/GenerateSSKMessage.java
branches/async-client/src/freenet/node/fcp/SSKKeypairMessage.java
Modified:
branches/async-client/src/freenet/keys/ClientCHKBlock.java
branches/async-client/src/freenet/keys/InsertableClientSSK.java
branches/async-client/src/freenet/keys/Key.java
branches/async-client/src/freenet/node/AnyInsertSender.java
branches/async-client/src/freenet/node/CHKInsertSender.java
branches/async-client/src/freenet/node/Node.java
branches/async-client/src/freenet/node/SSKInsertSender.java
branches/async-client/src/freenet/node/Version.java
branches/async-client/src/freenet/node/fcp/ClientHelloMessage.java
branches/async-client/src/freenet/node/fcp/FCPMessage.java
branches/async-client/src/freenet/node/fcp/NodeHelloMessage.java
Log:
Merge changes from trunk.
Modified: branches/async-client/src/freenet/keys/ClientCHKBlock.java
===================================================================
--- branches/async-client/src/freenet/keys/ClientCHKBlock.java 2006-01-25
14:14:13 UTC (rev 7917)
+++ branches/async-client/src/freenet/keys/ClientCHKBlock.java 2006-01-25
14:18:06 UTC (rev 7918)
@@ -152,7 +152,7 @@
ClientCHK key;
short compressionAlgorithm = -1;
try {
- Compressed comp = Key.compress(sourceData,
dontCompress, alreadyCompressedCodec, sourceLength,
MAX_LENGTH_BEFORE_COMPRESSION, MAX_COMPRESSED_DATA_LENGTH);
+ Compressed comp = Key.compress(sourceData,
dontCompress, alreadyCompressedCodec, sourceLength,
MAX_LENGTH_BEFORE_COMPRESSION, MAX_COMPRESSED_DATA_LENGTH, false);
finalData = comp.compressedData;
compressionAlgorithm = comp.compressionAlgorithm;
} catch (KeyEncodeException e2) {
Modified: branches/async-client/src/freenet/keys/InsertableClientSSK.java
===================================================================
--- branches/async-client/src/freenet/keys/InsertableClientSSK.java
2006-01-25 14:14:13 UTC (rev 7917)
+++ branches/async-client/src/freenet/keys/InsertableClientSSK.java
2006-01-25 14:18:06 UTC (rev 7918)
@@ -56,7 +56,7 @@
byte[] compressedData;
short compressionAlgo;
try {
- Compressed comp = Key.compress(sourceData,
dontCompress, alreadyCompressedCodec, sourceLength,
ClientSSKBlock.MAX_DECOMPRESSED_DATA_LENGTH, ClientSSKBlock.DATA_LENGTH);
+ Compressed comp = Key.compress(sourceData,
dontCompress, alreadyCompressedCodec, sourceLength,
ClientSSKBlock.MAX_DECOMPRESSED_DATA_LENGTH, ClientSSKBlock.DATA_LENGTH, true);
compressedData = comp.compressedData;
compressionAlgo = comp.compressionAlgorithm;
} catch (KeyEncodeException e) {
Modified: branches/async-client/src/freenet/keys/Key.java
===================================================================
--- branches/async-client/src/freenet/keys/Key.java 2006-01-25 14:14:13 UTC
(rev 7917)
+++ branches/async-client/src/freenet/keys/Key.java 2006-01-25 14:18:06 UTC
(rev 7918)
@@ -96,7 +96,7 @@
static Bucket decompress(boolean isCompressed, byte[] output,
BucketFactory bf, int maxLength, short compressionAlgorithm, boolean
shortLength) throws CHKDecodeException, IOException {
if(isCompressed) {
- Logger.minor(Key.class, "Decompressing in decode with codec
"+compressionAlgorithm);
+ Logger.minor(Key.class, "Decompressing "+output.length+" bytes
in decode with codec "+compressionAlgorithm);
if(output.length < (shortLength ? 3 : 5)) throw new
CHKDecodeException("No bytes to decompress");
// Decompress
// First get the length
@@ -129,12 +129,11 @@
short compressionAlgorithm;
}
- static Compressed compress(Bucket sourceData, boolean dontCompress, short
alreadyCompressedCodec, long sourceLength, long MAX_LENGTH_BEFORE_COMPRESSION,
long MAX_COMPRESSED_DATA_LENGTH) throws KeyEncodeException, IOException {
+ static Compressed compress(Bucket sourceData, boolean dontCompress, short
alreadyCompressedCodec, long sourceLength, long MAX_LENGTH_BEFORE_COMPRESSION,
long MAX_COMPRESSED_DATA_LENGTH, boolean shortLength) throws
KeyEncodeException, IOException {
byte[] finalData = null;
short compressionAlgorithm = -1;
// Try to compress it - even if it fits into the block,
// because compressing it improves its entropy.
- boolean compressed = false;
if(sourceData.size() > MAX_LENGTH_BEFORE_COMPRESSION)
throw new KeyEncodeException("Too big");
if(!dontCompress) {
@@ -180,13 +179,17 @@
if(cbuf != null) {
// Use it
int compressedLength = cbuf.length;
- finalData = new byte[compressedLength+4];
- System.arraycopy(cbuf, 0, finalData, 4, compressedLength);
- finalData[0] = (byte) ((sourceLength >> 24) & 0xff);
- finalData[1] = (byte) ((sourceLength >> 16) & 0xff);
- finalData[2] = (byte) ((sourceLength >> 8) & 0xff);
- finalData[3] = (byte) ((sourceLength) & 0xff);
- compressed = true;
+ finalData = new byte[compressedLength+(shortLength?2:4)];
+ System.arraycopy(cbuf, 0, finalData, shortLength?2:4,
compressedLength);
+ if(!shortLength) {
+ finalData[0] = (byte) ((sourceLength >> 24) & 0xff);
+ finalData[1] = (byte) ((sourceLength >> 16) & 0xff);
+ finalData[2] = (byte) ((sourceLength >> 8) & 0xff);
+ finalData[3] = (byte) ((sourceLength) & 0xff);
+ } else {
+ finalData[0] = (byte) ((sourceLength >> 8) & 0xff);
+ finalData[1] = (byte) ((sourceLength) & 0xff);
+ }
}
}
if(finalData == null) {
Modified: branches/async-client/src/freenet/node/AnyInsertSender.java
===================================================================
--- branches/async-client/src/freenet/node/AnyInsertSender.java 2006-01-25
14:14:13 UTC (rev 7917)
+++ branches/async-client/src/freenet/node/AnyInsertSender.java 2006-01-25
14:18:06 UTC (rev 7918)
@@ -13,4 +13,6 @@
public abstract boolean sentRequest();
+ public abstract long getUID();
+
}
\ No newline at end of file
Modified: branches/async-client/src/freenet/node/CHKInsertSender.java
===================================================================
--- branches/async-client/src/freenet/node/CHKInsertSender.java 2006-01-25
14:14:13 UTC (rev 7917)
+++ branches/async-client/src/freenet/node/CHKInsertSender.java 2006-01-25
14:18:06 UTC (rev 7918)
@@ -804,4 +804,8 @@
public byte[] getHeaders() {
return headers;
}
+
+ public long getUID() {
+ return uid;
+ }
}
Modified: branches/async-client/src/freenet/node/Node.java
===================================================================
--- branches/async-client/src/freenet/node/Node.java 2006-01-25 14:14:13 UTC
(rev 7917)
+++ branches/async-client/src/freenet/node/Node.java 2006-01-25 14:18:06 UTC
(rev 7918)
@@ -155,7 +155,7 @@
String myName;
final LocationManager lm;
final PeerManager peers; // my peers
- final RandomSource random; // strong RNG
+ public final RandomSource random; // strong RNG
final UdpSocketManager usm;
final FNPPacketMangler packetMangler;
final PacketSender ps;
@@ -1268,8 +1268,8 @@
// Dump
Iterator i = insertSenders.values().iterator();
while(i.hasNext()) {
- CHKInsertSender s = (CHKInsertSender) i.next();
- sb.append(s.uid);
+ AnyInsertSender s = (AnyInsertSender) i.next();
+ sb.append(s.getUID());
sb.append(": ");
sb.append(s.getStatusString());
sb.append('\n');
@@ -1457,4 +1457,8 @@
Logger.error(this, "Error accessing pubkey store: "+e,
e);
}
}
+
+ public boolean isTestnetEnabled() {
+ return testnetEnabled;
+ }
}
Modified: branches/async-client/src/freenet/node/SSKInsertSender.java
===================================================================
--- branches/async-client/src/freenet/node/SSKInsertSender.java 2006-01-25
14:14:13 UTC (rev 7917)
+++ branches/async-client/src/freenet/node/SSKInsertSender.java 2006-01-25
14:18:06 UTC (rev 7918)
@@ -516,4 +516,8 @@
return block;
}
+ public long getUID() {
+ return uid;
+ }
+
}
Modified: branches/async-client/src/freenet/node/Version.java
===================================================================
--- branches/async-client/src/freenet/node/Version.java 2006-01-25 14:14:13 UTC
(rev 7917)
+++ branches/async-client/src/freenet/node/Version.java 2006-01-25 14:18:06 UTC
(rev 7918)
@@ -20,10 +20,10 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- public static final int buildNumber = 374;
+ public static final int buildNumber = 380;
/** Oldest build of Fred we will talk to */
- public static final int lastGoodBuild = 374;
+ public static final int lastGoodBuild = 380;
/** The highest reported build of fred */
public static int highestSeenBuild = buildNumber;
Modified: branches/async-client/src/freenet/node/fcp/ClientHelloMessage.java
===================================================================
--- branches/async-client/src/freenet/node/fcp/ClientHelloMessage.java
2006-01-25 14:14:13 UTC (rev 7917)
+++ branches/async-client/src/freenet/node/fcp/ClientHelloMessage.java
2006-01-25 14:18:06 UTC (rev 7918)
@@ -39,7 +39,7 @@
public void run(FCPConnectionHandler handler, Node node) {
// We know the Hello is valid.
handler.setClientName(clientName);
- FCPMessage msg = new NodeHelloMessage();
+ FCPMessage msg = new NodeHelloMessage(node);
handler.outputHandler.queue(msg);
}
Modified: branches/async-client/src/freenet/node/fcp/FCPMessage.java
===================================================================
--- branches/async-client/src/freenet/node/fcp/FCPMessage.java 2006-01-25
14:14:13 UTC (rev 7917)
+++ branches/async-client/src/freenet/node/fcp/FCPMessage.java 2006-01-25
14:18:06 UTC (rev 7918)
@@ -31,6 +31,8 @@
return new ClientGetMessage(fs);
if(name.equals(ClientPutMessage.name))
return new ClientPutMessage(fs);
+ if(name.equals(GenerateSSKMessage.name))
+ return new GenerateSSKMessage();
if(name.equals("Void"))
return null;
// if(name.equals("ClientPut"))
Copied: branches/async-client/src/freenet/node/fcp/GenerateSSKMessage.java
(from rev 7917, trunk/freenet/src/freenet/node/fcp/GenerateSSKMessage.java)
Modified: branches/async-client/src/freenet/node/fcp/NodeHelloMessage.java
===================================================================
--- branches/async-client/src/freenet/node/fcp/NodeHelloMessage.java
2006-01-25 14:14:13 UTC (rev 7917)
+++ branches/async-client/src/freenet/node/fcp/NodeHelloMessage.java
2006-01-25 14:18:06 UTC (rev 7918)
@@ -15,12 +15,19 @@
*/
public class NodeHelloMessage extends FCPMessage {
+ private final Node node;
+
+ public NodeHelloMessage(Node node) {
+ this.node = node;
+ }
+
public SimpleFieldSet getFieldSet() {
SimpleFieldSet sfs = new SimpleFieldSet();
// FIXME
sfs.put("FCPVersion", "0.7.0");
sfs.put("Node", "Fred");
sfs.put("Version", Version.getVersionString());
+ sfs.put("Testnet", Boolean.toString(node.isTestnetEnabled()));
return sfs;
}
Copied: branches/async-client/src/freenet/node/fcp/SSKKeypairMessage.java (from
rev 7917, trunk/freenet/src/freenet/node/fcp/SSKKeypairMessage.java)