mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-03-30 21:18:17 +03:00
[FIX] Small fixes
This commit is contained in:
parent
e36cfea4f9
commit
0c281ab50d
12 changed files with 105 additions and 9 deletions
|
@ -10,6 +10,7 @@
|
||||||
import pro.gravit.launcher.modules.events.ClosePhase;
|
import pro.gravit.launcher.modules.events.ClosePhase;
|
||||||
import pro.gravit.launcher.profiles.ClientProfile;
|
import pro.gravit.launcher.profiles.ClientProfile;
|
||||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||||
|
import pro.gravit.launchserver.auth.core.RejectAuthCoreProvider;
|
||||||
import pro.gravit.launchserver.auth.session.MemorySessionStorage;
|
import pro.gravit.launchserver.auth.session.MemorySessionStorage;
|
||||||
import pro.gravit.launchserver.binary.EXEL4JLauncherBinary;
|
import pro.gravit.launchserver.binary.EXEL4JLauncherBinary;
|
||||||
import pro.gravit.launchserver.binary.EXELauncherBinary;
|
import pro.gravit.launchserver.binary.EXELauncherBinary;
|
||||||
|
@ -239,7 +240,7 @@ public void reload(ReloadType type) throws Exception {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Command> getCommands() {
|
public Map<String, Command> getCommands() {
|
||||||
Map<String, Command> commands = new HashMap<>();
|
Map<String, Command> commands = new HashMap<>();
|
||||||
SubCommand reload = new SubCommand() {
|
SubCommand reload = new SubCommand("[type]", "reload launchserver config") {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) throws Exception {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
|
@ -263,7 +264,7 @@ public void invoke(String... args) throws Exception {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
commands.put("reload", reload);
|
commands.put("reload", reload);
|
||||||
SubCommand save = new SubCommand() {
|
SubCommand save = new SubCommand("[]", "save launchserver config") {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) throws Exception {
|
||||||
launchServerConfigManager.writeConfig(config);
|
launchServerConfigManager.writeConfig(config);
|
||||||
|
@ -272,6 +273,28 @@ public void invoke(String... args) throws Exception {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
commands.put("save", save);
|
commands.put("save", save);
|
||||||
|
LaunchServer instance = this;
|
||||||
|
SubCommand resetauth = new SubCommand("authId", "reset auth by id") {
|
||||||
|
@Override
|
||||||
|
public void invoke(String... args) throws Exception {
|
||||||
|
verifyArgs(args, 1);
|
||||||
|
AuthProviderPair pair = config.getAuthProviderPair(args[0]);
|
||||||
|
if(pair == null) {
|
||||||
|
logger.error("Pair not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(pair.isUseCore()){
|
||||||
|
pair.core.close();
|
||||||
|
} else {
|
||||||
|
pair.provider.close();
|
||||||
|
pair.handler.close();
|
||||||
|
pair.handler = null;
|
||||||
|
pair.provider = null;
|
||||||
|
}
|
||||||
|
pair.core = new RejectAuthCoreProvider();
|
||||||
|
pair.core.init(instance);
|
||||||
|
}
|
||||||
|
};commands.put("resetauth", resetauth);
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,15 @@ public String getAccessToken() {
|
||||||
public ClientPermissions getPermissions() {
|
public ClientPermissions getPermissions() {
|
||||||
return permissions;
|
return permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "JsonUser{" +
|
||||||
|
"username='" + username + '\'' +
|
||||||
|
", uuid=" + uuid +
|
||||||
|
", permissions=" + permissions +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class JsonUserSession implements UserSession {
|
public static class JsonUserSession implements UserSession {
|
||||||
|
@ -300,6 +309,15 @@ public User getUser() {
|
||||||
public long getExpireIn() {
|
public long getExpireIn() {
|
||||||
return expireIn;
|
return expireIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "JsonUserSession{" +
|
||||||
|
"id='" + id + '\'' +
|
||||||
|
"user='" + (user == null ? null : user.getUsername()) + '\'' +
|
||||||
|
", expireIn=" + expireIn +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T, R> R jsonRequest(T request, String url, Class<R> clazz) {
|
public <T, R> R jsonRequest(T request, String url, Class<R> clazz) {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -453,6 +454,16 @@ public UserHardware getHardware() {
|
||||||
hardware = result;
|
hardware = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MySQLUser{" +
|
||||||
|
"uuid=" + uuid +
|
||||||
|
", username='" + username + '\'' +
|
||||||
|
", permissions=" + permissions +
|
||||||
|
", hwidId=" + hwidId +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MySQLUserHardware implements UserHardware {
|
public static class MySQLUserHardware implements UserHardware {
|
||||||
|
@ -487,5 +498,15 @@ public String getId() {
|
||||||
public boolean isBanned() {
|
public boolean isBanned() {
|
||||||
return banned;
|
return banned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MySQLUserHardware{" +
|
||||||
|
"hardwareInfo=" + hardwareInfo +
|
||||||
|
", publicKey=" + (publicKey == null ? null : SecurityHelper.toHex(publicKey)) +
|
||||||
|
", id=" + id +
|
||||||
|
", banned=" + banned +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
public class JsonPasswordVerifier extends PasswordVerifier {
|
public class JsonPasswordVerifier extends PasswordVerifier {
|
||||||
public String url;
|
public String url;
|
||||||
public String bearerToken;
|
public String bearerToken;
|
||||||
private transient HttpClient client = HttpClient.newBuilder().build();
|
private transient final HttpClient client = HttpClient.newBuilder().build();
|
||||||
|
|
||||||
public static class JsonPasswordRequest {
|
public static class JsonPasswordRequest {
|
||||||
public String encryptedPassword;
|
public String encryptedPassword;
|
||||||
|
|
|
@ -35,7 +35,7 @@ public void invoke(String... args) throws Exception {
|
||||||
if (args.length > 2) pair = server.config.getAuthProviderPair(args[2]);
|
if (args.length > 2) pair = server.config.getAuthProviderPair(args[2]);
|
||||||
else pair = server.config.getAuthProviderPair();
|
else pair = server.config.getAuthProviderPair();
|
||||||
if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[1]));
|
if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[1]));
|
||||||
|
if(pair.isUseCore()) throw new UnsupportedOperationException(String.format("Please use `config auth.%s.core COMMAND ARGS`", pair.name));
|
||||||
String login = args[0];
|
String login = args[0];
|
||||||
String password = args[1];
|
String password = args[1];
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public void invoke(String... args) throws CommandException, IOException {
|
||||||
if (args.length > 1) pair = server.config.getAuthProviderPair(args[1]);
|
if (args.length > 1) pair = server.config.getAuthProviderPair(args[1]);
|
||||||
else pair = server.config.getAuthProviderPair();
|
else pair = server.config.getAuthProviderPair();
|
||||||
if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[1]));
|
if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[1]));
|
||||||
|
if(pair.isUseCore()) throw new UnsupportedOperationException(String.format("Please use `config auth.%s.core COMMAND ARGS`", pair.name));
|
||||||
UUID uuid = parseUUID(args[0]);
|
UUID uuid = parseUUID(args[0]);
|
||||||
|
|
||||||
// Get UUID by username
|
// Get UUID by username
|
||||||
|
|
|
@ -34,6 +34,7 @@ public void invoke(String... args) throws CommandException, IOException {
|
||||||
if (args.length > 1) pair = server.config.getAuthProviderPair(args[1]);
|
if (args.length > 1) pair = server.config.getAuthProviderPair(args[1]);
|
||||||
else pair = server.config.getAuthProviderPair();
|
else pair = server.config.getAuthProviderPair();
|
||||||
if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[1]));
|
if (pair == null) throw new IllegalStateException(String.format("Auth %s not found", args[1]));
|
||||||
|
if(pair.isUseCore()) throw new UnsupportedOperationException(String.format("Please use `config auth.%s.core COMMAND ARGS`", pair.name));
|
||||||
String username = parseUsername(args[0]);
|
String username = parseUsername(args[0]);
|
||||||
|
|
||||||
// Get UUID by username
|
// Get UUID by username
|
||||||
|
|
|
@ -150,7 +150,7 @@ public static MakeProfileOption[] getMakeProfileOptionsFromDir(Path dir, ClientP
|
||||||
if (Files.exists(dir.resolve("liteloader.jar"))) {
|
if (Files.exists(dir.resolve("liteloader.jar"))) {
|
||||||
options.add(MakeProfileOption.LITELOADER);
|
options.add(MakeProfileOption.LITELOADER);
|
||||||
}
|
}
|
||||||
if (Files.exists(dir.resolve("libraries/libraries/org/lwjgl/lwjgl/3.2.2")) && Files.exists(dir.resolve("libraries/libraries/org/lwjgl/lwjgl/3.2.1"))) {
|
if (Files.exists(dir.resolve("libraries/org/lwjgl/lwjgl/3.2.2")) && Files.exists(dir.resolve("libraries/org/lwjgl/lwjgl/3.2.1"))) {
|
||||||
options.add(MakeProfileOption.LWJGLMAC);
|
options.add(MakeProfileOption.LWJGLMAC);
|
||||||
}
|
}
|
||||||
if (version.compareTo(ClientProfile.Version.MC1122) <= 0) {
|
if (version.compareTo(ClientProfile.Version.MC1122) <= 0) {
|
||||||
|
|
|
@ -64,6 +64,9 @@ public void invoke(String... args) {
|
||||||
} else {
|
} else {
|
||||||
printCheckResult(String.format("auth.%s.handler", name), "", true);
|
printCheckResult(String.format("auth.%s.handler", name), "", true);
|
||||||
}
|
}
|
||||||
|
if(!pair.isUseCore()) {
|
||||||
|
printCheckResult(String.format("auth.%s", name), "AuthProvider/AuthHandler may be removed in future release", null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (config.protectHandler instanceof NoProtectHandler) {
|
if (config.protectHandler instanceof NoProtectHandler) {
|
||||||
printCheckResult("protectHandler", "protectHandler none", false);
|
printCheckResult("protectHandler", "protectHandler none", false);
|
||||||
|
@ -220,8 +223,8 @@ public void invoke(String... args) {
|
||||||
if (checkOtherWriteAccess(IOHelper.getCodeSource(LaunchServer.class))) {
|
if (checkOtherWriteAccess(IOHelper.getCodeSource(LaunchServer.class))) {
|
||||||
logger.warn("Write access to LaunchServer.jar. Please use 'chmod 755 LaunchServer.jar'");
|
logger.warn("Write access to LaunchServer.jar. Please use 'chmod 755 LaunchServer.jar'");
|
||||||
}
|
}
|
||||||
if (Files.exists(server.dir.resolve("private.key")) && checkOtherReadOrWriteAccess(server.dir.resolve("private.key"))) {
|
if (Files.exists(server.dir.resolve(".keys")) && checkOtherReadOrWriteAccess(server.dir.resolve(".keys"))) {
|
||||||
logger.warn("Write or read access to private.key. Please use 'chmod 600 private.key'");
|
logger.warn("Write or read access to .keys directory. Please use 'chmod -R 600 .keys'");
|
||||||
}
|
}
|
||||||
if (Files.exists(server.dir.resolve("LaunchServerConfig.json")) && checkOtherReadOrWriteAccess(server.dir.resolve("LaunchServerConfig.json"))) {
|
if (Files.exists(server.dir.resolve("LaunchServerConfig.json")) && checkOtherReadOrWriteAccess(server.dir.resolve("LaunchServerConfig.json"))) {
|
||||||
logger.warn("Write or read access to LaunchServerConfig.json. Please use 'chmod 600 LaunchServerConfig.json'");
|
logger.warn("Write or read access to LaunchServerConfig.json. Please use 'chmod 600 LaunchServerConfig.json'");
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package pro.gravit.launcher;
|
package pro.gravit.launcher;
|
||||||
|
|
||||||
import pro.gravit.launcher.events.ExtendedTokenRequestEvent;
|
import pro.gravit.launcher.events.ExtendedTokenRequestEvent;
|
||||||
|
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||||
|
import pro.gravit.launcher.events.request.ErrorRequestEvent;
|
||||||
import pro.gravit.launcher.events.request.SecurityReportRequestEvent;
|
import pro.gravit.launcher.events.request.SecurityReportRequestEvent;
|
||||||
import pro.gravit.launcher.request.Request;
|
import pro.gravit.launcher.request.Request;
|
||||||
import pro.gravit.launcher.request.WebSocketEvent;
|
import pro.gravit.launcher.request.WebSocketEvent;
|
||||||
import pro.gravit.launcher.request.websockets.ClientWebSocketService;
|
import pro.gravit.launcher.request.websockets.ClientWebSocketService;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class BasicLauncherEventHandler implements ClientWebSocketService.EventHandler {
|
public class BasicLauncherEventHandler implements ClientWebSocketService.EventHandler {
|
||||||
|
|
||||||
|
@ -15,8 +18,15 @@ public <T extends WebSocketEvent> boolean eventHandle(T event) {
|
||||||
if (event1.action == SecurityReportRequestEvent.ReportAction.CRASH) {
|
if (event1.action == SecurityReportRequestEvent.ReportAction.CRASH) {
|
||||||
LauncherEngine.exitLauncher(80);
|
LauncherEngine.exitLauncher(80);
|
||||||
}
|
}
|
||||||
|
else if(event1.action == SecurityReportRequestEvent.ReportAction.TOKEN_EXPIRED) {
|
||||||
|
try {
|
||||||
|
Request.restore();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogHelper.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (event instanceof ExtendedTokenRequestEvent) {
|
else if (event instanceof ExtendedTokenRequestEvent) {
|
||||||
ExtendedTokenRequestEvent event1 = (ExtendedTokenRequestEvent) event;
|
ExtendedTokenRequestEvent event1 = (ExtendedTokenRequestEvent) event;
|
||||||
String token = event1.getExtendedToken();
|
String token = event1.getExtendedToken();
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ public String getType() {
|
||||||
public enum ReportAction {
|
public enum ReportAction {
|
||||||
NONE,
|
NONE,
|
||||||
LOGOUT,
|
LOGOUT,
|
||||||
|
TOKEN_EXPIRED,
|
||||||
EXIT,
|
EXIT,
|
||||||
CRASH,
|
CRASH,
|
||||||
OTHER
|
OTHER
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
import pro.gravit.launcher.events.request.HardwareReportRequestEvent;
|
import pro.gravit.launcher.events.request.HardwareReportRequestEvent;
|
||||||
import pro.gravit.launcher.request.Request;
|
import pro.gravit.launcher.request.Request;
|
||||||
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class HardwareReportRequest extends Request<HardwareReportRequestEvent> {
|
public class HardwareReportRequest extends Request<HardwareReportRequestEvent> {
|
||||||
public HardwareInfo hardware;
|
public HardwareInfo hardware;
|
||||||
|
@ -22,5 +25,21 @@ public static class HardwareInfo {
|
||||||
public byte[] displayId;
|
public byte[] displayId;
|
||||||
public String baseboardSerialNumber;
|
public String baseboardSerialNumber;
|
||||||
public String graphicCard;
|
public String graphicCard;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "HardwareInfo{" +
|
||||||
|
"bitness=" + bitness +
|
||||||
|
", totalMemory=" + totalMemory +
|
||||||
|
", logicalProcessors=" + logicalProcessors +
|
||||||
|
", physicalProcessors=" + physicalProcessors +
|
||||||
|
", processorMaxFreq=" + processorMaxFreq +
|
||||||
|
", battery=" + battery +
|
||||||
|
", hwDiskId='" + hwDiskId + '\'' +
|
||||||
|
", displayId=" + (displayId == null ? null : SecurityHelper.toHex(displayId)) +
|
||||||
|
", baseboardSerialNumber='" + baseboardSerialNumber + '\'' +
|
||||||
|
", graphicCard='" + graphicCard + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue