fix import, show backend address in login msg

This commit is contained in:
creeper123123321 2021-02-18 18:08:33 -03:00
parent 1667bfe2ec
commit 5c01df5f28
4 changed files with 13 additions and 8 deletions

View File

@ -13,7 +13,7 @@ class MinecraftHandler(
val data: ConnectionData,
val frontEnd: Boolean
) : SimpleChannelInboundHandler<Packet>() {
var remoteAddress: SocketAddress? = null
lateinit var remoteAddress: SocketAddress
val other: Channel? get() = if (frontEnd) data.backChannel else data.frontChannel
override fun channelRead0(ctx: ChannelHandlerContext, packet: Packet) {

View File

@ -107,8 +107,8 @@ class LoginState : MinecraftConnectionState {
parseUndashedId(playerId),
backName!!,
backHash,
frontHandler.remoteAddress!!,
backPublicKey
frontHandler.remoteAddress,
handler.data.backHandler!!.remoteAddress
).whenCompleteAsync({ _, throwable ->
if (throwable != null) {
frontHandler.data.backHandler!!.disconnect("Online mode error: $throwable")

View File

@ -11,6 +11,7 @@ import io.ktor.websocket.*
import kotlinx.coroutines.channels.consumeEach
import org.slf4j.event.Level
import java.nio.channels.ClosedChannelException
import java.time.Duration
class ViaWebApp {
fun Application.main() {

View File

@ -13,8 +13,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import us.myles.ViaVersion.api.Via
import java.net.InetSocketAddress
import java.net.SocketAddress
import java.security.PublicKey
import java.util.*
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ConcurrentHashMap
@ -46,14 +46,18 @@ class WebDashboardServer {
suspend fun requestSessionJoin(
id: UUID, name: String, hash: String,
address: SocketAddress, backKey: PublicKey
)
: CompletableFuture<Unit> {
address: SocketAddress, backAddress: SocketAddress
): CompletableFuture<Unit> {
val future = viaWebServer.pendingSessionHashes.get(hash)
var sent = 0
viaWebServer.listeners[id]?.forEach {
it.ws.send(
"""{"action": "session_hash_request", "user": "$name", "session_hash": "$hash", "message": "Client is $address"}""".trimMargin()
JsonObject().also {
it.addProperty("action", "session_hash_request")
it.addProperty("user", name)
it.addProperty("session_hash", hash)
it.addProperty("message", "Client is $address, backend is $backAddress")
}.toString()
)
it.ws.flush()
sent++