mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-02-10 00:41:56 +01:00
clearer message of domain suffix, add parsing options like "u__jeb"
This commit is contained in:
parent
f998115b43
commit
508da67d12
@ -1,6 +1,7 @@
|
||||
package com.github.creeper123123321.viaaas
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion
|
||||
import java.util.*
|
||||
|
||||
class VIAaaSAddress {
|
||||
var serverAddress: String? = null
|
||||
@ -38,30 +39,23 @@ class VIAaaSAddress {
|
||||
}
|
||||
|
||||
fun parseOption(part: String): Boolean {
|
||||
if (part.startsWith("_")) {
|
||||
val option = when {
|
||||
part.length < 2 -> null
|
||||
part.startsWith("_") -> part[1]
|
||||
part[1] == '_' -> part[0]
|
||||
else -> null
|
||||
}?.toString()
|
||||
if (option != null) {
|
||||
val arg = part.substring(2)
|
||||
when {
|
||||
part.startsWith("_p", ignoreCase = true) -> port = arg.toInt()
|
||||
part.startsWith("_o", ignoreCase = true) -> {
|
||||
online = when {
|
||||
when (option.toLowerCase(Locale.ROOT)) {
|
||||
"p" -> port = arg.toInt()
|
||||
"o" -> online = when {
|
||||
arg.startsWith("t", ignoreCase = true) -> true
|
||||
arg.startsWith("f", ignoreCase = true) -> false
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
part.startsWith("_v", ignoreCase = true) -> {
|
||||
try {
|
||||
protocol = arg.toInt()
|
||||
} catch (e: NumberFormatException) {
|
||||
ProtocolVersion.getClosest(arg.replace("_", "."))?.also {
|
||||
protocol = it.version
|
||||
}
|
||||
}
|
||||
if (protocol == -2) {
|
||||
protocol = null
|
||||
}
|
||||
}
|
||||
part.startsWith("_u", ignoreCase = true) -> {
|
||||
"v" -> parseProtocol(arg)
|
||||
"u" -> {
|
||||
if (arg.length > 16) throw IllegalArgumentException("Invalid username")
|
||||
username = arg
|
||||
}
|
||||
@ -70,4 +64,17 @@ class VIAaaSAddress {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun parseProtocol(arg: String) {
|
||||
try {
|
||||
protocol = arg.toInt()
|
||||
} catch (e: NumberFormatException) {
|
||||
ProtocolVersion.getClosest(arg.replace("_", "."))?.also {
|
||||
protocol = it.version
|
||||
}
|
||||
}
|
||||
if (protocol == -2) {
|
||||
protocol = null
|
||||
}
|
||||
}
|
||||
}
|
@ -70,7 +70,7 @@ class HandshakeState : MinecraftConnectionState {
|
||||
)
|
||||
|
||||
if (!hadHostname && VIAaaSConfig.requireHostName) {
|
||||
throw UnsupportedOperationException("This VIAaaS instance requires you to use the hostname")
|
||||
throw UnsupportedOperationException("Missing domain suffix in hostname")
|
||||
}
|
||||
|
||||
if (packet.nextState == State.STATUS) {
|
||||
@ -85,4 +85,4 @@ class HandshakeState : MinecraftConnectionState {
|
||||
override fun onInactivated(handler: MinecraftHandler) {
|
||||
// Not worth logging
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ mc-rsa-size: 4096
|
||||
use-strong-random: true
|
||||
# Blocks connection to local addresses
|
||||
block-local-address: true
|
||||
# Requires virtual host to contain the value from "host-name"
|
||||
# Requires virtual host to contain the value from "host-name" as a suffix
|
||||
# A false value could be used for transparent proxying.
|
||||
require-host-name: true
|
||||
# Default port to be used to connect to backend server
|
||||
@ -37,4 +37,4 @@ rate-limit-ws: 1.5
|
||||
# Rate limits new front-end connections per second per ip. Will disconnect when hit
|
||||
rate-limit-connection-mc: 10.0
|
||||
# Limits how many usernames a websocket connection can listen to.
|
||||
listening-ws-limit: 10
|
||||
listening-ws-limit: 10
|
||||
|
Loading…
Reference in New Issue
Block a user