diff --git a/core/java/src/net/i2p/util/ByteArrayStream.java b/core/java/src/net/i2p/util/ByteArrayStream.java new file mode 100644 index 0000000000..22192c5944 --- /dev/null +++ b/core/java/src/net/i2p/util/ByteArrayStream.java @@ -0,0 +1,52 @@ +package net.i2p.util; + +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; +import java.util.Arrays; + +/** + * OutputStream to InputStream adapter. + * Zero-copy where possible. Unsynchronized. + * This is NOT a Pipe. + * Do NOT reset after writing. + * + * @since 0.9.48 + */ +public class ByteArrayStream extends ByteArrayOutputStream { + + public ByteArrayStream() { + super(); + } + + public ByteArrayStream(int size) { + super(size); + } + + /** + * @throws IllegalStateException if previously written + */ + @Override + public void reset() { + if (count > 0) + throw new IllegalStateException(); + } + + /** + * Zero-copy only if the data fills the buffer. + * Use asInputStream() for guaranteed zero-copy. + */ + @Override + public byte[] toByteArray() { + if (count == buf.length) + return buf; + return Arrays.copyOfRange(buf, 0, count); + } + + /** + * All data previously written. Zero-copy. Not a Pipe. + * Data written after this call will not appear. + */ + public ByteArrayInputStream asInputStream() { + return new ByteArrayInputStream(buf, 0, count); + } +} diff --git a/history.txt b/history.txt index bc6f18640c..d5f718e1ba 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,15 @@ +2020-11-02 zzz + * I2CP: Remove tunnels immediately on client disconnect + * i2psnark: Limit max size of embedded video + * i2ptunnel: Restart tunnel if offline-signed private key file updated + +2020-10-30 zzz + * i2psnark: MetaInfo support for url-list (prep for BEP 19) + * Util: Fix NPE in EepGet CLI callback via PartialEepGet + 2020-10-29 zzz + * Crypto: Precalculate Noise initial hashes + * i2psnark: Store BEP 47 padding file info * Tunnels: Improved logging and handling of offline signature expiration 2020-10-28 zzz diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 5a58b19bc2..e36cd3b143 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 11; + public final static long BUILD = 12; /** for example "-test" */ public final static String EXTRA = "";