code cleanup
This commit is contained in:
parent
28df93c6e5
commit
d6e75ca173
@ -475,8 +475,8 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
||||
ConnectionManager<C> lm = this.localManagers.getOrCreate(connection, connection.toString());
|
||||
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isDebugEnabled()) {
|
||||
this.logger.debug("Connection specific Listener Manager added on connection: {}", connection);
|
||||
if (logger2.isTraceEnabled()) {
|
||||
this.logger.trace("Connection specific Listener Manager added on connection: {}", connection);
|
||||
}
|
||||
|
||||
return lm;
|
||||
|
@ -169,7 +169,7 @@ class EndPoint<C extends Connection> {
|
||||
EndPoint(Class<? extends EndPoint> type, final Configuration options) throws InitializationException, SecurityException, IOException {
|
||||
this.type = (Class<? extends EndPoint<C>>) type;
|
||||
|
||||
this.logger = org.slf4j.LoggerFactory.getLogger(type);
|
||||
this.logger = org.slf4j.LoggerFactory.getLogger(type.getSimpleName());
|
||||
|
||||
// make sure that 'localhost' is REALLY our specific IP address
|
||||
if (options.host != null && (options.host.equals("localhost") || options.host.startsWith("127."))) {
|
||||
|
@ -887,7 +887,7 @@ class KryoCryptoSerializationManager implements CryptoSerializationManager {
|
||||
logger2.trace("Encrypting data with - AES {}", connection);
|
||||
}
|
||||
|
||||
Crypto.AES.encrypt(kryo.aesEngine, connection.getCryptoParameters(), bufferWithData, bufferTempData, length);
|
||||
Crypto.AES.encrypt(kryo.aesEngine, connection.getCryptoParameters(), bufferWithData, bufferTempData, length, logger);
|
||||
|
||||
// swap buffers
|
||||
ByteBuf tmp = bufferWithData;
|
||||
@ -962,7 +962,7 @@ class KryoCryptoSerializationManager implements CryptoSerializationManager {
|
||||
}
|
||||
|
||||
// length-1 to adjust for the magic byte
|
||||
Crypto.AES.decrypt(kryo.aesEngine, connection.getCryptoParameters(), bufferWithData, bufferTempData, length - 1);
|
||||
Crypto.AES.decrypt(kryo.aesEngine, connection.getCryptoParameters(), bufferWithData, bufferTempData, length - 1, logger);
|
||||
|
||||
// correct which buffers are used
|
||||
bufferWithData = bufferTempData;
|
||||
|
@ -233,13 +233,9 @@ class RegistrationWrapper<C extends Connection> implements UdpServer {
|
||||
if (metaChannel != null && metaChannel.udpRemoteAddress != null) {
|
||||
this.udpRemoteMap.put(metaChannel.udpRemoteAddress, metaChannel.connection);
|
||||
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isDebugEnabled()) {
|
||||
logger2.debug("Connected to remote UDP connection. [{} <== {}]",
|
||||
metaChannel.udpChannel.localAddress()
|
||||
.toString(),
|
||||
metaChannel.udpRemoteAddress.toString());
|
||||
}
|
||||
this.logger.info("Connected to remote UDP connection. [{} <== {}]",
|
||||
metaChannel.udpChannel.localAddress(),
|
||||
metaChannel.udpRemoteAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,10 +247,7 @@ class RegistrationWrapper<C extends Connection> implements UdpServer {
|
||||
void unRegisterServerUDP(final InetSocketAddress udpRemoteAddress) {
|
||||
if (udpRemoteAddress != null) {
|
||||
this.udpRemoteMap.remove(udpRemoteAddress);
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isInfoEnabled()) {
|
||||
logger2.info("Closed remote UDP connection: {}", udpRemoteAddress.toString());
|
||||
}
|
||||
logger.info("Closed remote UDP connection: {}", udpRemoteAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class RegistrationHandler<C extends Connection> extends ChannelInboundHandlerAda
|
||||
|
||||
public
|
||||
RegistrationHandler(final String name, RegistrationWrapper<C> registrationWrapper) {
|
||||
this.name = name + " Discovery/Registration";
|
||||
this.name = name;
|
||||
this.logger = org.slf4j.LoggerFactory.getLogger(this.name);
|
||||
this.registrationWrapper = registrationWrapper;
|
||||
}
|
||||
|
@ -65,26 +65,6 @@ class RegistrationLocalHandler<C extends Connection> extends RegistrationHandler
|
||||
this.registrationWrapper.connection0(metaChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
* STEP 2: Channel is now active. Start the registration process
|
||||
*/
|
||||
@Override
|
||||
public
|
||||
void channelActive(ChannelHandlerContext context) throws Exception {
|
||||
Channel channel = context.channel();
|
||||
|
||||
//noinspection StringBufferReplaceableByString
|
||||
StringBuilder builder = new StringBuilder(76);
|
||||
builder.append("Connected to LOCAL connection. [");
|
||||
builder.append(context.channel()
|
||||
.localAddress());
|
||||
builder.append(getConnectionDirection());
|
||||
builder.append(channel.remoteAddress());
|
||||
builder.append("]");
|
||||
|
||||
this.logger.debug(builder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
void exceptionCaught(ChannelHandlerContext context, Throwable cause) throws Exception {
|
||||
@ -99,12 +79,6 @@ class RegistrationLocalHandler<C extends Connection> extends RegistrationHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the direction that traffic is going to this handler (" <== " or " ==> ")
|
||||
*/
|
||||
protected abstract
|
||||
String getConnectionDirection();
|
||||
|
||||
// this SHOULDN'T ever happen, but we might shutdown in the middle of registration
|
||||
@Override
|
||||
public final
|
||||
|
@ -48,24 +48,18 @@ class RegistrationLocalHandlerClient<C extends Connection> extends RegistrationL
|
||||
@Override
|
||||
public
|
||||
void channelActive(ChannelHandlerContext context) throws Exception {
|
||||
if (logger.isDebugEnabled()) {
|
||||
super.channelActive(context);
|
||||
}
|
||||
super.channelActive(context);
|
||||
|
||||
Channel channel = context.channel();
|
||||
this.logger.info("Connected to LOCAL connection. [{} ==> {}]",
|
||||
context.channel()
|
||||
.localAddress(),
|
||||
channel.remoteAddress());
|
||||
|
||||
// client starts the registration process
|
||||
Channel channel = context.channel();
|
||||
channel.writeAndFlush(new Registration());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the direction that traffic is going to this handler (" <== " or " ==> ")
|
||||
*/
|
||||
@Override
|
||||
protected
|
||||
String getConnectionDirection() {
|
||||
return " ==> ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
void channelRead(ChannelHandlerContext context, Object message) throws Exception {
|
||||
|
@ -48,18 +48,14 @@ class RegistrationLocalHandlerServer<C extends Connection> extends RegistrationL
|
||||
@Override
|
||||
public
|
||||
void channelActive(ChannelHandlerContext context) throws Exception {
|
||||
if (logger.isDebugEnabled()) {
|
||||
super.channelActive(context);
|
||||
}
|
||||
}
|
||||
Channel channel = context.channel();
|
||||
this.logger.info("Connected to LOCAL connection. [{} <== {}]",
|
||||
context.channel()
|
||||
.localAddress(),
|
||||
channel.remoteAddress());
|
||||
|
||||
/**
|
||||
* @return the direction that traffic is going to this handler (" <== " or " ==> ")
|
||||
*/
|
||||
@Override
|
||||
protected
|
||||
String getConnectionDirection() {
|
||||
return " <== ";
|
||||
|
||||
super.channelActive(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,7 +139,7 @@ class RegistrationRemoteHandler<C extends Connection> extends RegistrationHandle
|
||||
Class<? extends Channel> channelClass = channel.getClass();
|
||||
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder(76);
|
||||
StringBuilder stringBuilder = new StringBuilder(96);
|
||||
|
||||
stringBuilder.append("Connected to remote ");
|
||||
if (channelClass == NioSocketChannel.class || channelClass == EpollSocketChannel.class) {
|
||||
@ -175,7 +175,7 @@ class RegistrationRemoteHandler<C extends Connection> extends RegistrationHandle
|
||||
}
|
||||
stringBuilder.append("]");
|
||||
|
||||
this.logger.debug(stringBuilder.toString());
|
||||
this.logger.info(stringBuilder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,10 +127,7 @@ class RegistrationRemoteHandlerClientTCP<C extends Connection> extends Registrat
|
||||
@Override
|
||||
public
|
||||
void channelActive(final ChannelHandlerContext context) throws Exception {
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isDebugEnabled()) {
|
||||
super.channelActive(context);
|
||||
}
|
||||
super.channelActive(context);
|
||||
|
||||
Channel channel = context.channel();
|
||||
|
||||
@ -149,6 +146,7 @@ class RegistrationRemoteHandlerClientTCP<C extends Connection> extends Registrat
|
||||
this.registrationWrapper.releaseChannelMap();
|
||||
}
|
||||
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isTraceEnabled()) {
|
||||
logger2.trace("Start new TCP Connection. Sending request to server");
|
||||
}
|
||||
@ -213,7 +211,8 @@ class RegistrationRemoteHandlerClientTCP<C extends Connection> extends Registrat
|
||||
registrationWrapper2.getPrivateKey(),
|
||||
registration.publicKey,
|
||||
registration.eccParameters,
|
||||
registration.aesKey);
|
||||
registration.aesKey,
|
||||
logger);
|
||||
|
||||
if (aesKeyBytes.length != 32) {
|
||||
logger2.error("Invalid decryption of aesKey. Aborting.");
|
||||
@ -224,7 +223,7 @@ class RegistrationRemoteHandlerClientTCP<C extends Connection> extends Registrat
|
||||
}
|
||||
|
||||
// now decrypt payload using AES
|
||||
byte[] payload = Crypto.AES.decrypt(getAesEngine(), aesKeyBytes, registration.aesIV, registration.payload);
|
||||
byte[] payload = Crypto.AES.decrypt(getAesEngine(), aesKeyBytes, registration.aesIV, registration.payload, logger);
|
||||
|
||||
if (payload.length == 0) {
|
||||
logger2.error("Invalid decryption of payload. Aborting.");
|
||||
@ -308,7 +307,7 @@ class RegistrationRemoteHandlerClientTCP<C extends Connection> extends Registrat
|
||||
Output output = new Output(1024);
|
||||
EccPublicKeySerializer.write(output, (ECPublicKeyParameters) metaChannel.ecdhKey.getPublic());
|
||||
byte[] pubKeyAsBytes = output.toBytes();
|
||||
register.payload = Crypto.AES.encrypt(getAesEngine(), aesKeyBytes, registration.aesIV, pubKeyAsBytes);
|
||||
register.payload = Crypto.AES.encrypt(getAesEngine(), aesKeyBytes, registration.aesIV, pubKeyAsBytes, logger);
|
||||
|
||||
channel.writeAndFlush(register);
|
||||
|
||||
|
@ -73,10 +73,7 @@ class RegistrationRemoteHandlerClientUDP<C extends Connection> extends Registrat
|
||||
@Override
|
||||
public
|
||||
void channelActive(final ChannelHandlerContext context) throws Exception {
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isDebugEnabled()) {
|
||||
super.channelActive(context);
|
||||
}
|
||||
super.channelActive(context);
|
||||
|
||||
Channel channel = context.channel();
|
||||
|
||||
@ -116,6 +113,7 @@ class RegistrationRemoteHandlerClientUDP<C extends Connection> extends Registrat
|
||||
throw new IOException("UDP cannot connect to a remote server before TCP is established!");
|
||||
}
|
||||
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isTraceEnabled()) {
|
||||
logger2.trace("Start new UDP Connection. Sending request to server");
|
||||
}
|
||||
@ -151,7 +149,7 @@ class RegistrationRemoteHandlerClientUDP<C extends Connection> extends Registrat
|
||||
Registration registration = (Registration) message;
|
||||
|
||||
// now decrypt channelID using AES
|
||||
byte[] payload = Crypto.AES.decrypt(getAesEngine(), metaChannel.aesKey, metaChannel.aesIV, registration.payload);
|
||||
byte[] payload = Crypto.AES.decrypt(getAesEngine(), metaChannel.aesKey, metaChannel.aesIV, registration.payload, logger);
|
||||
|
||||
OptimizeUtilsByteArray optimizeUtils = OptimizeUtilsByteArray.get();
|
||||
if (!optimizeUtils.canReadInt(payload)) {
|
||||
|
@ -65,10 +65,7 @@ class RegistrationRemoteHandlerClientUDT<C extends Connection> extends Registrat
|
||||
@Override
|
||||
public
|
||||
void channelActive(final ChannelHandlerContext context) throws Exception {
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isDebugEnabled()) {
|
||||
super.channelActive(context);
|
||||
}
|
||||
super.channelActive(context);
|
||||
|
||||
Channel channel = context.channel();
|
||||
// look to see if we already have a connection (in progress) for the destined IP address.
|
||||
@ -107,6 +104,7 @@ class RegistrationRemoteHandlerClientUDT<C extends Connection> extends Registrat
|
||||
throw new IOException("UDT cannot connect to a remote server before TCP is established!");
|
||||
}
|
||||
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isTraceEnabled()) {
|
||||
logger2.trace("Start new UDT Connection. Sending request to server");
|
||||
}
|
||||
@ -144,7 +142,7 @@ class RegistrationRemoteHandlerClientUDT<C extends Connection> extends Registrat
|
||||
Registration registration = (Registration) message;
|
||||
|
||||
// now decrypt channelID using AES
|
||||
byte[] payload = Crypto.AES.decrypt(getAesEngine(), metaChannel.aesKey, metaChannel.aesIV, registration.payload);
|
||||
byte[] payload = Crypto.AES.decrypt(getAesEngine(), metaChannel.aesKey, metaChannel.aesIV, registration.payload, logger);
|
||||
|
||||
OptimizeUtilsByteArray optimizeUtils = OptimizeUtilsByteArray.get();
|
||||
if (!optimizeUtils.canReadInt(payload)) {
|
||||
|
@ -105,9 +105,7 @@ class RegistrationRemoteHandlerServerTCP<C extends Connection> extends Registrat
|
||||
@Override
|
||||
public
|
||||
void channelActive(ChannelHandlerContext context) throws Exception {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
super.channelActive(context);
|
||||
}
|
||||
super.channelActive(context);
|
||||
|
||||
Channel channel = context.channel();
|
||||
|
||||
@ -124,8 +122,9 @@ class RegistrationRemoteHandlerServerTCP<C extends Connection> extends Registrat
|
||||
this.registrationWrapper.releaseChannelMap();
|
||||
}
|
||||
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace(this.name, "New TCP connection. Saving TCP channel info.");
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isTraceEnabled()) {
|
||||
logger2.trace(this.name, "New TCP connection. Saving TCP channel info.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,11 +248,12 @@ class RegistrationRemoteHandlerServerTCP<C extends Connection> extends Registrat
|
||||
registrationWrapper2.getPrivateKey(),
|
||||
metaChannel.publicKey,
|
||||
register.eccParameters,
|
||||
metaChannel.aesKey);
|
||||
metaChannel.aesKey,
|
||||
logger);
|
||||
|
||||
|
||||
// now encrypt payload via AES
|
||||
register.payload = Crypto.AES.encrypt(getAesEngine(), metaChannel.aesKey, register.aesIV, combinedBytes);
|
||||
register.payload = Crypto.AES.encrypt(getAesEngine(), metaChannel.aesKey, register.aesIV, combinedBytes, logger);
|
||||
|
||||
channel.writeAndFlush(register);
|
||||
|
||||
@ -279,7 +279,8 @@ class RegistrationRemoteHandlerServerTCP<C extends Connection> extends Registrat
|
||||
byte[] payload = Crypto.AES.decrypt(getAesEngine(),
|
||||
metaChannel.aesKey,
|
||||
metaChannel.aesIV,
|
||||
registration.payload);
|
||||
registration.payload,
|
||||
logger);
|
||||
|
||||
if (payload.length == 0) {
|
||||
logger2.error("Invalid decryption of payload. Aborting.");
|
||||
|
@ -260,7 +260,8 @@ class RegistrationRemoteHandlerServerUDP<C extends Connection> extends MessageTo
|
||||
register.payload = Crypto.AES.encrypt(RegistrationRemoteHandler.getAesEngine(),
|
||||
metaChannel.aesKey,
|
||||
metaChannel.aesIV,
|
||||
idAsBytes);
|
||||
idAsBytes,
|
||||
logger);
|
||||
|
||||
channel.writeAndFlush(new UdpWrapper(register, udpRemoteAddress));
|
||||
if (logger2.isTraceEnabled()) {
|
||||
|
@ -57,9 +57,7 @@ class RegistrationRemoteHandlerServerUDT<C extends Connection> extends Registrat
|
||||
@Override
|
||||
public
|
||||
void channelActive(final ChannelHandlerContext context) throws Exception {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
super.channelActive(context);
|
||||
}
|
||||
super.channelActive(context);
|
||||
|
||||
// UDT channels are added when the registration request arrives on a UDT channel.
|
||||
}
|
||||
@ -132,7 +130,8 @@ class RegistrationRemoteHandlerServerUDT<C extends Connection> extends Registrat
|
||||
register.payload = Crypto.AES.encrypt(RegistrationRemoteHandler.getAesEngine(),
|
||||
metaChannel.aesKey,
|
||||
metaChannel.aesIV,
|
||||
idAsBytes);
|
||||
idAsBytes,
|
||||
logger);
|
||||
|
||||
// send back, so the client knows that UDP was ok. We include the encrypted connection ID, so the client knows it's a legit server
|
||||
channel.writeAndFlush(register);
|
||||
|
@ -232,7 +232,7 @@ class RmiBridge {
|
||||
CachedMethod cachedMethod = invokeMethod.cachedMethod;
|
||||
|
||||
Logger logger2 = this.logger;
|
||||
if (logger2.isDebugEnabled()) {
|
||||
if (logger2.isTraceEnabled()) {
|
||||
String argString = "";
|
||||
if (invokeMethod.args != null) {
|
||||
argString = Arrays.deepToString(invokeMethod.args);
|
||||
@ -254,9 +254,9 @@ class RmiBridge {
|
||||
.append(")");
|
||||
|
||||
if (cachedMethod.origMethod != null) {
|
||||
stringBuilder.append(" [Connection param override]");
|
||||
stringBuilder.append(" [Connection method override]");
|
||||
}
|
||||
logger2.debug(stringBuilder.toString());
|
||||
logger2.trace(stringBuilder.toString());
|
||||
}
|
||||
|
||||
byte responseData = invokeMethod.responseData;
|
||||
|
Loading…
Reference in New Issue
Block a user