mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2025-04-22 11:03:26 -04:00
Changed to Auto Detect if version is not specified in wildcard-domain
This commit is contained in:
parent
625cbf147e
commit
118af38576
2 changed files with 10 additions and 5 deletions
src/main/java/net/raphimc/viaproxy
|
@ -168,7 +168,7 @@ public class ViaProxyConfig {
|
|||
@Description({
|
||||
"Allows clients to specify a target server and version using wildcard domains.",
|
||||
"none: No wildcard domain handling.",
|
||||
"public: Public wildcard domain handling. Intended for usage by external clients. (Example: address.<address>.port.<port>.version.<version>.viaproxy.127.0.0.1.nip.io)",
|
||||
"public: Public wildcard domain handling. Intended for usage by external clients. (Example: address.<address>.port.<port>.version.<version>.viaproxy.127.0.0.1.nip.io (version is optional))",
|
||||
"internal: Internal wildcard domain handling. Intended for local usage by custom clients. (Example: original-handshake-address\\7address:port\\7version\\7classic-mppass)"
|
||||
})
|
||||
private WildcardDomainHandling wildcardDomainHandling = WildcardDomainHandling.NONE;
|
||||
|
|
|
@ -67,7 +67,7 @@ import java.util.regex.Pattern;
|
|||
public class Client2ProxyHandler extends SimpleChannelInboundHandler<Packet> {
|
||||
|
||||
private static final Pattern ADDRESS_SYNTAX_PATTERN = Pattern.compile(
|
||||
"^address\\.(.+?)\\.port\\.(\\d+?)\\.version\\.(.+?)$"
|
||||
"^address\\.(.+?)\\.port\\.(\\d+?)(?:\\.version\\.(.+?))?$"
|
||||
);
|
||||
|
||||
private ProxyConnection proxyConnection;
|
||||
|
@ -161,9 +161,14 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<Packet> {
|
|||
final int connectPort = Integer.parseInt(matcher.group(2));
|
||||
final String versionString = matcher.group(3);
|
||||
|
||||
serverVersion = ProtocolVersionUtil.fromNameLenient(versionString);
|
||||
if (serverVersion == null) {
|
||||
this.proxyConnection.kickClient("§cWrong domain syntax!\n§cUnknown server version.");
|
||||
if (versionString != null) {
|
||||
serverVersion = ProtocolVersionUtil.fromNameLenient(versionString);
|
||||
if (serverVersion == null) {
|
||||
this.proxyConnection.kickClient("§cWrong domain syntax!\n§cUnknown server version.");
|
||||
}
|
||||
} else {
|
||||
// When no version is specified, use the auto-detect protocol
|
||||
serverVersion = ProtocolTranslator.AUTO_DETECT_PROTOCOL;
|
||||
}
|
||||
|
||||
serverAddress = AddressUtil.parse(connectAddress + ":" + connectPort, serverVersion);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue