diff --git a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java index 25d87d97..217fe761 100644 --- a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java +++ b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java @@ -57,6 +57,7 @@ public class Configuration implements ProxyConfig private boolean ipForward; private Favicon favicon; private int compressionThreshold = 256; + private boolean preventProxyConnections; public void load() { @@ -84,6 +85,7 @@ public class Configuration implements ProxyConfig throttle = adapter.getInt( "connection_throttle", throttle ); ipForward = adapter.getBoolean( "ip_forward", ipForward ); compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold ); + preventProxyConnections = adapter.getBoolean( "prevent_proxy_connections", preventProxyConnections); disabledCommands = new CaseInsensitiveSet( (Collection) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) ); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 649802ec..b30e913c 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -4,6 +4,7 @@ import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.gson.Gson; import java.math.BigInteger; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.URLEncoder; import java.security.MessageDigest; @@ -404,7 +405,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection } String encodedHash = URLEncoder.encode( new BigInteger( sha.digest() ).toString( 16 ), "UTF-8" ); - String authURL = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=" + encName + "&serverId=" + encodedHash; + String preventProxy = ( ( BungeeCord.getInstance().config.isPreventProxyConnections() ) ? "&ip=" + URLEncoder.encode( getAddress().getAddress().getHostAddress(), "UTF-8" ) : "" ); + String authURL = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=" + encName + "&serverId=" + encodedHash + preventProxy; Callback handler = new Callback() { @@ -414,7 +416,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection if ( error == null ) { LoginResult obj = BungeeCord.getInstance().gson.fromJson( result, LoginResult.class ); - if ( obj != null ) + if ( obj != null && obj.getId() != null ) { loginProfile = obj; uniqueId = Util.getUUID( obj.getId() );