Cleaned up logging, code polish
This commit is contained in:
parent
e7a7ec9737
commit
006e597867
|
@ -15,16 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package dorkbox.network.handshake
|
package dorkbox.network.handshake
|
||||||
|
|
||||||
import org.slf4j.Logger
|
|
||||||
|
|
||||||
internal class ClientConnectionInfo(val subscriptionPort: Int,
|
internal class ClientConnectionInfo(val subscriptionPort: Int,
|
||||||
val publicationPort: Int,
|
val publicationPort: Int,
|
||||||
val sessionId: Int,
|
val sessionId: Int,
|
||||||
val streamId: Int,
|
val streamId: Int,
|
||||||
val publicKey: ByteArray,
|
val publicKey: ByteArray,
|
||||||
val kryoIdsForRmi: IntArray) {
|
val kryoIdsForRmi: IntArray) {
|
||||||
|
|
||||||
fun log(handshakeSessionId: Int, logger: Logger) {
|
|
||||||
logger.debug("[{}] connected {}|{} (encrypted {})", handshakeSessionId, publicationPort, subscriptionPort, sessionId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,6 @@ internal class ClientHandshake<CONNECTION: Connection>(private val logger: KLogg
|
||||||
// The message was intended for this client. Try to parse it as one of the available message types.
|
// The message was intended for this client. Try to parse it as one of the available message types.
|
||||||
// this message is ENCRYPTED!
|
// this message is ENCRYPTED!
|
||||||
connectionHelloInfo = crypto.decrypt(message.registrationData, message.publicKey)
|
connectionHelloInfo = crypto.decrypt(message.registrationData, message.publicKey)
|
||||||
connectionHelloInfo!!.log(sessionId, logger)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
HandshakeMessage.DONE_ACK -> {
|
HandshakeMessage.DONE_ACK -> {
|
||||||
|
|
|
@ -79,7 +79,10 @@ internal class ServerHandshake<CONNECTION : Connection>(private val logger: KLog
|
||||||
pendingConnectionsLock.write {
|
pendingConnectionsLock.write {
|
||||||
val pendingConnection = pendingConnections.remove(sessionId)
|
val pendingConnection = pendingConnections.remove(sessionId)
|
||||||
if (pendingConnection != null) {
|
if (pendingConnection != null) {
|
||||||
logger.debug("Connection from client $clientAddressString ready")
|
logger.trace { "Connection from client $clientAddressString done with handshake." }
|
||||||
|
|
||||||
|
// this enables the connection to start polling for messages
|
||||||
|
server.connections.add(pendingConnection)
|
||||||
|
|
||||||
// now tell the client we are done
|
// now tell the client we are done
|
||||||
server.writeHandshakeMessage(handshakePublication, HandshakeMessage.doneToClient(sessionId))
|
server.writeHandshakeMessage(handshakePublication, HandshakeMessage.doneToClient(sessionId))
|
||||||
|
@ -88,9 +91,6 @@ internal class ServerHandshake<CONNECTION : Connection>(private val logger: KLog
|
||||||
listenerManager.notifyConnect(pendingConnection)
|
listenerManager.notifyConnect(pendingConnection)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this enables the connection to start polling for messages
|
|
||||||
server.connections.add(pendingConnection)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,11 +199,11 @@ internal class ServerHandshake<CONNECTION : Connection>(private val logger: KLog
|
||||||
// we have to construct how the connection will communicate!
|
// we have to construct how the connection will communicate!
|
||||||
clientConnection.buildServer(aeron)
|
clientConnection.buildServer(aeron)
|
||||||
|
|
||||||
logger.trace {
|
logger.info {
|
||||||
"Creating new connection $clientConnection"
|
"Creating new connection from $clientConnection"
|
||||||
}
|
}
|
||||||
|
|
||||||
val connection = server.newConnection(ConnectionParams(server, clientConnection, validateRemoteAddress)) as CONNECTION
|
val connection = server.newConnection(ConnectionParams(server, clientConnection, validateRemoteAddress))
|
||||||
|
|
||||||
// VALIDATE:: are we allowed to connect to this server (now that we have the initial server information)
|
// VALIDATE:: are we allowed to connect to this server (now that we have the initial server information)
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@ -214,8 +214,6 @@ internal class ServerHandshake<CONNECTION : Connection>(private val logger: KLog
|
||||||
sessionIdAllocator.free(connectionSessionId)
|
sessionIdAllocator.free(connectionSessionId)
|
||||||
streamIdAllocator.free(connectionStreamId)
|
streamIdAllocator.free(connectionStreamId)
|
||||||
|
|
||||||
logger.error("Error creating new connection")
|
|
||||||
|
|
||||||
val exception = ClientRejectedException("Connection was not permitted!")
|
val exception = ClientRejectedException("Connection was not permitted!")
|
||||||
ListenerManager.cleanStackTrace(exception)
|
ListenerManager.cleanStackTrace(exception)
|
||||||
listenerManager.notifyError(connection, exception)
|
listenerManager.notifyError(connection, exception)
|
||||||
|
@ -231,8 +229,10 @@ internal class ServerHandshake<CONNECTION : Connection>(private val logger: KLog
|
||||||
///////////////
|
///////////////
|
||||||
|
|
||||||
// if necessary (and only for RMI id's that have never been seen before) we want to re-write our kryo information
|
// if necessary (and only for RMI id's that have never been seen before) we want to re-write our kryo information
|
||||||
val rmiModificationIds = message.registrationRmiIdData!!
|
serialization.updateKryoIdsForRmi(connection, message.registrationRmiIdData!!) { errorMessage ->
|
||||||
server.updateKryoIdsForRmi(connection, rmiModificationIds)
|
listenerManager.notifyError(connection,
|
||||||
|
ClientRejectedException(errorMessage))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user