mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Use the same maximum frame length for all transports.
This commit is contained in:
@@ -95,7 +95,7 @@ class ConnectionManagerImpl implements ConnectionManager {
|
||||
private MessagingSession createIncomingSession(StreamContext ctx,
|
||||
TransportConnectionReader r) throws IOException {
|
||||
InputStream streamReader = streamReaderFactory.createStreamReader(
|
||||
r.getInputStream(), r.getMaxFrameLength(), ctx);
|
||||
r.getInputStream(), ctx);
|
||||
return messagingSessionFactory.createIncomingSession(
|
||||
ctx.getContactId(), ctx.getTransportId(), streamReader);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class ConnectionManagerImpl implements ConnectionManager {
|
||||
private MessagingSession createSimplexOutgoingSession(StreamContext ctx,
|
||||
TransportConnectionWriter w) throws IOException {
|
||||
OutputStream streamWriter = streamWriterFactory.createStreamWriter(
|
||||
w.getOutputStream(), w.getMaxFrameLength(), ctx);
|
||||
w.getOutputStream(), ctx);
|
||||
return messagingSessionFactory.createSimplexOutgoingSession(
|
||||
ctx.getContactId(), ctx.getTransportId(), w.getMaxLatency(),
|
||||
streamWriter);
|
||||
@@ -112,7 +112,7 @@ class ConnectionManagerImpl implements ConnectionManager {
|
||||
private MessagingSession createDuplexOutgoingSession(StreamContext ctx,
|
||||
TransportConnectionWriter w) throws IOException {
|
||||
OutputStream streamWriter = streamWriterFactory.createStreamWriter(
|
||||
w.getOutputStream(), w.getMaxFrameLength(), ctx);
|
||||
w.getOutputStream(), ctx);
|
||||
return messagingSessionFactory.createDuplexOutgoingSession(
|
||||
ctx.getContactId(), ctx.getTransportId(), w.getMaxLatency(),
|
||||
w.getMaxIdleTime(), streamWriter);
|
||||
|
||||
@@ -28,7 +28,7 @@ public abstract class FilePlugin implements SimplexPlugin {
|
||||
protected final Executor ioExecutor;
|
||||
protected final FileUtils fileUtils;
|
||||
protected final SimplexPluginCallback callback;
|
||||
protected final int maxFrameLength, maxLatency;
|
||||
protected final int maxLatency;
|
||||
|
||||
protected volatile boolean running = false;
|
||||
|
||||
@@ -38,19 +38,13 @@ public abstract class FilePlugin implements SimplexPlugin {
|
||||
protected abstract void readerFinished(File f);
|
||||
|
||||
protected FilePlugin(Executor ioExecutor, FileUtils fileUtils,
|
||||
SimplexPluginCallback callback, int maxFrameLength,
|
||||
int maxLatency) {
|
||||
SimplexPluginCallback callback, int maxLatency) {
|
||||
this.ioExecutor = ioExecutor;
|
||||
this.fileUtils = fileUtils;
|
||||
this.callback = callback;
|
||||
this.maxFrameLength = maxFrameLength;
|
||||
this.maxLatency = maxLatency;
|
||||
}
|
||||
|
||||
public int getMaxFrameLength() {
|
||||
return maxFrameLength;
|
||||
}
|
||||
|
||||
public int getMaxLatency() {
|
||||
return maxLatency;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,6 @@ class FileTransportReader implements TransportConnectionReader {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public int getMaxFrameLength() {
|
||||
return plugin.getMaxFrameLength();
|
||||
}
|
||||
|
||||
public long getMaxLatency() {
|
||||
return plugin.getMaxLatency();
|
||||
}
|
||||
|
||||
@@ -27,10 +27,6 @@ class FileTransportWriter implements TransportConnectionWriter {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public int getMaxFrameLength() {
|
||||
return plugin.getMaxFrameLength();
|
||||
}
|
||||
|
||||
public int getMaxLatency() {
|
||||
return plugin.getMaxLatency();
|
||||
}
|
||||
|
||||
@@ -17,10 +17,8 @@ class LanTcpPlugin extends TcpPlugin {
|
||||
static final TransportId ID = new TransportId("lan");
|
||||
|
||||
LanTcpPlugin(Executor ioExecutor, DuplexPluginCallback callback,
|
||||
int maxFrameLength, int maxLatency, int maxIdleTime,
|
||||
int pollingInterval) {
|
||||
super(ioExecutor, callback, maxFrameLength, maxLatency, maxIdleTime,
|
||||
pollingInterval);
|
||||
int maxLatency, int maxIdleTime, int pollingInterval) {
|
||||
super(ioExecutor, callback, maxLatency, maxIdleTime, pollingInterval);
|
||||
}
|
||||
|
||||
public TransportId getId() {
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
|
||||
|
||||
public class LanTcpPluginFactory implements DuplexPluginFactory {
|
||||
|
||||
private static final int MAX_FRAME_LENGTH = 1024;
|
||||
private static final int MAX_LATENCY = 30 * 1000; // 30 seconds
|
||||
private static final int MAX_IDLE_TIME = 30 * 1000; // 30 seconds
|
||||
private static final int POLLING_INTERVAL = 3 * 60 * 1000; // 3 minutes
|
||||
@@ -25,7 +24,7 @@ public class LanTcpPluginFactory implements DuplexPluginFactory {
|
||||
}
|
||||
|
||||
public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
|
||||
return new LanTcpPlugin(ioExecutor, callback, MAX_FRAME_LENGTH,
|
||||
MAX_LATENCY, MAX_IDLE_TIME, POLLING_INTERVAL);
|
||||
return new LanTcpPlugin(ioExecutor, callback, MAX_LATENCY,
|
||||
MAX_IDLE_TIME, POLLING_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,7 @@ abstract class TcpPlugin implements DuplexPlugin {
|
||||
|
||||
protected final Executor ioExecutor;
|
||||
protected final DuplexPluginCallback callback;
|
||||
protected final int maxFrameLength, maxLatency, maxIdleTime;
|
||||
protected final int pollingInterval, socketTimeout;
|
||||
protected final int maxLatency, maxIdleTime, pollingInterval, socketTimeout;
|
||||
|
||||
protected volatile boolean running = false;
|
||||
protected volatile ServerSocket socket = null;
|
||||
@@ -53,11 +52,9 @@ abstract class TcpPlugin implements DuplexPlugin {
|
||||
protected abstract boolean isConnectable(InetSocketAddress remote);
|
||||
|
||||
protected TcpPlugin(Executor ioExecutor, DuplexPluginCallback callback,
|
||||
int maxFrameLength, int maxLatency, int maxIdleTime,
|
||||
int pollingInterval) {
|
||||
int maxLatency, int maxIdleTime, int pollingInterval) {
|
||||
this.ioExecutor = ioExecutor;
|
||||
this.callback = callback;
|
||||
this.maxFrameLength = maxFrameLength;
|
||||
this.maxLatency = maxLatency;
|
||||
this.maxIdleTime = maxIdleTime;
|
||||
this.pollingInterval = pollingInterval;
|
||||
@@ -66,10 +63,6 @@ abstract class TcpPlugin implements DuplexPlugin {
|
||||
else socketTimeout = maxIdleTime * 2;
|
||||
}
|
||||
|
||||
public int getMaxFrameLength() {
|
||||
return maxFrameLength;
|
||||
}
|
||||
|
||||
public int getMaxLatency() {
|
||||
return maxLatency;
|
||||
}
|
||||
|
||||
@@ -38,10 +38,6 @@ class TcpTransportConnection implements DuplexTransportConnection {
|
||||
|
||||
private class Reader implements TransportConnectionReader {
|
||||
|
||||
public int getMaxFrameLength() {
|
||||
return plugin.getMaxFrameLength();
|
||||
}
|
||||
|
||||
public long getMaxLatency() {
|
||||
return plugin.getMaxLatency();
|
||||
}
|
||||
@@ -59,10 +55,6 @@ class TcpTransportConnection implements DuplexTransportConnection {
|
||||
|
||||
private class Writer implements TransportConnectionWriter {
|
||||
|
||||
public int getMaxFrameLength() {
|
||||
return plugin.getMaxFrameLength();
|
||||
}
|
||||
|
||||
public int getMaxLatency() {
|
||||
return plugin.getMaxLatency();
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@ class WanTcpPlugin extends TcpPlugin {
|
||||
private volatile MappingResult mappingResult;
|
||||
|
||||
WanTcpPlugin(Executor ioExecutor, PortMapper portMapper,
|
||||
DuplexPluginCallback callback, int maxFrameLength, int maxLatency,
|
||||
int maxIdleTime, int pollingInterval) {
|
||||
super(ioExecutor, callback, maxFrameLength, maxLatency, maxIdleTime,
|
||||
pollingInterval);
|
||||
DuplexPluginCallback callback, int maxLatency, int maxIdleTime,
|
||||
int pollingInterval) {
|
||||
super(ioExecutor, callback, maxLatency, maxIdleTime, pollingInterval);
|
||||
this.portMapper = portMapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
|
||||
|
||||
public class WanTcpPluginFactory implements DuplexPluginFactory {
|
||||
|
||||
private static final int MAX_FRAME_LENGTH = 1024;
|
||||
private static final int MAX_LATENCY = 30 * 1000; // 30 seconds
|
||||
private static final int MAX_IDLE_TIME = 30 * 1000; // 30 seconds
|
||||
private static final int POLLING_INTERVAL = 5 * 60 * 1000; // 5 minutes
|
||||
@@ -30,7 +29,6 @@ public class WanTcpPluginFactory implements DuplexPluginFactory {
|
||||
|
||||
public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
|
||||
return new WanTcpPlugin(ioExecutor, new PortMapperImpl(shutdownManager),
|
||||
callback, MAX_FRAME_LENGTH, MAX_LATENCY, MAX_IDLE_TIME,
|
||||
POLLING_INTERVAL);
|
||||
callback, MAX_LATENCY, MAX_IDLE_TIME, POLLING_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user