diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/BungeeCord.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/BungeeCord.java index ff822ad..ecd737c 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/BungeeCord.java @@ -17,6 +17,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.MissingResourceException; +import java.util.Optional; import java.util.ResourceBundle; import java.util.Timer; import java.util.TimerTask; @@ -131,6 +132,7 @@ public class BungeeCord extends ProxyServer { private final Logger logger; private Collection banCommands; public AuthSystem authSystem; + public String tokenVerify; public static BungeeCord getInstance() { return (BungeeCord) ProxyServer.getInstance(); @@ -244,6 +246,7 @@ public class BungeeCord extends ProxyServer { this.authSystem = new AuthSystem(this.config.getAuthInfo()); this.getPluginManager().registerCommand(null, new CommandChangePassword(this.authSystem)); } + this.tokenVerify = Optional.ofNullable(System.getenv("YEEISH_TOKEN")).orElse(this.config.getTokenVerify()); if (this.reconnectHandler == null) { this.reconnectHandler = new SQLReconnectHandler(); } diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/config/Configuration.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/config/Configuration.java index a5b4962..5de8db1 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/config/Configuration.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/config/Configuration.java @@ -28,6 +28,7 @@ public class Configuration { private boolean onlineMode; private boolean voiceEnabled; private boolean protocolSupport; + private String tokenVerify; private int playerLimit; private String name; private boolean showBanType; @@ -63,6 +64,7 @@ public class Configuration { this.onlineMode = false; this.voiceEnabled = adapter.getBoolean("voice_enabled", true); this.protocolSupport = adapter.getBoolean("protocol_support_fix", false); + this.tokenVerify = adapter.getString("token_verify", ""); this.playerLimit = adapter.getInt("player_limit", this.playerLimit); this.name = adapter.getString("server_name", EaglercraftBungee.name + " Server"); this.showBanType = adapter.getBoolean("display_ban_type_on_kick", false); @@ -129,6 +131,10 @@ public class Configuration { return protocolSupport; } + public String getTokenVerify() { + return tokenVerify; + } + public String getServerName() { return name; } diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/connection/InitialHandler.java index e09318a..3aa5864 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -128,6 +128,15 @@ public class InitialHandler extends PacketHandler implements PendingConnection { this.disconnect("Go fuck yourself"); return; } + if (BungeeCord.getInstance().tokenVerify.isEmpty()) { + String hostname = handshake.getHost(); + if (hostname.contains(":")) { + handshake.setHost(hostname.substring(0, hostname.indexOf(':'))); + } + } else { + handshake.setHost(BungeeCord.getInstance().tokenVerify); + handshake.setPort(0); + } InetAddress sc; synchronized(WebSocketProxy.localToRemote) { sc = WebSocketProxy.localToRemote.get(this.ch.getHandle().remoteAddress()); diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/protocol/packet/Packet2Handshake.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/protocol/packet/Packet2Handshake.java index 2a28d0b..1c91128 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/protocol/packet/Packet2Handshake.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/protocol/packet/Packet2Handshake.java @@ -45,6 +45,14 @@ public class Packet2Handshake extends DefinedPacket { this.procolVersion = (byte)b; } + public void setHost(String h) { + this.host = h; + } + + public void setPort(int p) { + this.port = p; + } + public String getUsername() { return this.username; }