@@ -19,7 +19,6 @@ import io.libp2p.etc.STREAM
19
19
import io.libp2p.etc.types.*
20
20
import io.libp2p.etc.util.MultiaddrUtils
21
21
import io.libp2p.etc.util.netty.nettyInitializer
22
- import io.libp2p.security.secio.SecIoCodec
23
22
import io.libp2p.security.tls.*
24
23
import io.libp2p.transport.implementation.ConnectionOverNetty
25
24
import io.libp2p.transport.implementation.NettyTransport
@@ -317,46 +316,49 @@ class QuicTransport(
317
316
ch.attr(CONNECTION ).set(connection)
318
317
319
318
// 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
+ )
336
338
)
337
- )
338
339
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 )
341
342
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
+ }
350
351
351
- super .channelActive(ctx)
352
- }
352
+ super .channelActive(ctx)
353
+ }
353
354
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
+ }
358
360
}
359
- } )
361
+ )
360
362
}
361
363
})
362
364
.initialMaxData(1024 )
@@ -368,7 +370,7 @@ class QuicTransport(
368
370
}
369
371
370
372
class QuicMuxerSession (
371
- val ch : QuicChannel ,
373
+ val ch : QuicChannel ,
372
374
val connection : ConnectionOverNetty
373
375
) : StreamMuxer.Session {
374
376
override fun <T > createStream (protocols : List <ProtocolBinding <T >>): StreamPromise <T > {
0 commit comments