Fixed BungeeCord support

This commit is contained in:
games647
2016-03-20 11:30:52 +01:00
parent 9c0ad7d70c
commit 5608821fe3
22 changed files with 119 additions and 80 deletions

View File

@@ -1,6 +1,12 @@
######0.6
######0.7
* Added /premium [player] command with optional player parameter
* Fixed BungeeCord support
* Changed config option autologin to autoregister to clarify the usage
* Updated to the newest changes of Spigot
######0.6
* Fixed 1.9 bugs
* Added UltraAuth support

View File

@@ -10,8 +10,11 @@ So they don't need to enter passwords. This is also called auto login (auto-logi
* Detect paid accounts from others
* Automatically login paid accounts (premium)
* Support various of auth plugins
* Experimental Cauldron support
* Cauldron support
* Forge/Sponge message support
* BungeeCord support
* Auto register new premium players
* Plugin: ProtocolSupport is supported and can be used as an alternative to ProtocolLib
* No client modifications needed
* Good performance by using async non blocking operations
* Free
@@ -27,9 +30,9 @@ So they don't need to enter passwords. This is also called auto login (auto-logi
###Requirements:
* Plugin: [ProtocolLib](http://www.spigotmc.org/resources/protocollib.1997/)
* Tested Bukkit/[Spigot](https://www.spigotmc.org) 1.8.8 (could also work with other versions)
* Java 7 or above
* Run in offline mode (see server.properties)
* Tested Bukkit/[Spigot](https://www.spigotmc.org) 1.9 (could also work with other versions)
* Java 7+
* Run Spigot and/or BungeeCord in offline mode (see server.properties or config.yml)
* An auth plugin. Supported Plugins:
* [AuthMe](http://dev.bukkit.org/bukkit-plugins/authme-reloaded/)
* [xAuth](http://dev.bukkit.org/bukkit-plugins/xauth/)

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin-parent</artifactId>
<version>0.6</version>
<version>0.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -82,9 +82,9 @@ public class FastLoginBukkit extends JavaPlugin {
AsynchronousManager asynchronousManager = protocolManager.getAsynchronousManager();
asynchronousManager.registerAsyncHandler(new StartPacketListener(this, protocolManager)).start();
asynchronousManager.registerAsyncHandler(new EncryptionPacketListener(this, protocolManager)).start();
}
getServer().getPluginManager().registerEvents(new BukkitJoinListener(this), this);
}
//register commands using a unique name
getCommand("premium").setExecutor(new PremiumCommand(this));

View File

@@ -25,6 +25,10 @@ public class PlayerSession {
this.verifyToken = ArrayUtils.clone(verifyToken);
}
public PlayerSession(String username) {
this(username, "", ArrayUtils.EMPTY_BYTE_ARRAY);
}
/**
* Gets the random generated server id. This makes sure the request
* sent from the client is just for this server.
@@ -32,6 +36,8 @@ public class PlayerSession {
* See this for details
* http://www.sk89q.com/2011/09/minecraft-name-spoofing-exploit/
*
* Empty if it's a BungeeCord connection
*
* @return random generated server id
*/
public String getServerId() {
@@ -41,6 +47,8 @@ public class PlayerSession {
/**
* Gets the verify token the server sent to the client.
*
* Empty if it's a BungeeCord connection
*
* @return the verify token from the server
*/
public byte[] getVerifyToken() {

View File

@@ -28,10 +28,24 @@ public class CrackedCommand implements CommandExecutor {
}
String playerName = sender.getName();
plugin.getEnabledPremium().remove(playerName);
sender.sendMessage(ChatColor.DARK_GREEN + "Removed to the list of premium players");
boolean existed = plugin.getEnabledPremium().remove(playerName);
if (existed) {
sender.sendMessage(ChatColor.DARK_GREEN + "Removed from the list of premium players");
notifiyBungeeCord((Player) sender);
} else {
sender.sendMessage(ChatColor.DARK_RED + "You are not in the premium list");
}
return true;
} else {
String playerName = args[0];
boolean existed = plugin.getEnabledPremium().remove(playerName);
if (existed) {
sender.sendMessage(ChatColor.DARK_GREEN + "Removed from the list of premium players");
// notifiyBungeeCord((Player) sender);
} else {
sender.sendMessage(ChatColor.DARK_RED + "User is not in the premium list");
}
}
return true;

View File

@@ -37,6 +37,11 @@ public class PremiumCommand implements CommandExecutor {
sender.sendMessage(ChatColor.DARK_GREEN + "Added to the list of premium players");
notifiyBungeeCord((Player) sender);
return true;
} else {
String playerName = args[0];
plugin.getEnabledPremium().add(playerName);
sender.sendMessage(ChatColor.DARK_GREEN + "Added player to the list of premium players");
// notifiyBungeeCord();
}
return true;

View File

@@ -6,7 +6,10 @@ import org.bukkit.entity.Player;
/**
* Github: https://github.com/Xephi/AuthMeReloaded/
* Project page: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
* Project page:
*
* Bukkit: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
* Spigot: https://www.spigotmc.org/resources/authme-reloaded.6269/
*/
public class AuthMeHook implements AuthPlugin {

View File

@@ -8,7 +8,8 @@ import org.bukkit.entity.Player;
public interface AuthPlugin {
/**
* Login the premium (paid account) player
* Login the premium (paid account) player after
* the player joined successfully the server.
*
* @param player the player that needs to be logged in
*/
@@ -21,6 +22,9 @@ public interface AuthPlugin {
* so we can be sure the premium player doesn't steal the account
* of that player.
*
* This operation will be performed async while the player is
* connecting
*
* @param playerName player name
* @return if the player has an account
*/
@@ -28,6 +32,10 @@ public interface AuthPlugin {
/**
* Forces a register in order to protect the paid account.
* The method will be invoked after the player joined the server.
*
* After a successful registration the player should be logged
* in too.
*
* The method will be called only for premium accounts.
* So it's recommended to set additionally premium property

View File

@@ -15,7 +15,10 @@ import org.bukkit.entity.Player;
/**
* Github: https://github.com/ST-DDT/CrazyLogin
* Project page: http://dev.bukkit.org/server-mods/crazylogin/
*
* Project page:
*
* Bukkit: http://dev.bukkit.org/server-mods/crazylogin/
*/
public class CrazyLoginHook implements AuthPlugin {
@@ -32,7 +35,7 @@ public class CrazyLoginHook implements AuthPlugin {
String ip = player.getAddress().getAddress().getHostAddress();
//this should be done after login to restore the inventory, unhide players, prevent potential memory leaks...
//extracted from: https://github.com/ST-DDT/CrazyLogin/blob/master/src/main/java/de/st_ddt/crazylogin/CrazyLogin.java#L1948
//from: https://github.com/ST-DDT/CrazyLogin/blob/master/src/main/java/de/st_ddt/crazylogin/CrazyLogin.java#L1948
playerData.resetLoginFails();
player.setFireTicks(0);

View File

@@ -12,8 +12,11 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* Github: http://dev.bukkit.org/bukkit-plugins/loginsecurity/
* Project page: https://github.com/lenis0012/LoginSecurity-2
* Github: https://github.com/lenis0012/LoginSecurity-2
* Project page:
*
* Bukkit: http://dev.bukkit.org/bukkit-plugins/loginsecurity/
* Spigot: https://www.spigotmc.org/resources/loginsecurity.19362/
*
* on join:
* https://github.com/lenis0012/LoginSecurity-2/blob/master/src/main/java/com/lenis0012/bukkit/ls/LoginSecurity.java#L282
@@ -44,7 +47,7 @@ public class LoginSecurityHook implements AuthPlugin {
//https://github.com/lenis0012/LoginSecurity-2/blob/master/src/main/java/com/lenis0012/bukkit/ls/LoginSecurity.java#L283
UUID offlineUuid = UUID.nameUUIDFromBytes(playerName.getBytes(Charsets.UTF_8));
return dataManager.isRegistered(offlineUuid.toString().replace("-", ""));
//check for sessions in order to prevent a sql query?
//check for loginsecurity sessions in order to prevent a sql query?
//sesUse && thread.getSession().containsKey(uuid) && checkLastIp(player)) {
}

View File

@@ -4,6 +4,13 @@ import org.bukkit.entity.Player;
import org.royaldev.royalauth.AuthPlayer;
import org.royaldev.royalauth.Config;
/**
* Github: https://github.com/RoyalDev/RoyalAuth
*
* Project page:
*
* Bukkit: http://dev.bukkit.org/bukkit-plugins/royalauth/
*/
public class RoyalAuthHook implements AuthPlugin {
@Override

View File

@@ -40,6 +40,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.InventoryView.Property;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MainHand;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.map.MapView;
import org.bukkit.metadata.MetadataValue;
@@ -55,7 +56,10 @@ import org.bukkit.util.Vector;
import ultraauth.api.UltraAuthAPI;
/**
* Project page: http://dev.bukkit.org/bukkit-plugins/ultraauth-aa/
* Project page:
*
* Bukkit: http://dev.bukkit.org/bukkit-plugins/ultraauth-aa/
* Spigot: https://www.spigotmc.org/resources/ultraauth.17044/
*/
public class UltraAuthHook implements AuthPlugin {
@@ -1402,5 +1406,19 @@ public class UltraAuthHook implements AuthPlugin {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public MainHand getMainHand() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isGliding() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setGliding(boolean arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
}

View File

@@ -7,7 +7,10 @@ import org.bukkit.entity.Player;
/**
* Github: https://github.com/LycanDevelopment/xAuth/
* Project page: http://dev.bukkit.org/bukkit-plugins/xauth/
*
* Project page:
*
* Bukkit: http://dev.bukkit.org/bukkit-plugins/xauth/
*/
public class xAuthHook implements AuthPlugin {

View File

@@ -35,7 +35,7 @@ public class BukkitJoinListener implements Listener {
final Player player = joinEvent.getPlayer();
//removing the session because we now use it
final PlayerSession session = plugin.getSessions().remove(player.getAddress().toString());
final PlayerSession session = plugin.getSessions().get(player.getAddress().toString());
if (session != null) {
WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player);
WrappedSignedProperty skin = session.getSkin();
@@ -49,6 +49,10 @@ public class BukkitJoinListener implements Listener {
@Override
public void run() {
if (player.isOnline()) {
//remove the bungeecord identifier
String id = '/' + player.getAddress().getHostString() + ':' + player.getAddress().getPort();
PlayerSession session = plugin.getSessions().get(id);
//blacklist this target player for BungeeCord Id brute force attacks
player.setMetadata(plugin.getName(), new FixedMetadataValue(plugin, true));
//check if it's the same player as we checked before

View File

@@ -61,10 +61,13 @@ public class BungeeCordListener implements PluginMessageListener {
//fail if BungeeCord support is disabled (id = null)
if (sourceId.equals(proxyId)) {
PlayerSession playerSession = new PlayerSession(playerName, null, null);
PlayerSession playerSession = new PlayerSession(playerName);
playerSession.setVerified(true);
playerSession.setRegistered(true);
//put it only if the user doesn't has a session open
//so that the player have to send the bungeecord packet and cannot skip the verification then
plugin.getSessions().putIfAbsent(checkedPlayer.getAddress().toString(), playerSession);
} else {
//blacklist target for the current login

View File

@@ -1,6 +1,7 @@
package com.github.games647.fastlogin.bukkit.listener;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.PacketType.Protocol;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
@@ -34,10 +35,10 @@ public class HandshakePacketListener extends PacketAdapter {
@Override
public void onPacketReceiving(PacketEvent packetEvent) {
PacketContainer packet = packetEvent.getPacket();
PacketType.Protocol nextProtocol = packet.getProtocols().read(0);
Protocol nextProtocol = packet.getProtocols().read(0);
//we don't want to listen for server ping.
if (nextProtocol == PacketType.Protocol.LOGIN) {
if (nextProtocol == Protocol.LOGIN) {
//here are the information written separated by a space
String hostname = packet.getStrings().read(0);
//https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/browse/CraftBukkit-Patches/0055-BungeeCord-Support.patch

View File

@@ -1,27 +1,18 @@
package com.github.games647.fastlogin.bukkit.listener;
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.bukkit.PlayerSession;
import java.net.InetSocketAddress;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import protocolsupport.api.events.PlayerLoginStartEvent;
import protocolsupport.api.events.PlayerPropertiesResolveEvent;
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty;
public class ProtcolSupportListener implements Listener {
private static final long DELAY_LOGIN = 1 * 20L / 2;
protected final FastLoginBukkit plugin;
public ProtcolSupportListener(FastLoginBukkit plugin) {
@@ -41,7 +32,7 @@ public class ProtcolSupportListener implements Listener {
if (plugin.getEnabledPremium().contains(playerName)) {
//the player have to be registered in order to invoke the command
startPremiumSession(playerName, loginStartEvent, true);
} else if (plugin.getConfig().getBoolean("autologin") && !plugin.getAuthPlugin().isRegistered(playerName)) {
} else if (plugin.getConfig().getBoolean("autoRegister") && !plugin.getAuthPlugin().isRegistered(playerName)) {
startPremiumSession(playerName, loginStartEvent, false);
plugin.getEnabledPremium().add(playerName);
}
@@ -53,49 +44,8 @@ public class ProtcolSupportListener implements Listener {
PlayerSession session = plugin.getSessions().get(address.toString());
if (session != null) {
session.setVerified(true);
ProfileProperty skinProperty = propertiesResolveEvent.getProperties().get("textures");
if (skinProperty != null) {
WrappedSignedProperty signedProperty = WrappedSignedProperty
.fromValues(skinProperty.getName(), skinProperty.getValue(), skinProperty.getSignature());
session.setSkin(signedProperty);
}
}
}
@EventHandler(ignoreCancelled = true)
public void onJoin(PlayerJoinEvent joinEvent) {
final Player player = joinEvent.getPlayer();
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
String address = player.getAddress().getAddress().toString();
//removing the session because we now use it
PlayerSession session = plugin.getSessions().remove(address);
if (player.isOnline()) {
//check if it's the same player as we checked before
if (session != null && player.getName().equals(session.getUsername()) && session.isVerified()) {
if (session.needsRegistration()) {
plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName());
String generatedPassword = plugin.generateStringPassword();
plugin.getAuthPlugin().forceRegister(player, generatedPassword);
player.sendMessage(ChatColor.DARK_GREEN + "Auto registered with password: "
+ generatedPassword);
player.sendMessage(ChatColor.DARK_GREEN + "You may want change it?");
} else {
plugin.getLogger().log(Level.FINE, "Logging player {0} in", player.getName());
plugin.getAuthPlugin().forceLogin(player);
player.sendMessage(ChatColor.DARK_GREEN + "Auto logged in");
}
}
}
}
//Wait before auth plugin and we received a message from BungeeCord initializes the player
}, DELAY_LOGIN);
}
private void startPremiumSession(String playerName, PlayerLoginStartEvent loginStartEvent, boolean registered) {
if (plugin.getApiConnector().isPremiumName(playerName)) {

View File

@@ -4,7 +4,7 @@
# Request a premium login without forcing the player to type a command
#
# If you activate autologin, this plugin will check/do these points on login:
# If you activate autoRegister, this plugin will check/do these points on login:
# 1. An existing cracked account shouldn't exist
# -> paid accounts cannot steal the existing account of cracked players
# - (Already registered players could still use the /premium command to activate premium checks)
@@ -16,4 +16,4 @@
# the player just disconnect and sees the message: 'bad login'
# There is no way to change this message
# For more information: https://github.com/games647/FastLogin#why-do-players-have-to-invoke-a-command
autologin: false
autoRegister: false

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin-parent</artifactId>
<version>0.6</version>
<version>0.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -8,7 +8,7 @@
<packaging>pom</packaging>
<name>FastLogin</name>
<version>0.6</version>
<version>0.7</version>
<inceptionYear>2015</inceptionYear>
<url>https://www.spigotmc.org/resources/fastlogin.14153/</url>
<description>

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>com.github.games647</groupId>
<artifactId>fastlogin-parent</artifactId>
<version>0.6</version>
<version>0.7</version>
<relativePath>../pom.xml</relativePath>
</parent>