buffer between the bandwidth limiter and the raw stream
This commit is contained in:
@ -10,6 +10,8 @@ package net.i2p.router.transport.tcp;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.net.Socket;
|
||||
@ -44,6 +46,9 @@ class RestrictiveTCPConnection extends TCPConnection {
|
||||
/** passed in the handshake process for the connection, and only equivilant protocols will be accepted */
|
||||
private final static long PROTO_ID = 12;
|
||||
|
||||
/** read / write buffer size */
|
||||
private final static int BUF_SIZE = 4*1024;
|
||||
|
||||
private boolean validateVersion() throws DataFormatException, IOException {
|
||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Before validating version");
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(8);
|
||||
@ -284,8 +289,8 @@ class RestrictiveTCPConnection extends TCPConnection {
|
||||
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("TCP connection " + _id + " established with " + _remoteIdentity.getHash().toBase64());
|
||||
_in = new AESInputStream(_context, new BandwidthLimitedInputStream(_context, _in, _remoteIdentity), _key, _iv);
|
||||
_out = new AESOutputStream(_context, new BandwidthLimitedOutputStream(_context, _out, _remoteIdentity), _key, _iv);
|
||||
_in = new AESInputStream(_context, new BandwidthLimitedInputStream(_context, new BufferedInputStream(_in, BUF_SIZE), _remoteIdentity), _key, _iv);
|
||||
_out = new AESOutputStream(_context, new BufferedOutputStream(new BandwidthLimitedOutputStream(_context, _out, _remoteIdentity), BUF_SIZE), _key, _iv);
|
||||
_socket.setSoTimeout(0);
|
||||
success = _context.clock().now();
|
||||
established();
|
||||
|
Reference in New Issue
Block a user