11package io.libp2p.etc.util.netty
22
33import io.libp2p.etc.types.addAfter
4- import io.libp2p.etc.types.fromHex
54import io.netty.channel.Channel
65import io.netty.channel.ChannelHandler
76import io.netty.channel.ChannelInitializer
87import io.netty.util.internal.StringUtil
98
10- class NettyInit (val channel : Channel , val thisHandler : ChannelHandler ) {
9+ class NettyInit (val channel : Channel , thisHandler : ChannelHandler ) {
1110 private var lastLocalHandler = thisHandler
1211 fun addLastLocal (handler : ChannelHandler ) {
1312 channel.pipeline().addAfter(lastLocalHandler, generateName(channel, handler), handler)
@@ -23,13 +22,6 @@ fun nettyInitializer(initer: (NettyInit) -> Unit): ChannelInitializer<Channel> {
2322 }
2423}
2524
26- private val regex = Regex (" \\ |[0-9a-fA-F]{8}\\ | " )
27- fun String.fromLogHandler () = lines()
28- .filter { it.contains(regex) }
29- .map { it.substring(11 , 59 ).replace(" " , " " ) }
30- .flatMap { it.fromHex().asList() }
31- .toByteArray()
32-
3325private fun generateName (ch : Channel , handler : ChannelHandler ): String {
3426 val className = StringUtil .simpleClassName(handler.javaClass)
3527 val names = ch.pipeline().names().toSet()
0 commit comments