mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Refactored transport component and renamed WritersModule.
The goal of the refactoring was to clean up the dependencies of IncomingBatchConnection and OutgoingBatchConnection.
This commit is contained in:
@@ -1,26 +1,51 @@
|
||||
package net.sf.briar.transport;
|
||||
|
||||
import java.io.FilterOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/** A ConnectionEncrypter that performs no encryption. */
|
||||
class NullConnectionEncrypter implements ConnectionEncrypter {
|
||||
class NullConnectionEncrypter extends FilterOutputStream
|
||||
implements ConnectionEncrypter {
|
||||
|
||||
private final OutputStream out;
|
||||
private long capacity;
|
||||
|
||||
NullConnectionEncrypter(OutputStream out) {
|
||||
this.out = out;
|
||||
this(out, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
NullConnectionEncrypter(OutputStream out, long capacity) {
|
||||
super(out);
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public OutputStream getOutputStream() {
|
||||
return out;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void writeMac(byte[] mac) throws IOException {
|
||||
out.write(mac);
|
||||
capacity -= mac.length;
|
||||
}
|
||||
|
||||
public long getCapacity(long capacity) {
|
||||
public long getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
out.write(b);
|
||||
capacity--;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
write(b, 0, b.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
out.write(b, off, len);
|
||||
capacity -= len;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user