mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] Потенциальные NPE
This commit is contained in:
parent
32d7ca932a
commit
438133bce7
4 changed files with 26 additions and 5 deletions
|
@ -57,6 +57,13 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
|
||||||
throw new AuthException("Password decryption error");
|
throw new AuthException("Password decryption error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(clientData.isAuth) {
|
||||||
|
if(LogHelper.isDevEnabled()) {
|
||||||
|
LogHelper.warning("Client %s double auth", clientData.username == null ? ip : clientData.username);
|
||||||
|
}
|
||||||
|
sendError("You are already logged in");
|
||||||
|
return;
|
||||||
|
}
|
||||||
AuthProviderPair pair;
|
AuthProviderPair pair;
|
||||||
if (auth_id == null || auth_id.isEmpty()) pair = server.config.getAuthProviderPair();
|
if (auth_id == null || auth_id.isEmpty()) pair = server.config.getAuthProviderPair();
|
||||||
else pair = server.config.getAuthProviderPair(auth_id);
|
else pair = server.config.getAuthProviderPair(auth_id);
|
||||||
|
|
|
@ -25,6 +25,10 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
sendError("Permissions denied");
|
sendError("Permissions denied");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(username == null || accessToken == null || serverID == null) {
|
||||||
|
sendError("Invalid request");
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean success;
|
boolean success;
|
||||||
try {
|
try {
|
||||||
server.authHookManager.joinServerHook.hook(this, client);
|
server.authHookManager.joinServerHook.hook(this, client);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent;
|
import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent;
|
||||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||||
|
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||||
import pro.gravit.launchserver.socket.Client;
|
import pro.gravit.launchserver.socket.Client;
|
||||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
@ -20,14 +21,19 @@ public String getType() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||||
BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent();
|
BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent();
|
||||||
|
if(list == null) {
|
||||||
|
sendError("Invalid request");
|
||||||
|
return;
|
||||||
|
}
|
||||||
result.playerProfiles = new PlayerProfile[list.length];
|
result.playerProfiles = new PlayerProfile[list.length];
|
||||||
for (int i = 0; i < list.length; ++i) {
|
for (int i = 0; i < list.length; ++i) {
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
if (client.auth == null) {
|
AuthProviderPair pair = client.auth;
|
||||||
LogHelper.warning("Client auth is null. Using default.");
|
if (pair == null) {
|
||||||
uuid = server.config.getAuthProviderPair().handler.usernameToUUID(list[i].username);
|
pair = server.config.getAuthProviderPair();
|
||||||
} else uuid = client.auth.handler.usernameToUUID(list[i].username);
|
}
|
||||||
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(uuid, list[i].username, list[i].client, client.auth.textureProvider);
|
uuid = pair.handler.usernameToUUID(list[i].username);
|
||||||
|
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(uuid, list[i].username, list[i].client, pair.textureProvider);
|
||||||
}
|
}
|
||||||
sendResult(result);
|
sendResult(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,10 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
sendError("Access denied");
|
sendError("Access denied");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(dirName == null) {
|
||||||
|
sendError("Invalid request");
|
||||||
|
return;
|
||||||
|
}
|
||||||
HashedDir dir = server.updatesDirMap.get(dirName);
|
HashedDir dir = server.updatesDirMap.get(dirName);
|
||||||
if (dir == null) {
|
if (dir == null) {
|
||||||
sendError(String.format("Directory %s not found", dirName));
|
sendError(String.format("Directory %s not found", dirName));
|
||||||
|
|
Loading…
Reference in a new issue