Merge branch 'release/v5.6.1'

This commit is contained in:
Gravita 2024-04-21 13:41:55 +07:00
commit 42cf9bc79e
19 changed files with 70 additions and 86 deletions

View file

@ -29,12 +29,12 @@ public void init(LaunchServer server) {
@Override @Override
public boolean canGetProfile(ClientProfile profile, Client client) { public boolean canGetProfile(ClientProfile profile, Client client) {
return !profile.isLimited() || isWhitelisted("launchserver.profile.%s.show", profile, client); return (client.isAuth && !profile.isLimited()) || isWhitelisted("launchserver.profile.%s.show", profile, client);
} }
@Override @Override
public boolean canChangeProfile(ClientProfile profile, Client client) { public boolean canChangeProfile(ClientProfile profile, Client client) {
return !profile.isLimited() || isWhitelisted("launchserver.profile.%s.enter", profile, client); return (client.isAuth && !profile.isLimited()) || isWhitelisted("launchserver.profile.%s.enter", profile, client);
} }
@Override @Override

View file

@ -31,6 +31,9 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar")); builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar"));
{ {
List<String> classPath = new ArrayList<>(5); List<String> classPath = new ArrayList<>(5);
if(findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent()) {
classPath.add("libraries/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar");
}
classPath.add("libraries"); classPath.add("libraries");
classPath.add("minecraft.jar"); classPath.add("minecraft.jar");
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) { if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) {

View file

@ -31,7 +31,6 @@
import pro.gravit.launchserver.socket.response.secure.SecurityReportResponse; import pro.gravit.launchserver.socket.response.secure.SecurityReportResponse;
import pro.gravit.launchserver.socket.response.secure.VerifySecureLevelKeyResponse; import pro.gravit.launchserver.socket.response.secure.VerifySecureLevelKeyResponse;
import pro.gravit.launchserver.socket.response.update.LauncherResponse; import pro.gravit.launchserver.socket.response.update.LauncherResponse;
import pro.gravit.launchserver.socket.response.update.UpdateListResponse;
import pro.gravit.launchserver.socket.response.update.UpdateResponse; import pro.gravit.launchserver.socket.response.update.UpdateResponse;
import pro.gravit.utils.BiHookSet; import pro.gravit.utils.BiHookSet;
import pro.gravit.utils.HookSet; import pro.gravit.utils.HookSet;
@ -74,7 +73,6 @@ public static void registerResponses() {
providers.register("joinServer", JoinServerResponse.class); providers.register("joinServer", JoinServerResponse.class);
providers.register("profiles", ProfilesResponse.class); providers.register("profiles", ProfilesResponse.class);
providers.register("launcher", LauncherResponse.class); providers.register("launcher", LauncherResponse.class);
providers.register("updateList", UpdateListResponse.class);
providers.register("setProfile", SetProfileResponse.class); providers.register("setProfile", SetProfileResponse.class);
providers.register("update", UpdateResponse.class); providers.register("update", UpdateResponse.class);
providers.register("batchProfileByUsername", BatchProfileByUsername.class); providers.register("batchProfileByUsername", BatchProfileByUsername.class);

View file

@ -1,27 +0,0 @@
package pro.gravit.launchserver.socket.response.update;
import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.base.events.request.UpdateListRequestEvent;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse;
import java.util.HashSet;
public class UpdateListResponse extends SimpleResponse {
@Override
public String getType() {
return "updateList";
}
@Override
public void execute(ChannelHandlerContext ctx, Client client) {
if (!client.isAuth) {
sendError("Access denied");
return;
}
HashSet<String> set = server.updatesManager.getUpdatesList();
sendResult(new UpdateListRequestEvent(set));
}
}

View file

@ -16,7 +16,7 @@
-keeppackagenames com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.runtime.api.**, pro.gravit.launcher.base.api.**, pro.gravit.launcher.client.api.**, pro.gravit.utils.**, pro.gravit.launcher.base.request.**, pro.gravit.launcher.base.events.**, pro.gravit.launcher.base.profiles.** -keeppackagenames com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.runtime.api.**, pro.gravit.launcher.base.api.**, pro.gravit.launcher.client.api.**, pro.gravit.utils.**, pro.gravit.launcher.base.request.**, pro.gravit.launcher.base.events.**, pro.gravit.launcher.base.profiles.**
-keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.client.api.**, pro.gravit.utils.**, pro.gravit.launcher.base.request.**, pro.gravit.launcher.base.events.**, pro.gravit.launcher.base.profiles.**, pro.gravit.launcher.runtime.LauncherEngineWrapper { -keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.client.api.**, pro.gravit.launcher.base.api.**, pro.gravit.utils.**, pro.gravit.launcher.base.request.**, pro.gravit.launcher.base.events.**, pro.gravit.launcher.base.profiles.**, pro.gravit.launcher.runtime.LauncherEngineWrapper {
*; *;
} }

View file

@ -147,7 +147,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException {
if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.AGENT) { if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.AGENT) {
processArgs.add("-javaagent:".concat(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString())); processArgs.add("-javaagent:".concat(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString()));
} else if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) { } else if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) {
systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(workDir, params.actions, params.profile) systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(new HashSet<>(), workDir, params.actions, params.profile)
.filter(x -> !params.profile.getModulePath().contains(workDir.relativize(x).toString())) .filter(x -> !params.profile.getModulePath().contains(workDir.relativize(x).toString()))
.map(Path::toString) .map(Path::toString)
.toList()); .toList());

View file

@ -1,24 +0,0 @@
package pro.gravit.launcher.base.events.request;
import pro.gravit.launcher.core.LauncherNetworkAPI;
import pro.gravit.launcher.base.events.RequestEvent;
import java.util.HashSet;
import java.util.UUID;
public class UpdateListRequestEvent extends RequestEvent {
@SuppressWarnings("unused")
private static final UUID uuid = UUID.fromString("5fa836ae-6b61-401c-96ac-d8396f07ec6b");
@LauncherNetworkAPI
public final HashSet<String> dirs;
public UpdateListRequestEvent(HashSet<String> dirs) {
this.dirs = dirs;
}
@Override
public String getType() {
return "updateList";
}
}

View file

@ -3,10 +3,10 @@
import pro.gravit.launcher.base.request.auth.AuthRequest; import pro.gravit.launcher.base.request.auth.AuthRequest;
public class AuthCodePassword implements AuthRequest.AuthPasswordInterface { public class AuthCodePassword implements AuthRequest.AuthPasswordInterface {
public final String code; public final String uri;
public AuthCodePassword(String code) { public AuthCodePassword(String uri) {
this.code = code; this.uri = uri;
} }
@Override @Override

View file

@ -1,13 +0,0 @@
package pro.gravit.launcher.base.request.update;
import pro.gravit.launcher.base.events.request.UpdateListRequestEvent;
import pro.gravit.launcher.base.request.Request;
import pro.gravit.launcher.base.request.websockets.WebSocketRequest;
public final class UpdateListRequest extends Request<UpdateListRequestEvent> implements WebSocketRequest {
@Override
public String getType() {
return "updateList";
}
}

View file

@ -94,7 +94,6 @@ public void registerResults() {
results.register("batchProfileByUsername", BatchProfileByUsernameRequestEvent.class); results.register("batchProfileByUsername", BatchProfileByUsernameRequestEvent.class);
results.register("profiles", ProfilesRequestEvent.class); results.register("profiles", ProfilesRequestEvent.class);
results.register("setProfile", SetProfileRequestEvent.class); results.register("setProfile", SetProfileRequestEvent.class);
results.register("updateList", UpdateListRequestEvent.class);
results.register("error", ErrorRequestEvent.class); results.register("error", ErrorRequestEvent.class);
results.register("update", UpdateRequestEvent.class); results.register("update", UpdateRequestEvent.class);
results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class);

View file

@ -118,7 +118,8 @@ private static void realMain(String[] args) throws Throwable {
// Verify ClientLauncher sign and classpath // Verify ClientLauncher sign and classpath
LogHelper.debug("Verifying ClientLauncher sign and classpath"); LogHelper.debug("Verifying ClientLauncher sign and classpath");
List<Path> classpath = resolveClassPath(clientDir, params.actions, params.profile) Set<Path> ignoredPath = new HashSet<>();
List<Path> classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile)
.filter(x -> !profile.getModulePath().contains(clientDir.relativize(x).toString())) .filter(x -> !profile.getModulePath().contains(clientDir.relativize(x).toString()))
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
if(LogHelper.isDevEnabled()) { if(LogHelper.isDevEnabled()) {
@ -252,11 +253,11 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher,
} }
} }
private static LinkedList<Path> resolveClassPathList(Path clientDir, String... classPath) throws IOException { private static LinkedList<Path> resolveClassPathList(Set<Path> ignorePaths, Path clientDir, String... classPath) throws IOException {
return resolveClassPathStream(clientDir, classPath).collect(Collectors.toCollection(LinkedList::new)); return resolveClassPathStream(ignorePaths, clientDir, classPath).collect(Collectors.toCollection(LinkedList::new));
} }
private static Stream<Path> resolveClassPathStream(Path clientDir, String... classPath) throws IOException { private static Stream<Path> resolveClassPathStream(Set<Path> ignorePaths, Path clientDir, String... classPath) throws IOException {
Stream.Builder<Path> builder = Stream.builder(); Stream.Builder<Path> builder = Stream.builder();
for (String classPathEntry : classPath) { for (String classPathEntry : classPath) {
Path path = clientDir.resolve(IOHelper.toPath(classPathEntry.replace(IOHelper.CROSS_SEPARATOR, IOHelper.PLATFORM_SEPARATOR))); Path path = clientDir.resolve(IOHelper.toPath(classPathEntry.replace(IOHelper.CROSS_SEPARATOR, IOHelper.PLATFORM_SEPARATOR)));
@ -265,20 +266,28 @@ private static Stream<Path> resolveClassPathStream(Path clientDir, String... cla
IOHelper.walk(path, new ClassPathFileVisitor(jars), false); IOHelper.walk(path, new ClassPathFileVisitor(jars), false);
Collections.sort(jars); Collections.sort(jars);
for(var e : jars) { for(var e : jars) {
if(ignorePaths.contains(e)) {
continue;
}
builder.accept(e); builder.accept(e);
ignorePaths.add(e);
} }
continue; continue;
} }
if(ignorePaths.contains(path)) {
continue;
}
builder.accept(path); builder.accept(path);
ignorePaths.add(path);
} }
return builder.build(); return builder.build();
} }
public static Stream<Path> resolveClassPath(Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException { public static Stream<Path> resolveClassPath(Set<Path> ignorePaths, Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException {
Stream<Path> result = resolveClassPathStream(clientDir, profile.getClassPath()); Stream<Path> result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath());
for (OptionalAction a : actions) { for (OptionalAction a : actions) {
if (a instanceof OptionalActionClassPath) if (a instanceof OptionalActionClassPath)
result = Stream.concat(result, resolveClassPathStream(clientDir, ((OptionalActionClassPath) a).args)); result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args));
} }
return result; return result;
} }
@ -340,8 +349,9 @@ private ClassPathFileVisitor(List<Path> result) {
@Override @Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip")) if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip")) {
result.add(file); result.add(file);
}
return super.visitFile(file, attrs); return super.visitFile(file, attrs);
} }
} }

View file

@ -6,7 +6,7 @@ public final class Version implements Comparable<Version> {
public static final int MAJOR = 5; public static final int MAJOR = 5;
public static final int MINOR = 6; public static final int MINOR = 6;
public static final int PATCH = 0; public static final int PATCH = 1;
public static final int BUILD = 1; public static final int BUILD = 1;
public static final Version.Type RELEASE = Type.STABLE; public static final Version.Type RELEASE = Type.STABLE;
public final int major; public final int major;

View file

@ -258,6 +258,14 @@ public static ArgsParseResult parseJavaArgs(List<String> args) {
return new ArgsParseResult(conf, classpath, jvmArgs, mainClass, mainModule, jarFile, args); return new ArgsParseResult(conf, classpath, jvmArgs, mainClass, mainModule, jarFile, args);
} }
public static <K, V> V multimapFirstOrNullValue(K key, Map<K, List<V>> params) {
List<V> list = params.getOrDefault(key, Collections.emptyList());
if (list.isEmpty()) {
return null;
}
return list.getFirst();
}
public record ArgsParseResult(LaunchOptions.ModuleConf conf, List<String> classpath, List<String> jvmArgs, String mainClass, String mainModule, String jarFile, List<String> args) { public record ArgsParseResult(LaunchOptions.ModuleConf conf, List<String> classpath, List<String> jvmArgs, String mainClass, String mainModule, String jarFile, List<String> args) {
} }

View file

@ -93,6 +93,7 @@ public synchronized static List<JavaVersion> findJava() {
trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Java")); trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Java"));
trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("AdoptOpenJDK")); trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("AdoptOpenJDK"));
trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Eclipse Foundation")); //AdoptJDK rebranding trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Eclipse Foundation")); //AdoptJDK rebranding
trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Eclipse Adoptium")); //AdoptJDK rebranding
trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("BellSoft")); // LibericaJDK trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("BellSoft")); // LibericaJDK
} catch (IOException e) { } catch (IOException e) {
LogHelper.error(e); LogHelper.error(e);

View file

@ -0,0 +1,29 @@
package pro.gravit.utils.helper;
import java.net.URI;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
public class QueryHelper {
public static Map<String, List<String>> splitUriQuery(URI uri) {
var query = uri.getRawQuery();
if (query == null) {
return Collections.emptyMap();
}
Map<String, List<String>> params = new HashMap<>();
String[] split = query.split("&");
for (String qParams : split) {
String[] splitParams = qParams.split("=");
List<String> strings = params.computeIfAbsent(URLDecoder.decode(splitParams[0], StandardCharsets.UTF_8),
k -> new ArrayList<>(1));
strings.add(URLDecoder.decode(splitParams[1], StandardCharsets.UTF_8));
}
return params;
}
public static String encodeFormPair(String key, String value) {
return URLEncoder.encode(key, StandardCharsets.UTF_8) + "=" + URLEncoder.encode(value, StandardCharsets.UTF_8);
}
}

View file

@ -5,7 +5,7 @@
id 'org.openjfx.javafxplugin' version '0.1.0' apply false id 'org.openjfx.javafxplugin' version '0.1.0' apply false
} }
group = 'pro.gravit.launcher' group = 'pro.gravit.launcher'
version = '5.6.0' version = '5.6.1'
apply from: 'props.gradle' apply from: 'props.gradle'

Binary file not shown.

View file

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

@ -1 +1 @@
Subproject commit e93620f10963b951c8874dfef17dce91cf8c8da9 Subproject commit dba18b58312a92e465ad17d78ea3504a8b3c1818