diff --git a/Dorkbox-Network/src/dorkbox/network/connection/ConnectionManager.java b/Dorkbox-Network/src/dorkbox/network/connection/ConnectionManager.java index e18a3628..a015494e 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/ConnectionManager.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/ConnectionManager.java @@ -475,8 +475,8 @@ class ConnectionManager implements ListenerBridge, ISessio ConnectionManager 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; diff --git a/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java b/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java index 300f3f08..3c1001eb 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java @@ -169,7 +169,7 @@ class EndPoint { EndPoint(Class type, final Configuration options) throws InitializationException, SecurityException, IOException { this.type = (Class>) 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."))) { diff --git a/Dorkbox-Network/src/dorkbox/network/connection/KryoCryptoSerializationManager.java b/Dorkbox-Network/src/dorkbox/network/connection/KryoCryptoSerializationManager.java index 82dcace2..d8e413fd 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/KryoCryptoSerializationManager.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/KryoCryptoSerializationManager.java @@ -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; diff --git a/Dorkbox-Network/src/dorkbox/network/connection/RegistrationWrapper.java b/Dorkbox-Network/src/dorkbox/network/connection/RegistrationWrapper.java index c717e701..7006ab19 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/RegistrationWrapper.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/RegistrationWrapper.java @@ -233,13 +233,9 @@ class RegistrationWrapper 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 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); } } diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/RegistrationHandler.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/RegistrationHandler.java index 6feee2d0..ac7814a6 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/RegistrationHandler.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/RegistrationHandler.java @@ -36,7 +36,7 @@ class RegistrationHandler extends ChannelInboundHandlerAda public RegistrationHandler(final String name, RegistrationWrapper registrationWrapper) { - this.name = name + " Discovery/Registration"; + this.name = name; this.logger = org.slf4j.LoggerFactory.getLogger(this.name); this.registrationWrapper = registrationWrapper; } diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandler.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandler.java index 0e84cb02..79883580 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandler.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandler.java @@ -65,26 +65,6 @@ class RegistrationLocalHandler 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 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 diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandlerClient.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandlerClient.java index 9e66a6e3..dbe3cdb0 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandlerClient.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandlerClient.java @@ -48,24 +48,18 @@ class RegistrationLocalHandlerClient 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 { diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandlerServer.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandlerServer.java index 4e9649e9..344f6b07 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandlerServer.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/local/RegistrationLocalHandlerServer.java @@ -48,18 +48,14 @@ class RegistrationLocalHandlerServer 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 diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandler.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandler.java index 9a87fef8..0a90f2b8 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandler.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandler.java @@ -139,7 +139,7 @@ class RegistrationRemoteHandler extends RegistrationHandle Class 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 extends RegistrationHandle } stringBuilder.append("]"); - this.logger.debug(stringBuilder.toString()); + this.logger.info(stringBuilder.toString()); } @Override diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientTCP.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientTCP.java index 1d6b2344..61d82709 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientTCP.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientTCP.java @@ -127,10 +127,7 @@ class RegistrationRemoteHandlerClientTCP 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 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 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 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 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); diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientUDP.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientUDP.java index f007ec75..328cef5d 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientUDP.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientUDP.java @@ -73,10 +73,7 @@ class RegistrationRemoteHandlerClientUDP 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 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 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)) { diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientUDT.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientUDT.java index 9a24f2ae..bdd9f88f 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientUDT.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerClientUDT.java @@ -65,10 +65,7 @@ class RegistrationRemoteHandlerClientUDT 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 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 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)) { diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerTCP.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerTCP.java index 67feba94..348f3bf3 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerTCP.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerTCP.java @@ -105,9 +105,7 @@ class RegistrationRemoteHandlerServerTCP 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 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 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 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."); diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerUDP.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerUDP.java index 91f0b22c..f63f3fcb 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerUDP.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerUDP.java @@ -260,7 +260,8 @@ class RegistrationRemoteHandlerServerUDP 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()) { diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerUDT.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerUDT.java index 694e0663..f7cc87c8 100644 --- a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerUDT.java +++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandlerServerUDT.java @@ -57,9 +57,7 @@ class RegistrationRemoteHandlerServerUDT 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 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); diff --git a/Dorkbox-Network/src/dorkbox/network/rmi/RmiBridge.java b/Dorkbox-Network/src/dorkbox/network/rmi/RmiBridge.java index c6269d6c..6561d4d8 100644 --- a/Dorkbox-Network/src/dorkbox/network/rmi/RmiBridge.java +++ b/Dorkbox-Network/src/dorkbox/network/rmi/RmiBridge.java @@ -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;