Add Mojang prevent_proxy_connections option.

This commit is contained in:
md_5 2017-04-28 21:48:34 +10:00
parent bfab8a1d9c
commit 806a6dfaca
2 changed files with 6 additions and 2 deletions

View File

@ -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<String>) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) );

View File

@ -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<String> handler = new Callback<String>()
{
@ -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() );