Add experimental offline mode support - closes issue #121
This commit is contained in:
parent
0d5099bee5
commit
d17c457040
@ -34,6 +34,15 @@ public interface ConfigurationAdapter
|
|||||||
*/
|
*/
|
||||||
public String getString(String path, String def);
|
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.
|
* Get the configuration all servers which may be accessible via the proxy.
|
||||||
*
|
*
|
||||||
|
@ -51,7 +51,7 @@ public class EncryptionUtil
|
|||||||
keys = KeyPairGenerator.getInstance( "RSA" ).generateKeyPair();
|
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[] pubKey = keys.getPublic().getEncoded();
|
||||||
byte[] verify = new byte[ 4 ];
|
byte[] verify = new byte[ 4 ];
|
||||||
random.nextBytes( verify );
|
random.nextBytes( verify );
|
||||||
|
@ -109,7 +109,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo
|
|||||||
Preconditions.checkState( thisState == State.ENCRYPT, "Not expecting ENCRYPT" );
|
Preconditions.checkState( thisState == State.ENCRYPT, "Not expecting ENCRYPT" );
|
||||||
|
|
||||||
SecretKey shared = EncryptionUtil.getSecret( encryptResponse, request );
|
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" );
|
throw new KickException( "Not authenticated with minecraft.net" );
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,10 @@ public class Configuration
|
|||||||
* Set of all servers.
|
* Set of all servers.
|
||||||
*/
|
*/
|
||||||
private Map<String, ServerInfo> servers;
|
private Map<String, ServerInfo> servers;
|
||||||
|
/**
|
||||||
|
* Should we check minecraft.net auth.
|
||||||
|
*/
|
||||||
|
private boolean onlineMode = true;
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
@ -52,6 +56,7 @@ public class Configuration
|
|||||||
|
|
||||||
timeout = adapter.getInt( "timeout", timeout );
|
timeout = adapter.getInt( "timeout", timeout );
|
||||||
uuid = adapter.getString( "stats", uuid );
|
uuid = adapter.getString( "stats", uuid );
|
||||||
|
onlineMode = adapter.getBoolean( "online_mode", onlineMode );
|
||||||
|
|
||||||
DefaultTabList tab = DefaultTabList.valueOf( adapter.getString( "tab_list", "GLOBAL_PING" ) );
|
DefaultTabList tab = DefaultTabList.valueOf( adapter.getString( "tab_list", "GLOBAL_PING" ) );
|
||||||
if ( tab == null )
|
if ( tab == null )
|
||||||
|
@ -127,6 +127,12 @@ public class YamlConfig implements ConfigurationAdapter
|
|||||||
return get( path, def );
|
return get( path, def );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getBoolean(String path, boolean def)
|
||||||
|
{
|
||||||
|
return get( path, def );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Map<String, ServerInfo> getServers()
|
public Map<String, ServerInfo> getServers()
|
||||||
|
Loading…
Reference in New Issue
Block a user