fix #176 exceptions on tail of pipeline

This commit is contained in:
creeper123123321 2021-07-24 09:05:55 -03:00
parent 24fb56d0dc
commit 9a3ea9d690
3 changed files with 8 additions and 3 deletions

View File

@ -255,4 +255,8 @@ fun reverseLookup(address: InetAddress): String {
.asReversed()
.joinToString(".") + ".ip6.arpa"
}
}
fun Channel.fireExceptionCaughtIfOpen(e: Exception) {
if (isOpen()) pipeline().fireExceptionCaught(e)
}

View File

@ -7,6 +7,7 @@ import com.google.common.util.concurrent.RateLimiter
import com.viaversion.aas.codec.packet.Packet
import com.viaversion.aas.codec.packet.handshake.Handshake
import com.viaversion.aas.config.VIAaaSConfig
import com.viaversion.aas.fireExceptionCaughtIfOpen
import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.mcLogger
import com.viaversion.aas.setAutoRead
@ -113,7 +114,7 @@ class HandshakeState : ConnectionState {
try {
connectBack(handler, packet.address, packet.port, packet.nextState)
} catch (e: Exception) {
ctx.fireExceptionCaught(e)
ctx.channel().fireExceptionCaughtIfOpen(e)
}
}
}

View File

@ -167,7 +167,7 @@ class LoginState : ConnectionState {
forward(frontHandler, cryptoResponse, true)
backChan.pipeline().addBefore("frame", "crypto", CryptoCodec(aesKey(backKey), aesKey(backKey)))
} catch (e: Exception) {
frontHandler.data.frontChannel.pipeline().fireExceptionCaught(e)
frontHandler.data.frontChannel.fireExceptionCaughtIfOpen(e)
}
}
}
@ -224,7 +224,7 @@ class LoginState : ConnectionState {
loginStart.username = backName!!
send(handler.data.backChannel!!, loginStart, true)
} catch (e: Exception) {
handler.data.frontChannel.pipeline().fireExceptionCaught(e)
handler.data.frontChannel.fireExceptionCaughtIfOpen(e)
}
}
}