mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-04 09:30:00 +01:00
code cleanup, change hs msg to a http-like format
This commit is contained in:
parent
8586f08adb
commit
177b950400
@ -21,7 +21,7 @@ object VIAaaSConfig : Config(File("config/viaaas.yml")) {
|
||||
val useStrongRandom: Boolean get() = this.getBoolean("use-strong-random", true)
|
||||
val blockLocalAddress: Boolean get() = this.getBoolean("block-local-address", true)
|
||||
val requireHostName: Boolean get() = this.getBoolean("require-host-name", true)
|
||||
val defaultBackendPort: Int get() = this.getInt("default-backend-port", 25565)
|
||||
val defaultBackendPort: Int? get() = this.getInt("default-backend-port", 25565).let { if (it == -1) null else it }
|
||||
val blockedBackAddresses: List<String>
|
||||
get() = this.get(
|
||||
"blocked-back-addresses",
|
||||
@ -40,4 +40,4 @@ object VIAaaSConfig : Config(File("config/viaaas.yml")) {
|
||||
val rateLimitWs: Double get() = this.getDouble("rate-limit-ws", 1.0)
|
||||
val rateLimitConnectionMc: Double get() = this.getDouble("rate-limit-connection-mc", 10.0)
|
||||
val listeningWsLimit: Int get() = this.getInt("listening-ws-limit", 16)
|
||||
}
|
||||
}
|
||||
|
@ -39,17 +39,16 @@ class HandshakeState : MinecraftConnectionState {
|
||||
if (!RateLimit.rateLimitByIp.get((handler.remoteAddress as InetSocketAddress).address).tryAcquire()) {
|
||||
throw IllegalStateException("Rate-limited")
|
||||
}
|
||||
val virtualPort = packet.port
|
||||
val extraData = packet.address.substringAfter(0.toChar(), missingDelimiterValue = "") // todo
|
||||
val virtualHostNoExtra = packet.address.substringBefore(0.toChar())
|
||||
|
||||
val parsed = VIAaaSAddress().parse(packet.address.substringBefore(0.toChar()), VIAaaSConfig.hostName)
|
||||
val parsed = VIAaaSAddress().parse(virtualHostNoExtra, VIAaaSConfig.hostName)
|
||||
val backProto = parsed.protocol
|
||||
val hadHostname = parsed.viaSuffix != null
|
||||
|
||||
packet.address = parsed.serverAddress!!
|
||||
packet.port = parsed.port ?: if (VIAaaSConfig.defaultBackendPort == -1) {
|
||||
packet.port
|
||||
} else {
|
||||
VIAaaSConfig.defaultBackendPort
|
||||
}
|
||||
packet.port = parsed.port ?: VIAaaSConfig.defaultBackendPort ?: virtualPort
|
||||
|
||||
handler.data.viaBackServerVer = backProto
|
||||
var frontOnline = parsed.online
|
||||
@ -63,10 +62,8 @@ class HandshakeState : MinecraftConnectionState {
|
||||
|
||||
val playerAddr = handler.data.frontHandler.remoteAddress
|
||||
mcLogger.info(
|
||||
"HS: $playerAddr (P: ${handler.data.frontVer}, S: ${handler.data.state.state.toString().substring(0, 1)}" +
|
||||
" O: ${
|
||||
frontOnline.toString().substring(0, 1)
|
||||
}) -> ${packet.address}:${packet.port} (${backProto ?: "AUTO"})"
|
||||
"HS: $playerAddr ${handler.data.state.state.toString().substring(0, 1)} " +
|
||||
"$virtualHostNoExtra $virtualPort v${handler.data.frontVer}"
|
||||
)
|
||||
|
||||
if (!hadHostname && VIAaaSConfig.requireHostName) {
|
||||
|
Loading…
Reference in New Issue
Block a user