Compare commits

...

14 commits

Author SHA1 Message Date
Gravita
c6f8793031 Merge branch 'release/5.3.6' 2023-03-07 14:21:15 +07:00
Gravita
70012a2a8f [ANY] 5.3.6 release 2023-03-03 18:00:57 +07:00
Gravita
3821fa7e51 [ANY] Update modules 2023-03-03 16:59:50 +07:00
Gravita
43ffacdf5e [FEATURE] Update Sentry module 2023-02-26 13:12:11 +07:00
Gravita
5c374462ef [FIX] Ping error handle 2023-02-25 19:54:05 +07:00
Gravita
ef5695f679 [ANY] Update modules 2023-02-25 18:43:34 +07:00
Gravita
b4331819cb [FEATURE] Update OptionalView 2023-02-25 18:42:26 +07:00
Gravit
ebf25a65f7
Merge pull request #637 from microwin7/patch-16
[FEATURE] Default value for client profile and assets dir
2023-02-22 16:44:57 +07:00
microwin7
5588b4aac1 [FEATURE] Default value for client profile and assets dir 2023-02-18 07:00:35 +03:00
Gravita
fbaf9ab87f [ANY] Update modules 2023-01-30 20:33:16 +07:00
Gravita
6d1440207b [FIX] Launch4j build exe 2023-01-25 18:02:24 +07:00
Gravita
9d719c48e3 [ANY] Update dependencies 2023-01-24 17:17:03 +07:00
Gravita
b0fba84fbb [FEATURE] MergeAuthCoreProvider 2023-01-20 19:57:14 +07:00
Gravita
1ffd36fc82 Merge tag 'v5.3.5' into dev
5.3.5 stable release
2023-01-15 14:50:37 +07:00
17 changed files with 180 additions and 49 deletions

View file

@ -22,6 +22,7 @@ public final class AuthProviderPair {
public transient String name; public transient String name;
public transient Set<String> features; public transient Set<String> features;
public String displayName; public String displayName;
public boolean visible = true;
private transient boolean warnOAuthShow = false; private transient boolean warnOAuthShow = false;
public AuthProviderPair() { public AuthProviderPair() {

View file

@ -46,6 +46,7 @@ public static void registerProviders() {
providers.register("postgresql", PostgresSQLCoreProvider.class); providers.register("postgresql", PostgresSQLCoreProvider.class);
providers.register("memory", MemoryAuthCoreProvider.class); providers.register("memory", MemoryAuthCoreProvider.class);
providers.register("http", HttpAuthCoreProvider.class); providers.register("http", HttpAuthCoreProvider.class);
providers.register("merge", MergeAuthCoreProvider.class);
registredProviders = true; registredProviders = true;
} }
} }

View file

@ -0,0 +1,90 @@
package pro.gravit.launchserver.auth.core;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import pro.gravit.launcher.request.auth.AuthRequest;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.manangers.AuthManager;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class MergeAuthCoreProvider extends AuthCoreProvider {
private transient final Logger logger = LogManager.getLogger(MergeAuthCoreProvider.class);
public List<String> list = new ArrayList<>();
private transient List<AuthCoreProvider> providers = new ArrayList<>();
@Override
public User getUserByUsername(String username) {
for(var core : providers) {
var result = core.getUserByUsername(username);
if(result != null) {
return result;
}
}
return null;
}
@Override
public User getUserByUUID(UUID uuid) {
for(var core : providers) {
var result = core.getUserByUUID(uuid);
if(result != null) {
return result;
}
}
return null;
}
@Override
public UserSession getUserSessionByOAuthAccessToken(String accessToken) throws OAuthAccessTokenExpired {
throw new OAuthAccessTokenExpired(); // Authorization not supported
}
@Override
public AuthManager.AuthReport refreshAccessToken(String refreshToken, AuthResponse.AuthContext context) {
return null;
}
@Override
public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext context, AuthRequest.AuthPasswordInterface password, boolean minecraftAccess) throws IOException {
throw new AuthException("Authorization not supported");
}
@Override
public User checkServer(Client client, String username, String serverID) throws IOException {
for(var core : providers) {
var result = core.checkServer(client, username, serverID);
if(result != null) {
return result;
}
}
return null;
}
@Override
public boolean joinServer(Client client, String username, String accessToken, String serverID) throws IOException {
return false; // Authorization not supported
}
@Override
public void init(LaunchServer server) {
for(var e : list) {
var pair = server.config.auth.get(e);
if(pair != null) {
providers.add(pair.core);
} else {
logger.warn("Provider {} not found", e);
}
}
}
@Override
public void close() throws IOException {
// Providers closed automatically
}
}

View file

@ -83,8 +83,7 @@ private Path setConfig() {
jre.setMinVersion(server.config.launch4j.minVersion); jre.setMinVersion(server.config.launch4j.minVersion);
if (server.config.launch4j.setMaxVersion) if (server.config.launch4j.setMaxVersion)
jre.setMaxVersion(server.config.launch4j.maxVersion); jre.setMaxVersion(server.config.launch4j.maxVersion);
jre.setRuntimeBits(Jre.RUNTIME_BITS_64_AND_32); jre.setPath(System.getProperty("java.home"));
jre.setJdkPreference(Jre.JDK_PREFERENCE_PREFER_JRE);
config.setJre(jre); config.setJre(jre);
// Prepare version info (product) // Prepare version info (product)

View file

@ -40,11 +40,11 @@ public String getUsageDescription() {
@Override @Override
public void invoke(String... args) throws Exception { public void invoke(String... args) throws Exception {
verifyArgs(args, 2); verifyArgs(args, 1);
//Version version = Version.byName(args[0]); //Version version = Version.byName(args[0]);
String versionName = args[0]; String versionName = args[0];
String dirName = IOHelper.verifyFileName(args[1] != null ? args[1] : "assets");
String type = args.length > 2 ? args[2] : "mojang"; String type = args.length > 2 ? args[2] : "mojang";
String dirName = IOHelper.verifyFileName(args[1]);
Path assetDir = server.updatesDir.resolve(dirName); Path assetDir = server.updatesDir.resolve(dirName);
// Create asset dir // Create asset dir

View file

@ -41,18 +41,14 @@ public void invoke(String... args) throws IOException, CommandException {
verifyArgs(args, 2); verifyArgs(args, 2);
//Version version = Version.byName(args[0]); //Version version = Version.byName(args[0]);
String versionName = args[0]; String versionName = args[0];
String dirName = IOHelper.verifyFileName(args[1]); String dirName = IOHelper.verifyFileName(args[1] != null ? args[1] : args[0]);
Path clientDir = server.updatesDir.resolve(args[1]); Path clientDir = server.updatesDir.resolve(dirName);
boolean isMirrorClientDownload = false; boolean isMirrorClientDownload = false;
if (args.length > 2) { if (args.length > 2) {
isMirrorClientDownload = args[2].equals("mirror"); isMirrorClientDownload = args[2].equals("mirror");
} }
// Create client dir
logger.info("Creating client dir: '{}'", dirName);
Files.createDirectory(clientDir);
// Download required client // Download required client
logger.info("Downloading client, it may take some time"); logger.info("Downloading client, it may take some time");
//HttpDownloader.downloadZip(server.mirrorManager.getDefaultMirror().getClientsURL(version.name), clientDir); //HttpDownloader.downloadZip(server.mirrorManager.getDefaultMirror().getClientsURL(version.name), clientDir);
@ -60,7 +56,25 @@ public void invoke(String... args) throws IOException, CommandException {
// Create profile file // Create profile file
logger.info("Creaing profile file: '{}'", dirName); logger.info("Creaing profile file: '{}'", dirName);
ClientProfile client = null; ClientProfile clientProfile = null;
if (isMirrorClientDownload) {
try {
JsonElement clientJson = server.mirrorManager.jsonRequest(null, "GET", "clients/%s.json", versionName);
clientProfile = Launcher.gsonManager.configGson.fromJson(clientJson, ClientProfile.class);
clientProfile.setTitle(dirName);
clientProfile.setDir(dirName);
clientProfile.setUUID(UUID.randomUUID());
if (clientProfile.getServers() != null) {
ClientProfile.ServerProfile serverProfile = clientProfile.getDefaultServerProfile();
if (serverProfile != null) {
serverProfile.name = dirName;
}
}
} catch (Exception e) {
logger.error("Filed download clientProfile from mirror: '{}' Generation through MakeProfileHelper", versionName);
isMirrorClientDownload = false;
}
}
if (!isMirrorClientDownload) { if (!isMirrorClientDownload) {
try { try {
String internalVersion = versionName; String internalVersion = versionName;
@ -75,27 +89,14 @@ public void invoke(String... args) throws IOException, CommandException {
for (MakeProfileHelper.MakeProfileOption option : options) { for (MakeProfileHelper.MakeProfileOption option : options) {
logger.debug("Detected option {}", option.getClass().getSimpleName()); logger.debug("Detected option {}", option.getClass().getSimpleName());
} }
client = MakeProfileHelper.makeProfile(version, dirName, options); clientProfile = MakeProfileHelper.makeProfile(version, dirName, options);
} catch (Throwable e) { } catch (Throwable e) {
isMirrorClientDownload = true; isMirrorClientDownload = true;
} }
} }
if (isMirrorClientDownload) {
JsonElement clientJson = server.mirrorManager.jsonRequest(null, "GET", "clients/%s.json", versionName);
client = Launcher.gsonManager.configGson.fromJson(clientJson, ClientProfile.class);
client.setTitle(dirName);
client.setDir(dirName);
client.setUUID(UUID.randomUUID());
if (client.getServers() != null) {
ClientProfile.ServerProfile serverProfile = client.getDefaultServerProfile();
if (serverProfile != null) {
serverProfile.name = dirName;
}
}
}
try (BufferedWriter writer = IOHelper.newWriter(IOHelper.resolveIncremental(server.profilesDir, try (BufferedWriter writer = IOHelper.newWriter(IOHelper.resolveIncremental(server.profilesDir,
dirName, "json"))) { dirName, "json"))) {
Launcher.gsonManager.configGson.toJson(client, writer); Launcher.gsonManager.configGson.toJson(clientProfile, writer);
} }
// Finished // Finished

View file

@ -23,10 +23,10 @@ public void execute(ChannelHandlerContext ctx, Client client) {
var rca = pair.isSupport(AuthSupportRemoteClientAccess.class); var rca = pair.isSupport(AuthSupportRemoteClientAccess.class);
if (rca != null) { if (rca != null) {
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName, list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName,
pair.core.getDetails(client), rca.getClientApiUrl(), rca.getClientApiFeatures())); pair.visible, pair.core.getDetails(client), rca.getClientApiUrl(), rca.getClientApiFeatures()));
} else { } else {
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName, list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName,
pair.core.getDetails(client))); pair.visible, pair.core.getDetails(client)));
} }
} }
sendResult(new GetAvailabilityAuthRequestEvent(list)); sendResult(new GetAvailabilityAuthRequestEvent(list));

View file

@ -179,7 +179,7 @@ public static void applyBasicOfflineProcessors(OfflineRequestService service) {
service.registerRequestProcessor(GetAvailabilityAuthRequest.class, (r) -> { service.registerRequestProcessor(GetAvailabilityAuthRequest.class, (r) -> {
List<GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails> details = new ArrayList<>(); List<GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails> details = new ArrayList<>();
details.add(new AuthLoginOnlyDetails()); details.add(new AuthLoginOnlyDetails());
GetAvailabilityAuthRequestEvent.AuthAvailability authAvailability = new GetAvailabilityAuthRequestEvent.AuthAvailability("offline", "Offline Mode", details); GetAvailabilityAuthRequestEvent.AuthAvailability authAvailability = new GetAvailabilityAuthRequestEvent.AuthAvailability("offline", "Offline Mode", true, details);
List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>(1); List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>(1);
list.add(authAvailability); list.add(authAvailability);
return new GetAvailabilityAuthRequestEvent(list); return new GetAvailabilityAuthRequestEvent(list);

View file

@ -1,5 +1,6 @@
package pro.gravit.launcher.client; package pro.gravit.launcher.client;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.profiles.ClientProfile;
@ -162,9 +163,13 @@ private Result modernPing(HInput input, HOutput output) throws IOException {
} }
// Parse JSON response // Parse JSON response
JsonObject object = JsonParser.parseString(response).getAsJsonObject(); JsonElement element = JsonParser.parseString(response);
if(element.isJsonPrimitive()) {
throw new IOException(element.getAsString());
}
JsonObject object = element.getAsJsonObject();
if (object.has("error")) { if (object.has("error")) {
throw new IOException(object.get("error").getAsString()); throw new IOException(object.get("error").getAsString()); // May be not needed?
} }
JsonObject playersObject = object.get("players").getAsJsonObject(); JsonObject playersObject = object.get("players").getAsJsonObject();
int online = playersObject.get("online").getAsInt(); int online = playersObject.get("online").getAsInt();

View file

@ -45,18 +45,23 @@ public static class AuthAvailability {
public String name; public String name;
@LauncherNetworkAPI @LauncherNetworkAPI
public String displayName; public String displayName;
@LauncherNetworkAPI
public boolean visible;
@LauncherNetworkAPI @LauncherNetworkAPI
public String apiUrl; public String apiUrl;
@LauncherNetworkAPI @LauncherNetworkAPI
public List<String> apiFeatures; public List<String> apiFeatures;
public AuthAvailability(String name, String displayName, List<AuthAvailabilityDetails> details) { public AuthAvailability(String name, String displayName, boolean visible, List<AuthAvailabilityDetails> details) {
this.name = name; this.name = name;
this.displayName = displayName; this.displayName = displayName;
this.visible = visible;
this.details = details; this.details = details;
} }
public AuthAvailability(String name, String displayName, List<AuthAvailabilityDetails> details, String apiUrl, List<String> apiFeatures) { public AuthAvailability(String name, String displayName, boolean visible, List<AuthAvailabilityDetails> details, String apiUrl, List<String> apiFeatures) {
this.visible = visible;
this.details = details; this.details = details;
this.name = name; this.name = name;
this.displayName = displayName; this.displayName = displayName;

View file

@ -27,6 +27,21 @@ public OptionalView(OptionalView view) {
this.all = view.all; this.all = view.all;
} }
public OptionalView(ClientProfile profile, OptionalView old) {
this(profile);
for(OptionalFile oldFile : old.all) {
OptionalFile newFile = findByName(oldFile.name);
if(newFile == null) {
continue;
}
if(old.isEnabled(oldFile)) {
enable(newFile, old.installInfo.get(oldFile).isManual, (file, status) -> {});
} else {
disable(newFile, (file, status) -> {});
}
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends OptionalAction> Set<T> getActionsByClass(Class<T> clazz) { public <T extends OptionalAction> Set<T> getActionsByClass(Class<T> clazz) {
Set<T> results = new HashSet<>(); Set<T> results = new HashSet<>();
@ -42,6 +57,19 @@ public <T extends OptionalAction> Set<T> getActionsByClass(Class<T> clazz) {
return results; return results;
} }
public OptionalFile findByName(String name) {
for(OptionalFile file : all) {
if(name.equals(file.name)) {
return file;
}
}
return null;
}
public boolean isEnabled(OptionalFile file) {
return enabled.contains(file);
}
public Set<OptionalAction> getEnabledActions() { public Set<OptionalAction> getEnabledActions() {
Set<OptionalAction> results = new HashSet<>(); Set<OptionalAction> results = new HashSet<>();
for (OptionalFile e : enabled) { for (OptionalFile e : enabled) {

View file

@ -56,6 +56,7 @@ public static void downloadFile(URL url, Path file, Consumer<Integer> chanheTrac
public static void downloadZip(URL url, Path dir) throws IOException { public static void downloadZip(URL url, Path dir) throws IOException {
try (ZipInputStream input = IOHelper.newZipInput(url)) { try (ZipInputStream input = IOHelper.newZipInput(url)) {
Files.createDirectory(dir);
for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) { for (ZipEntry entry = input.getNextEntry(); entry != null; entry = input.getNextEntry()) {
if (entry.isDirectory()) { if (entry.isDirectory()) {
Files.createDirectory(dir.resolve(IOHelper.toPath(entry.getName()))); Files.createDirectory(dir.resolve(IOHelper.toPath(entry.getName())));

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 = 3; public static final int MINOR = 3;
public static final int PATCH = 5; public static final int PATCH = 6;
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

@ -64,7 +64,7 @@ pack project(':LauncherAPI')
shadowJar { shadowJar {
duplicatesStrategy = 'EXCLUDE' duplicatesStrategy = 'EXCLUDE'
classifier = null archiveClassifier = null
relocate 'io.netty', 'pro.gravit.repackage.io.netty' relocate 'io.netty', 'pro.gravit.repackage.io.netty'
configurations = [project.configurations.pack] configurations = [project.configurations.pack]
exclude 'module-info.class' exclude 'module-info.class'

View file

@ -1,11 +1,11 @@
plugins { plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0' apply false id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
id 'maven-publish' id 'maven-publish'
id 'signing' id 'signing'
id 'org.openjfx.javafxplugin' version '0.0.10' apply false id 'org.openjfx.javafxplugin' version '0.0.10' apply false
} }
group = 'pro.gravit.launcher' group = 'pro.gravit.launcher'
version = '5.3.5' version = '5.3.6'
apply from: 'props.gradle' apply from: 'props.gradle'

@ -1 +1 @@
Subproject commit 614aea895f2d3ccbcf311b8058ab7a5f1dcd8602 Subproject commit e16960e7eef248a217071638f0e68b14cec09cb8

View file

@ -1,20 +1,20 @@
project.ext { project.ext {
verAsm = '9.3' verAsm = '9.4'
verNetty = '4.1.78.Final' verNetty = '4.1.87.Final'
verOshiCore = '6.2.1' verOshiCore = '6.4.0'
verJunit = '5.8.2' verJunit = '5.9.2'
verGuavaC = '30.1.1-jre' verGuavaC = '30.1.1-jre'
verJansi = '2.4.0' verJansi = '2.4.0'
verJline = '3.21.0' verJline = '3.22.0'
verJwt = '0.11.5' verJwt = '0.11.5'
verBcprov = '1.70' verBcprov = '1.70'
verGson = '2.9.0' verGson = '2.10.1'
verBcpkix = '1.70' verBcpkix = '1.70'
verSlf4j = '1.7.36' verSlf4j = '1.7.36'
verLog4j = '2.17.2' verLog4j = '2.19.0'
verMySQLConn = '8.0.29' verMySQLConn = '8.0.32'
verPostgreSQLConn = '42.4.0' verPostgreSQLConn = '42.5.1'
verProguard = '7.2.2' verProguard = '7.3.1'
verLaunch4j = '3.14' verLaunch4j = '3.50'
verHibernate = '5.5.6.Final' verHibernate = '5.5.6.Final'
} }