Add experimental offline mode support - closes issue #121

This commit is contained in:
md_5 2013-02-12 11:48:38 +11:00
parent 0d5099bee5
commit d17c457040
5 changed files with 22 additions and 2 deletions

View File

@ -34,6 +34,15 @@ public interface ConfigurationAdapter
*/
public String getString(String path, String def);
/**
* Gets a boolean from the specified path.
*
* @param path the path to retrieve the boolean form.
* @param def the default value
* @return the retrieved boolean
*/
public boolean getBoolean(String path, boolean def);
/**
* Get the configuration all servers which may be accessible via the proxy.
*

View File

@ -51,7 +51,7 @@ public class EncryptionUtil
keys = KeyPairGenerator.getInstance( "RSA" ).generateKeyPair();
}
String hash = Long.toString( random.nextLong(), 16 );
String hash = ( BungeeCord.getInstance().config.isOnlineMode() ) ? Long.toString( random.nextLong(), 16 ) : "-";
byte[] pubKey = keys.getPublic().getEncoded();
byte[] verify = new byte[ 4 ];
random.nextBytes( verify );

View File

@ -109,7 +109,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo
Preconditions.checkState( thisState == State.ENCRYPT, "Not expecting ENCRYPT" );
SecretKey shared = EncryptionUtil.getSecret( encryptResponse, request );
if ( !EncryptionUtil.isAuthenticated( handshake.username, request.serverId, shared ) )
if ( BungeeCord.getInstance().config.isOnlineMode() && !EncryptionUtil.isAuthenticated( handshake.username, request.serverId, shared ) )
{
throw new KickException( "Not authenticated with minecraft.net" );
}

View File

@ -44,6 +44,10 @@ public class Configuration
* Set of all servers.
*/
private Map<String, ServerInfo> servers;
/**
* Should we check minecraft.net auth.
*/
private boolean onlineMode = true;
public void load()
{
@ -52,6 +56,7 @@ public class Configuration
timeout = adapter.getInt( "timeout", timeout );
uuid = adapter.getString( "stats", uuid );
onlineMode = adapter.getBoolean( "online_mode", onlineMode );
DefaultTabList tab = DefaultTabList.valueOf( adapter.getString( "tab_list", "GLOBAL_PING" ) );
if ( tab == null )

View File

@ -127,6 +127,12 @@ public class YamlConfig implements ConfigurationAdapter
return get( path, def );
}
@Override
public boolean getBoolean(String path, boolean def)
{
return get( path, def );
}
@Override
@SuppressWarnings("unchecked")
public Map<String, ServerInfo> getServers()