implement #87 multiple hostname suffix

This commit is contained in:
creeper123123321 2021-03-25 18:13:44 -03:00
parent cf4573fc9d
commit e73175b7c5
3 changed files with 13 additions and 6 deletions

View File

@ -16,7 +16,7 @@ object VIAaaSConfig : Config(File("config/viaaas.yml")) {
val isNativeTransportMc: Boolean get() = this.getBoolean("native-transport-mc", true)
val port: Int get() = this.getInt("port", 25565)
val bindAddress: String get() = this.getString("bind-address", "localhost")!!
val hostName: String get() = this.getString("host-name", "viaaas.localhost")!!
val hostName: List<String> get() = this.getString("host-name", "viaaas.localhost")!!.split(",")
val mcRsaSize: Int get() = this.getInt("mc-rsa-size", 4096)
val useStrongRandom: Boolean get() = this.getBoolean("use-strong-random", true)
val blockLocalAddress: Boolean get() = this.getBoolean("block-local-address", true)

View File

@ -23,6 +23,7 @@ class HandshakeState : MinecraftConnectionState {
RateLimiter.create(VIAaaSConfig.rateLimitConnectionMc)
})
}
override val state: State
get() = State.HANDSHAKE
@ -43,7 +44,12 @@ class HandshakeState : MinecraftConnectionState {
val extraData = packet.address.substringAfter(0.toChar(), missingDelimiterValue = "") // todo
val virtualHostNoExtra = packet.address.substringBefore(0.toChar())
val parsed = VIAaaSAddress().parse(virtualHostNoExtra, VIAaaSConfig.hostName)
val parsed = VIAaaSConfig.hostName.map {
VIAaaSAddress().parse(virtualHostNoExtra, it)
}.sortedBy {
it.viaSuffix == null
}.first()
val backProto = parsed.protocol
val hadHostname = parsed.viaSuffix != null

View File

@ -26,14 +26,15 @@ use-strong-random: false
######
# VIAaaS virtual hosts options
######
# Host name of this instance, that will be used in the virtual host as a suffix.
host-name: viaaas.localhost
# Requires online mode for front-end connections. May be useful for stopping bots.
force-online-mode: false
# Requires virtual host to contain the value from "host-name" as a suffix.
# A false value will allow virtual hosts with no suffix, connecting to the virtual host sent by client.
# A false value could be used for transparent proxying.
require-host-name: true
# Host names of this instance, that will be used in the virtual host as a suffix.
# Use commas for separating multiple hostnames.
host-name: viaaas.localhost,via.localhost
# Requires online mode for front-end connections. May be useful for stopping bots.
force-online-mode: false
# Default port to be used when connecting to the backend server.
# Use -1 to reuse the port sent by client, useful for transparent proxying.
default-backend-port: 25565