From 72ee9c24f62f9be6315ebb0aa082c6bf7d2559e7 Mon Sep 17 00:00:00 2001 From: Prototik Date: Sun, 17 May 2015 20:14:24 +0700 Subject: [PATCH] Add logs for user login process --- .../network/NetHandlerLoginServer.java.patch | 52 +++++++++++++++---- .../network/ThreadPlayerLookupUUID.java | 7 ++- .../configuration/CauldronConfig.java | 2 + 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/patches/net/minecraft/server/network/NetHandlerLoginServer.java.patch b/patches/net/minecraft/server/network/NetHandlerLoginServer.java.patch index 115567e..faaa33b 100644 --- a/patches/net/minecraft/server/network/NetHandlerLoginServer.java.patch +++ b/patches/net/minecraft/server/network/NetHandlerLoginServer.java.patch @@ -1,29 +1,46 @@ --- ../src-base/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java +++ ../src-work/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java -@@ -13,6 +13,7 @@ +@@ -2,17 +2,17 @@ + + import com.google.common.base.Charsets; + import com.mojang.authlib.GameProfile; +-import com.mojang.authlib.exceptions.AuthenticationUnavailableException; +- + import cpw.mods.fml.common.network.internal.FMLNetworkHandler; + import io.netty.util.concurrent.GenericFutureListener; +-import java.math.BigInteger; ++ + import java.security.PrivateKey; + import java.util.Arrays; + import java.util.Random; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; ++ import javax.crypto.SecretKey; + import net.minecraft.network.EnumConnectionState; import net.minecraft.network.NetworkManager; import net.minecraft.network.login.INetHandlerLoginServer; -@@ -29,6 +30,14 @@ +@@ -23,12 +23,17 @@ + import net.minecraft.network.login.server.S02PacketLoginSuccess; + import net.minecraft.server.MinecraftServer; + import net.minecraft.util.ChatComponentText; +-import net.minecraft.util.CryptManager; + import net.minecraft.util.IChatComponent; ++ + import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import net.minecraft.entity.player.EntityPlayerMP; -+import org.bukkit.craftbukkit.util.Waitable; -+import org.bukkit.event.player.AsyncPlayerPreLoginEvent; -+import org.bukkit.event.player.PlayerPreLoginEvent; +// CraftBukkit end +import com.mojang.authlib.properties.Property; + public class NetHandlerLoginServer implements INetHandlerLoginServer { private static final AtomicInteger field_147331_b = new AtomicInteger(0); -@@ -37,16 +46,17 @@ +@@ -37,25 +42,28 @@ private final byte[] field_147330_e = new byte[4]; private final MinecraftServer field_147327_f; public final NetworkManager field_147333_a; @@ -35,6 +52,7 @@ private SecretKey field_147335_k; + public String hostname = ""; // CraftBukkit - add field private static final String __OBFID = "CL_00001458"; ++ private final boolean debug; public NetHandlerLoginServer(MinecraftServer p_i45298_1_, NetworkManager p_i45298_2_) { @@ -43,7 +61,9 @@ this.field_147334_j = ""; this.field_147327_f = p_i45298_1_; this.field_147333_a = p_i45298_2_; -@@ -55,7 +65,7 @@ ++ this.debug = p_i45298_1_.cauldronConfig.userLogin.getValue(); + field_147329_d.nextBytes(this.field_147330_e); + } public void onNetworkTick() { @@ -52,7 +72,7 @@ { this.func_147326_c(); } -@@ -81,24 +91,54 @@ +@@ -81,24 +89,54 @@ } } @@ -111,7 +131,7 @@ } } -@@ -114,29 +154,29 @@ +@@ -114,29 +152,33 @@ public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) { @@ -123,18 +143,22 @@ public void processLoginStart(C00PacketLoginStart p_147316_1_) { - Validate.validState(this.field_147328_g == NetHandlerLoginServer.LoginState.HELLO, "Unexpected hello packet", new Object[0]); ++ if (debug) logger.info("Login attempt"); + Validate.validState(this.field_147328_g == LoginState.HELLO, "Unexpected hello packet", new Object[0]); this.field_147337_i = p_147316_1_.func_149304_c(); ++ if (debug) logger.info("Received profile: " + this.field_147337_i.getName()); if (this.field_147327_f.isServerInOnlineMode() && !this.field_147333_a.isLocalChannel()) { - this.field_147328_g = NetHandlerLoginServer.LoginState.KEY; ++ if (debug) logger.info("Send encryption request to " + this.field_147337_i.getName()); + this.field_147328_g = LoginState.KEY; this.field_147333_a.scheduleOutboundPacket(new S01PacketEncryptionRequest(this.field_147334_j, this.field_147327_f.getKeyPair().getPublic(), this.field_147330_e), new GenericFutureListener[0]); } else { - this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; ++ if (debug) logger.info("Lookup offline UUID for " + this.field_147337_i.getName()); + (new ThreadPlayerLookupUUID(this, "User Authenticator #" + field_147331_b.incrementAndGet())).start(); // Spigot } } @@ -146,7 +170,11 @@ PrivateKey privatekey = this.field_147327_f.getKeyPair().getPrivate(); if (!Arrays.equals(this.field_147330_e, p_147315_1_.func_149299_b(privatekey))) -@@ -148,51 +188,7 @@ +@@ -145,54 +187,12 @@ + } + else + { ++ if (debug) logger.info("Enabling encryption for " + this.field_147337_i.getName()); this.field_147335_k = p_147315_1_.func_149300_a(privatekey); this.field_147328_g = NetHandlerLoginServer.LoginState.AUTHENTICATING; this.field_147333_a.enableEncryption(this.field_147335_k); @@ -195,11 +223,12 @@ - } - } - }).start(); ++ if (debug) logger.info("Lookup online UUID for " + this.field_147337_i.getName()); + (new ThreadPlayerLookupUUID(this, "User Authenticator #" + field_147331_b.incrementAndGet())).start(); } } -@@ -202,6 +198,37 @@ +@@ -202,6 +202,38 @@ return new GameProfile(uuid, p_152506_1_.getName()); } @@ -217,6 +246,7 @@ + } + + static GameProfile processPlayerLoginGameProfile(NetHandlerLoginServer loginServer, GameProfile gameprofile) { ++ if (loginServer.debug) logger.info("Player logged in: " + gameprofile); + return loginServer.field_147337_i = gameprofile; + } + diff --git a/src/main/java/net/minecraft/server/network/ThreadPlayerLookupUUID.java b/src/main/java/net/minecraft/server/network/ThreadPlayerLookupUUID.java index 206c259..5f43d99 100644 --- a/src/main/java/net/minecraft/server/network/ThreadPlayerLookupUUID.java +++ b/src/main/java/net/minecraft/server/network/ThreadPlayerLookupUUID.java @@ -42,10 +42,9 @@ class ThreadPlayerLookupUUID extends Thread } // Spigot End String s = (new BigInteger(CryptManager.getServerIdHash(NetHandlerLoginServer.getLoginServerId(this.field_151292_a), this.mcServer.getKeyPair().getPublic(), NetHandlerLoginServer.getSecretKey(this.field_151292_a)))).toString(16); - NetHandlerLoginServer.processPlayerLoginGameProfile(this.field_151292_a, this.mcServer.func_147130_as().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s)); - - if (NetHandlerLoginServer.getGameProfile(this.field_151292_a) != null) - { + GameProfile profile = this.mcServer.func_147130_as().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s); + if (profile != null) { + NetHandlerLoginServer.processPlayerLoginGameProfile(this.field_151292_a, profile); fireLoginEvents(); // Spigot } else if (this.mcServer.isSinglePlayer()) diff --git a/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java b/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java index 3c10b53..ff4b116 100644 --- a/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java +++ b/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java @@ -35,6 +35,7 @@ public class CauldronConfig extends ConfigBase public final BoolSetting logEntitySpeedRemoval = new BoolSetting(this, "logging.entity-speed-removal", false, "Whether to log entity removals due to speed"); public final IntSetting largeCollisionLogSize = new IntSetting(this, "logging.collision-warn-size", 200, "Number of colliding entities in one spot before logging a warning. Set to 0 to disable"); public final IntSetting largeEntityCountLogSize = new IntSetting(this, "logging.entity-count-warn-size", 0, "Number of entities in one dimension logging a warning. Set to 0 to disable"); + public final BoolSetting userLogin = new BoolSetting(this, "logging.user-login", false, "Set true to enable debuggin user's login process"); // General settings public final BoolSetting loadChunkOnRequest = new BoolSetting(this, "settings.load-chunk-on-request", true, "Forces Chunk Loading on 'Provide' requests (speedup for mods that don't check if a chunk is loaded"); @@ -93,6 +94,7 @@ public class CauldronConfig extends ConfigBase settings.put(flowingLavaDecay.path, flowingLavaDecay); settings.put(fakePlayerLogin.path, fakePlayerLogin); settings.put(remapPluginFile.path, remapPluginFile); + settings.put(userLogin.path, userLogin); load(); }