mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +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.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.auth.core.RejectAuthCoreProvider;
|
||||
import pro.gravit.launchserver.auth.session.MemorySessionStorage;
|
||||
import pro.gravit.launchserver.binary.EXEL4JLauncherBinary;
|
||||
import pro.gravit.launchserver.binary.EXELauncherBinary;
|
||||
|
@ -239,7 +240,7 @@ public void reload(ReloadType type) throws Exception {
|
|||
@Override
|
||||
public Map<String, Command> getCommands() {
|
||||
Map<String, Command> commands = new HashMap<>();
|
||||
SubCommand reload = new SubCommand() {
|
||||
SubCommand reload = new SubCommand("[type]", "reload launchserver config") {
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
|
@ -263,7 +264,7 @@ public void invoke(String... args) throws Exception {
|
|||
}
|
||||
};
|
||||
commands.put("reload", reload);
|
||||
SubCommand save = new SubCommand() {
|
||||
SubCommand save = new SubCommand("[]", "save launchserver config") {
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
launchServerConfigManager.writeConfig(config);
|
||||
|
@ -272,6 +273,28 @@ public void invoke(String... args) throws Exception {
|
|||
}
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -279,6 +279,15 @@ public String getAccessToken() {
|
|||
public ClientPermissions getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JsonUser{" +
|
||||
"username='" + username + '\'' +
|
||||
", uuid=" + uuid +
|
||||
", permissions=" + permissions +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
public static class JsonUserSession implements UserSession {
|
||||
|
@ -300,6 +309,15 @@ public User getUser() {
|
|||
public long getExpireIn() {
|
||||
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) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -453,6 +454,16 @@ public UserHardware getHardware() {
|
|||
hardware = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MySQLUser{" +
|
||||
"uuid=" + uuid +
|
||||
", username='" + username + '\'' +
|
||||
", permissions=" + permissions +
|
||||
", hwidId=" + hwidId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
public static class MySQLUserHardware implements UserHardware {
|
||||
|
@ -487,5 +498,15 @@ public String getId() {
|
|||
public boolean isBanned() {
|
||||
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 String url;
|
||||
public String bearerToken;
|
||||
private transient HttpClient client = HttpClient.newBuilder().build();
|
||||
private transient final HttpClient client = HttpClient.newBuilder().build();
|
||||
|
||||
public static class JsonPasswordRequest {
|
||||
public String encryptedPassword;
|
||||
|
|
|
@ -35,7 +35,7 @@ public void invoke(String... args) throws Exception {
|
|||
if (args.length > 2) pair = server.config.getAuthProviderPair(args[2]);
|
||||
else pair = server.config.getAuthProviderPair();
|
||||
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 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]);
|
||||
else pair = server.config.getAuthProviderPair();
|
||||
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]);
|
||||
|
||||
// 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]);
|
||||
else pair = server.config.getAuthProviderPair();
|
||||
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]);
|
||||
|
||||
// Get UUID by username
|
||||
|
|
|
@ -150,7 +150,7 @@ public static MakeProfileOption[] getMakeProfileOptionsFromDir(Path dir, ClientP
|
|||
if (Files.exists(dir.resolve("liteloader.jar"))) {
|
||||
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);
|
||||
}
|
||||
if (version.compareTo(ClientProfile.Version.MC1122) <= 0) {
|
||||
|
|
|
@ -64,6 +64,9 @@ public void invoke(String... args) {
|
|||
} else {
|
||||
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) {
|
||||
printCheckResult("protectHandler", "protectHandler none", false);
|
||||
|
@ -220,8 +223,8 @@ public void invoke(String... args) {
|
|||
if (checkOtherWriteAccess(IOHelper.getCodeSource(LaunchServer.class))) {
|
||||
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"))) {
|
||||
logger.warn("Write or read access to private.key. Please use 'chmod 600 private.key'");
|
||||
if (Files.exists(server.dir.resolve(".keys")) && checkOtherReadOrWriteAccess(server.dir.resolve(".keys"))) {
|
||||
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"))) {
|
||||
logger.warn("Write or read access to LaunchServerConfig.json. Please use 'chmod 600 LaunchServerConfig.json'");
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package pro.gravit.launcher;
|
||||
|
||||
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.request.Request;
|
||||
import pro.gravit.launcher.request.WebSocketEvent;
|
||||
import pro.gravit.launcher.request.websockets.ClientWebSocketService;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class BasicLauncherEventHandler implements ClientWebSocketService.EventHandler {
|
||||
|
||||
|
@ -15,8 +18,15 @@ public <T extends WebSocketEvent> boolean eventHandle(T event) {
|
|||
if (event1.action == SecurityReportRequestEvent.ReportAction.CRASH) {
|
||||
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;
|
||||
String token = event1.getExtendedToken();
|
||||
if (token != null) {
|
||||
|
|
|
@ -29,6 +29,7 @@ public String getType() {
|
|||
public enum ReportAction {
|
||||
NONE,
|
||||
LOGOUT,
|
||||
TOKEN_EXPIRED,
|
||||
EXIT,
|
||||
CRASH,
|
||||
OTHER
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
import pro.gravit.launcher.events.request.HardwareReportRequestEvent;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class HardwareReportRequest extends Request<HardwareReportRequestEvent> {
|
||||
public HardwareInfo hardware;
|
||||
|
@ -22,5 +25,21 @@ public static class HardwareInfo {
|
|||
public byte[] displayId;
|
||||
public String baseboardSerialNumber;
|
||||
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