diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index 83f0afb95e..3337f6b60d 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -22,6 +22,7 @@ public class NetLoginHandler extends NetHandler { private String g = null; private Packet1Login h = null; private String loginKey = Long.toString(random.nextLong(), 16); // CraftBukkit - Security fix + public String hostname = ""; // CraftBukkit - add field public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) { this.server = minecraftserver; @@ -60,6 +61,12 @@ public class NetLoginHandler extends NetHandler { } public void a(Packet2Handshake packet2handshake) { + // CraftBukkit start + int i = packet2handshake.a.indexOf(';'); + if (i == -1) { + this.hostname = ""; + } else this.hostname = packet2handshake.a.substring(i + 1); + // CraftBukkit end if (this.server.onlineMode) { this.loginKey = Long.toString(random.nextLong(), 16); this.networkManager.queue(new Packet2Handshake(this.loginKey)); @@ -92,7 +99,7 @@ public class NetLoginHandler extends NetHandler { } public void b(Packet1Login packet1login) { - EntityPlayer entityplayer = this.server.serverConfigurationManager.attemptLogin(this, packet1login.name); + EntityPlayer entityplayer = this.server.serverConfigurationManager.attemptLogin(this, packet1login.name, this.hostname); // CraftBukkit - add hostname parameter if (entityplayer != null) { this.server.serverConfigurationManager.b(entityplayer); diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index da9f6d94f0..d1ab7d1dd3 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -199,14 +199,14 @@ public class ServerConfigurationManager { return playerQuitEvent.getQuitMessage(); // CraftBukkit } - public EntityPlayer attemptLogin(NetLoginHandler netloginhandler, String s) { + public EntityPlayer attemptLogin(NetLoginHandler netloginhandler, String s, String hostname) { // CraftBukkit - add hostname parameter // CraftBukkit start - note: this entire method needs to be changed // Instead of kicking then returning, we need to store the kick reason // in the event, check with plugins to see if it's ok, and THEN kick // depending on the outcome. Also change any reference to this.e.c to entity.world EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, new ItemInWorldManager(this.server.getWorldServer(0))); - Player player = (entity == null) ? null : (Player) entity.getBukkitEntity(); - PlayerLoginEvent event = new PlayerLoginEvent(player); + Player player = (Player) entity.getBukkitEntity(); + PlayerLoginEvent event = new PlayerLoginEvent(player, hostname); String s1 = netloginhandler.networkManager.getSocketAddress().toString();