Skip to content

Commit 4b0fd88

Browse files
try a different approach + remove bossGroup
1 parent 40ff205 commit 4b0fd88

File tree

2 files changed

+22
-37
lines changed

2 files changed

+22
-37
lines changed

examples/android-chatter/build.gradle

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,18 @@ android {
2222
}
2323
}
2424
packagingOptions {
25-
exclude 'META-INF/io.netty.versions.properties'
26-
exclude 'META-INF/INDEX.LIST'
27-
exclude 'META-INF/versions/9/OSGI-INF/MANIFEST.MF'
28-
exclude 'META-INF/license/LICENSE.aix-netbsd.txt'
29-
exclude 'META-INF/native-image/io.netty/netty-codec-native-quic/jni-config.json'
30-
exclude 'META-INF/native-image/io.netty/netty-codec-native-quic/reflect-config.json'
31-
exclude 'META-INF/native-image/io.netty/netty-codec-native-quic/resource-config.json'
32-
exclude 'META-INF/license/LICENSE.boringssl.txt'
33-
exclude 'META-INF/license/LICENSE.mvn-wrapper.txt'
34-
exclude 'META-INF/license/LICENSE.quiche.txt'
35-
exclude 'META-INF/license/LICENSE.tomcat-native.txt'
36-
exclude 'META-INF/license/LICENSE.jbzip2.txt'
37-
exclude 'META-INF/license/LICENSE.webbit.txt'
38-
exclude 'META-INF/license/LICENSE.snappy.txt'
39-
exclude 'META-INF/license/LICENSE.protobuf.txt'
40-
exclude 'META-INF/license/LICENSE.nghttp2-hpack.txt'
41-
exclude 'META-INF/license/LICENSE.base64.txt'
42-
exclude 'META-INF/license/LICENSE.commons-lang.txt'
43-
exclude 'META-INF/license/LICENSE.jzlib.txt'
44-
exclude 'META-INF/license/LICENSE.jctools.txt'
45-
exclude 'META-INF/license/LICENSE.log4j.txt'
25+
resources {
26+
pickFirsts += setOf("META-INF/license/LICENSE")
27+
excludes += setOf(
28+
"META-INF/io.netty.versions.properties",
29+
"META-INF/INDEX.LIST",
30+
"META-INF/versions/9/OSGI-INF/MANIFEST.MF",
31+
"META-INF/native-image/io.netty/netty-codec-native-quic/jni-config.json",
32+
"META-INF/native-image/io.netty/netty-codec-native-quic/reflect-config.json",
33+
"META-INF/native-image/io.netty/netty-codec-native-quic/resource-config.json"
34+
)
35+
}
36+
4637
}
4738
kotlinOptions {
4839
jvmTarget = "11"

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ class QuicTransport(
6262
private var workerGroup by lazyVar {
6363
MultiThreadIoEventLoopGroup(NioIoHandler.newFactory())
6464
}
65-
private var bossGroup by lazyVar {
66-
MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory())
67-
}
6865
private var allocator by lazyVar { PooledByteBufAllocator(true) }
6966
private var multistreamProtocol: MultistreamProtocol = MultistreamProtocolV1
7067
private var incomingMultistreamProtocol: MultistreamProtocol by lazyVar { multistreamProtocol }
@@ -139,10 +136,7 @@ class QuicTransport(
139136
val allClosed = CompletableFuture.allOf(*everythingThatNeedsToClose.toTypedArray())
140137

141138
return allClosed.thenCompose {
142-
CompletableFuture.allOf(
143-
workerGroup.shutdownGracefully().toVoidCompletableFuture(),
144-
bossGroup.shutdownGracefully().toVoidCompletableFuture()
145-
).thenApply { }
139+
workerGroup.shutdownGracefully().toVoidCompletableFuture()
146140
}
147141
}
148142

@@ -286,9 +280,9 @@ class QuicTransport(
286280

287281
override fun handles(addr: Multiaddr) =
288282
handlesHost(addr) &&
289-
addr.has(UDP) &&
290-
addr.has(QUICV1) &&
291-
!addr.has(WS)
283+
addr.has(UDP) &&
284+
addr.has(QUICV1) &&
285+
!addr.has(WS)
292286

293287
fun quicSslContext(expectedRemotePeerId: PeerId?, trustManager: Libp2pTrustManager): QuicSslContext {
294288
val connectionKeys = if (certAlgorithm.equals("ECDSA")) generateEcdsaKeyPair() else generateEd25519KeyPair()
@@ -297,12 +291,12 @@ class QuicTransport(
297291
val cert = buildCert(localKey, connectionKeys.first)
298292
logger.info("Building {} keys and cert for peer id {}", certAlgorithm, PeerId.fromPubKey(localKey.publicKey()))
299293
return (
300-
if (isClient) {
301-
QuicSslContextBuilder.forClient().keyManager(javaPrivateKey, null, cert)
302-
} else {
303-
QuicSslContextBuilder.forServer(javaPrivateKey, null, cert).clientAuth(ClientAuth.REQUIRE)
304-
}
305-
)
294+
if (isClient) {
295+
QuicSslContextBuilder.forClient().keyManager(javaPrivateKey, null, cert)
296+
} else {
297+
QuicSslContextBuilder.forServer(javaPrivateKey, null, cert).clientAuth(ClientAuth.REQUIRE)
298+
}
299+
)
306300
.trustManager(trustManager)
307301
.applicationProtocols("libp2p")
308302
.build()

0 commit comments

Comments
 (0)