clean up context usage
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
package net.i2p.router.tunnel;
|
package net.i2p.router.tunnel;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
|
||||||
import net.i2p.data.ByteArray;
|
import net.i2p.data.ByteArray;
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
@ -16,7 +15,7 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class InboundEndpointProcessor {
|
public class InboundEndpointProcessor {
|
||||||
private I2PAppContext _context;
|
private RouterContext _context;
|
||||||
private Log _log;
|
private Log _log;
|
||||||
private TunnelCreatorConfig _config;
|
private TunnelCreatorConfig _config;
|
||||||
private IVValidator _validator;
|
private IVValidator _validator;
|
||||||
@ -24,10 +23,10 @@ public class InboundEndpointProcessor {
|
|||||||
static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
static final boolean USE_ENCRYPTION = HopProcessor.USE_ENCRYPTION;
|
||||||
private static final ByteCache _cache = ByteCache.getInstance(128, HopProcessor.IV_LENGTH);
|
private static final ByteCache _cache = ByteCache.getInstance(128, HopProcessor.IV_LENGTH);
|
||||||
|
|
||||||
public InboundEndpointProcessor(I2PAppContext ctx, TunnelCreatorConfig cfg) {
|
public InboundEndpointProcessor(RouterContext ctx, TunnelCreatorConfig cfg) {
|
||||||
this(ctx, cfg, DummyValidator.getInstance());
|
this(ctx, cfg, DummyValidator.getInstance());
|
||||||
}
|
}
|
||||||
public InboundEndpointProcessor(I2PAppContext ctx, TunnelCreatorConfig cfg, IVValidator validator) {
|
public InboundEndpointProcessor(RouterContext ctx, TunnelCreatorConfig cfg, IVValidator validator) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
_log = ctx.logManager().getLog(InboundEndpointProcessor.class);
|
_log = ctx.logManager().getLog(InboundEndpointProcessor.class);
|
||||||
_config = cfg;
|
_config = cfg;
|
||||||
@ -73,23 +72,19 @@ public class InboundEndpointProcessor {
|
|||||||
|
|
||||||
_cache.release(ba);
|
_cache.release(ba);
|
||||||
|
|
||||||
// now for a little bookkeeping
|
if (_config.getLength() > 0) {
|
||||||
RouterContext ctx = null;
|
|
||||||
if (_context instanceof RouterContext)
|
|
||||||
ctx = (RouterContext)_context;
|
|
||||||
if ( (ctx != null) && (_config.getLength() > 0) ) {
|
|
||||||
int rtt = 0; // dunno... may not be related to an rtt
|
int rtt = 0; // dunno... may not be related to an rtt
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Received a " + length + "byte message through tunnel " + _config);
|
_log.debug("Received a " + length + "byte message through tunnel " + _config);
|
||||||
for (int i = 0; i < _config.getLength(); i++)
|
for (int i = 0; i < _config.getLength(); i++)
|
||||||
ctx.profileManager().tunnelDataPushed(_config.getPeer(i), rtt, length);
|
_context.profileManager().tunnelDataPushed(_config.getPeer(i), rtt, length);
|
||||||
_config.incrementVerifiedBytesTransferred(length);
|
_config.incrementVerifiedBytesTransferred(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decrypt(I2PAppContext ctx, TunnelCreatorConfig cfg, byte iv[], byte orig[], int offset, int length) {
|
private void decrypt(RouterContext ctx, TunnelCreatorConfig cfg, byte iv[], byte orig[], int offset, int length) {
|
||||||
Log log = ctx.logManager().getLog(OutboundGatewayProcessor.class);
|
Log log = ctx.logManager().getLog(OutboundGatewayProcessor.class);
|
||||||
ByteArray ba = _cache.acquire();
|
ByteArray ba = _cache.acquire();
|
||||||
byte cur[] = ba.getData(); // new byte[HopProcessor.IV_LENGTH]; // so we dont malloc
|
byte cur[] = ba.getData(); // new byte[HopProcessor.IV_LENGTH]; // so we dont malloc
|
||||||
|
Reference in New Issue
Block a user