forked from xjboss/KCauldronX
Add logs for user login process
This commit is contained in:
parent
480506629d
commit
72ee9c24f6
@ -1,29 +1,46 @@
|
|||||||
--- ../src-base/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java
|
--- ../src-base/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java
|
||||||
+++ ../src-work/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.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
+
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
+
|
+
|
||||||
import net.minecraft.network.EnumConnectionState;
|
import net.minecraft.network.EnumConnectionState;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.login.INetHandlerLoginServer;
|
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.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import net.minecraft.entity.player.EntityPlayerMP;
|
+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
|
+// CraftBukkit end
|
||||||
+import com.mojang.authlib.properties.Property;
|
+import com.mojang.authlib.properties.Property;
|
||||||
+
|
+
|
||||||
public class NetHandlerLoginServer implements INetHandlerLoginServer
|
public class NetHandlerLoginServer implements INetHandlerLoginServer
|
||||||
{
|
{
|
||||||
private static final AtomicInteger field_147331_b = new AtomicInteger(0);
|
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 byte[] field_147330_e = new byte[4];
|
||||||
private final MinecraftServer field_147327_f;
|
private final MinecraftServer field_147327_f;
|
||||||
public final NetworkManager field_147333_a;
|
public final NetworkManager field_147333_a;
|
||||||
@ -35,6 +52,7 @@
|
|||||||
private SecretKey field_147335_k;
|
private SecretKey field_147335_k;
|
||||||
+ public String hostname = ""; // CraftBukkit - add field
|
+ public String hostname = ""; // CraftBukkit - add field
|
||||||
private static final String __OBFID = "CL_00001458";
|
private static final String __OBFID = "CL_00001458";
|
||||||
|
+ private final boolean debug;
|
||||||
|
|
||||||
public NetHandlerLoginServer(MinecraftServer p_i45298_1_, NetworkManager p_i45298_2_)
|
public NetHandlerLoginServer(MinecraftServer p_i45298_1_, NetworkManager p_i45298_2_)
|
||||||
{
|
{
|
||||||
@ -43,7 +61,9 @@
|
|||||||
this.field_147334_j = "";
|
this.field_147334_j = "";
|
||||||
this.field_147327_f = p_i45298_1_;
|
this.field_147327_f = p_i45298_1_;
|
||||||
this.field_147333_a = p_i45298_2_;
|
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()
|
public void onNetworkTick()
|
||||||
{
|
{
|
||||||
@ -52,7 +72,7 @@
|
|||||||
{
|
{
|
||||||
this.func_147326_c();
|
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_)
|
public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_)
|
||||||
{
|
{
|
||||||
@ -123,18 +143,22 @@
|
|||||||
public void processLoginStart(C00PacketLoginStart p_147316_1_)
|
public void processLoginStart(C00PacketLoginStart p_147316_1_)
|
||||||
{
|
{
|
||||||
- Validate.validState(this.field_147328_g == NetHandlerLoginServer.LoginState.HELLO, "Unexpected hello packet", new Object[0]);
|
- 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]);
|
+ Validate.validState(this.field_147328_g == LoginState.HELLO, "Unexpected hello packet", new Object[0]);
|
||||||
this.field_147337_i = p_147316_1_.func_149304_c();
|
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())
|
if (this.field_147327_f.isServerInOnlineMode() && !this.field_147333_a.isLocalChannel())
|
||||||
{
|
{
|
||||||
- this.field_147328_g = NetHandlerLoginServer.LoginState.KEY;
|
- 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_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]);
|
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
|
else
|
||||||
{
|
{
|
||||||
- this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT;
|
- 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
|
+ (new ThreadPlayerLookupUUID(this, "User Authenticator #" + field_147331_b.incrementAndGet())).start(); // Spigot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +170,11 @@
|
|||||||
PrivateKey privatekey = this.field_147327_f.getKeyPair().getPrivate();
|
PrivateKey privatekey = this.field_147327_f.getKeyPair().getPrivate();
|
||||||
|
|
||||||
if (!Arrays.equals(this.field_147330_e, p_147315_1_.func_149299_b(privatekey)))
|
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_147335_k = p_147315_1_.func_149300_a(privatekey);
|
||||||
this.field_147328_g = NetHandlerLoginServer.LoginState.AUTHENTICATING;
|
this.field_147328_g = NetHandlerLoginServer.LoginState.AUTHENTICATING;
|
||||||
this.field_147333_a.enableEncryption(this.field_147335_k);
|
this.field_147333_a.enableEncryption(this.field_147335_k);
|
||||||
@ -195,11 +223,12 @@
|
|||||||
- }
|
- }
|
||||||
- }
|
- }
|
||||||
- }).start();
|
- }).start();
|
||||||
|
+ if (debug) logger.info("Lookup online UUID for " + this.field_147337_i.getName());
|
||||||
+ (new ThreadPlayerLookupUUID(this, "User Authenticator #" + field_147331_b.incrementAndGet())).start();
|
+ (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());
|
return new GameProfile(uuid, p_152506_1_.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +246,7 @@
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ static GameProfile processPlayerLoginGameProfile(NetHandlerLoginServer loginServer, GameProfile gameprofile) {
|
+ static GameProfile processPlayerLoginGameProfile(NetHandlerLoginServer loginServer, GameProfile gameprofile) {
|
||||||
|
+ if (loginServer.debug) logger.info("Player logged in: " + gameprofile);
|
||||||
+ return loginServer.field_147337_i = gameprofile;
|
+ return loginServer.field_147337_i = gameprofile;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -42,10 +42,9 @@ class ThreadPlayerLookupUUID extends Thread
|
|||||||
}
|
}
|
||||||
// Spigot End
|
// 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);
|
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));
|
GameProfile profile = this.mcServer.func_147130_as().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s);
|
||||||
|
if (profile != null) {
|
||||||
if (NetHandlerLoginServer.getGameProfile(this.field_151292_a) != null)
|
NetHandlerLoginServer.processPlayerLoginGameProfile(this.field_151292_a, profile);
|
||||||
{
|
|
||||||
fireLoginEvents(); // Spigot
|
fireLoginEvents(); // Spigot
|
||||||
}
|
}
|
||||||
else if (this.mcServer.isSinglePlayer())
|
else if (this.mcServer.isSinglePlayer())
|
||||||
|
@ -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 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 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 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
|
// 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");
|
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(flowingLavaDecay.path, flowingLavaDecay);
|
||||||
settings.put(fakePlayerLogin.path, fakePlayerLogin);
|
settings.put(fakePlayerLogin.path, fakePlayerLogin);
|
||||||
settings.put(remapPluginFile.path, remapPluginFile);
|
settings.put(remapPluginFile.path, remapPluginFile);
|
||||||
|
settings.put(userLogin.path, userLogin);
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user