Skip to content

Commit 84495a7

Browse files
committed
spotless
1 parent 49618c8 commit 84495a7

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

libp2p/src/main/kotlin/io/libp2p/transport/quic/QuicTransport.kt

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import io.libp2p.etc.STREAM
1919
import io.libp2p.etc.types.*
2020
import io.libp2p.etc.util.MultiaddrUtils
2121
import io.libp2p.etc.util.netty.nettyInitializer
22-
import io.libp2p.security.secio.SecIoCodec
2322
import io.libp2p.security.tls.*
2423
import io.libp2p.transport.implementation.ConnectionOverNetty
2524
import io.libp2p.transport.implementation.NettyTransport
@@ -317,46 +316,49 @@ class QuicTransport(
317316
ch.attr(CONNECTION).set(connection)
318317

319318
// Add a handler to wait for channel activation (handshake completion)
320-
ch.pipeline().addFirst("quic-handshake-waiter", object : ChannelInboundHandlerAdapter() {
321-
override fun channelActive(ctx: ChannelHandlerContext) {
322-
// Now the handshake is complete and remoteCert should be available
323-
val remoteCert = trustManager.remoteCert
324-
if (remoteCert != null) {
325-
val remotePeerId = verifyAndExtractPeerId(arrayOf(remoteCert))
326-
val remotePublicKey = getPublicKeyFromCert(arrayOf(remoteCert))
327-
328-
log.info("Handshake completed with remote peer id: {}", remotePeerId)
329-
330-
connection.setSecureSession(
331-
SecureChannel.Session(
332-
PeerId.fromPubKey(localKey.publicKey()),
333-
remotePeerId,
334-
remotePublicKey,
335-
null
319+
ch.pipeline().addFirst(
320+
"quic-handshake-waiter",
321+
object : ChannelInboundHandlerAdapter() {
322+
override fun channelActive(ctx: ChannelHandlerContext) {
323+
// Now the handshake is complete and remoteCert should be available
324+
val remoteCert = trustManager.remoteCert
325+
if (remoteCert != null) {
326+
val remotePeerId = verifyAndExtractPeerId(arrayOf(remoteCert))
327+
val remotePublicKey = getPublicKeyFromCert(arrayOf(remoteCert))
328+
329+
log.info("Handshake completed with remote peer id: {}", remotePeerId)
330+
331+
connection.setSecureSession(
332+
SecureChannel.Session(
333+
PeerId.fromPubKey(localKey.publicKey()),
334+
remotePeerId,
335+
remotePublicKey,
336+
null
337+
)
336338
)
337-
)
338339

339-
// Remove this handler as it's no longer needed
340-
ctx.pipeline().remove(this)
340+
// Remove this handler as it's no longer needed
341+
ctx.pipeline().remove(this)
341342

342-
// Now it's safe to call the connection handler
343-
preHandler?.also { it.visit(connection) }
344-
connHandler.handleConnection(connection)
345-
} else {
346-
// This should not happen if channelActive is called after handshake
347-
ctx.close()
348-
throw IllegalStateException("Remote certificate still not available after handshake")
349-
}
343+
// Now it's safe to call the connection handler
344+
preHandler?.also { it.visit(connection) }
345+
connHandler.handleConnection(connection)
346+
} else {
347+
// This should not happen if channelActive is called after handshake
348+
ctx.close()
349+
throw IllegalStateException("Remote certificate still not available after handshake")
350+
}
350351

351-
super.channelActive(ctx)
352-
}
352+
super.channelActive(ctx)
353+
}
353354

354-
@Deprecated("Deprecated in Java")
355-
override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {
356-
log.error("An error during handshake", cause)
357-
ctx.close()
355+
@Deprecated("Deprecated in Java")
356+
override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {
357+
log.error("An error during handshake", cause)
358+
ctx.close()
359+
}
358360
}
359-
})
361+
)
360362
}
361363
})
362364
.initialMaxData(1024)
@@ -368,7 +370,7 @@ class QuicTransport(
368370
}
369371

370372
class QuicMuxerSession(
371-
val ch : QuicChannel,
373+
val ch: QuicChannel,
372374
val connection: ConnectionOverNetty
373375
) : StreamMuxer.Session {
374376
override fun <T> createStream(protocols: List<ProtocolBinding<T>>): StreamPromise<T> {

0 commit comments

Comments
 (0)