mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-03-29 12:38:26 +03:00
[REFACTOR] Idea Reformat Code
This commit is contained in:
parent
2c41b510ad
commit
cd99641327
123 changed files with 846 additions and 903 deletions
|
@ -11,7 +11,10 @@
|
|||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.auth.session.MemorySessionStorage;
|
||||
import pro.gravit.launchserver.binary.*;
|
||||
import pro.gravit.launchserver.binary.EXEL4JLauncherBinary;
|
||||
import pro.gravit.launchserver.binary.EXELauncherBinary;
|
||||
import pro.gravit.launchserver.binary.JARLauncherBinary;
|
||||
import pro.gravit.launchserver.binary.LauncherBinary;
|
||||
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
|
||||
import pro.gravit.launchserver.launchermodules.LauncherModuleLoader;
|
||||
|
@ -50,8 +53,6 @@
|
|||
* Not a singletron
|
||||
*/
|
||||
public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurable {
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public static final Class<? extends LauncherBinary> defaultLauncherEXEBinaryClass = null;
|
||||
/**
|
||||
* Working folder path
|
||||
|
@ -69,12 +70,12 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
|
|||
* The path to the folder with compile-only libraries for the launcher
|
||||
*/
|
||||
public final Path launcherLibrariesCompile;
|
||||
|
||||
// Constant paths
|
||||
/**
|
||||
* The path to the folder with updates/webroot
|
||||
*/
|
||||
public final Path updatesDir;
|
||||
|
||||
// Constant paths
|
||||
/**
|
||||
* Save/Reload LaunchServer config
|
||||
*/
|
||||
|
@ -100,7 +101,6 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
|
|||
* Pipeline for building EXE
|
||||
*/
|
||||
public final LauncherBinary launcherEXEBinary;
|
||||
|
||||
//public static LaunchServer server = null;
|
||||
public final Class<? extends LauncherBinary> launcherEXEBinaryClass;
|
||||
// Server config
|
||||
|
@ -125,6 +125,7 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
|
|||
public final ScheduledExecutorService service;
|
||||
public final AtomicBoolean started = new AtomicBoolean(false);
|
||||
public final LauncherModuleLoader launcherModuleLoader;
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
public LaunchServerConfig config;
|
||||
public volatile Map<String, HashedDir> updatesDirMap;
|
||||
// Updates and profiles
|
||||
|
@ -542,7 +543,8 @@ public void collect() {
|
|||
if (launcherLibrariesCompileDir == null)
|
||||
launcherLibrariesCompileDir = getPath(LAUNCHERLIBRARIESCOMPILE_NAME);
|
||||
if (keyDirectory == null) keyDirectory = getPath(KEY_NAME);
|
||||
if(tmpDir ==null) tmpDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve(String.format("launchserver-%s", SecurityHelper.randomStringToken()));
|
||||
if (tmpDir == null)
|
||||
tmpDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve(String.format("launchserver-%s", SecurityHelper.randomStringToken()));
|
||||
}
|
||||
|
||||
private Path getPath(String dirName) {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
import pro.gravit.utils.command.CommandHandler;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.security.interfaces.ECPrivateKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
|
||||
public class LaunchServerBuilder {
|
||||
private LaunchServerConfig config;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
|
@ -39,12 +38,8 @@
|
|||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.KeyPair;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.interfaces.ECPrivateKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
|
||||
public class LaunchServerStarter {
|
||||
public static final boolean allowUnsigned = Boolean.getBoolean("launchserver.allowUnsigned");
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.postgresql.ds.PGSimpleDataSource;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
@ -18,11 +17,9 @@ public final class PostgreSQLSourceConfig implements AutoCloseable {
|
|||
private static final int MAX_POOL_SIZE = VerifyHelper.verifyInt(
|
||||
Integer.parseUnsignedInt(System.getProperty("launcher.postgresql.maxPoolSize", Integer.toString(3))),
|
||||
VerifyHelper.POSITIVE, "launcher.postgresql.maxPoolSize can't be <= 0");
|
||||
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
// Instance
|
||||
private String poolName;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
// Config
|
||||
private String[] addresses;
|
||||
private int[] ports;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
@ -31,8 +30,9 @@
|
|||
*/
|
||||
public abstract class AuthCoreProvider implements AutoCloseable, Reconfigurable {
|
||||
public static final ProviderMap<AuthCoreProvider> providers = new ProviderMap<>("AuthCoreProvider");
|
||||
private static boolean registredProviders = false;
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static boolean registredProviders = false;
|
||||
|
||||
public static void registerProviders() {
|
||||
if (!registredProviders) {
|
||||
providers.register("reject", RejectAuthCoreProvider.class);
|
||||
|
@ -40,14 +40,23 @@ public static void registerProviders() {
|
|||
registredProviders = true;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract User getUserByUsername(String username);
|
||||
|
||||
public abstract User getUserByUUID(UUID uuid);
|
||||
|
||||
public abstract UserSession getUserSessionByOAuthAccessToken(String accessToken) throws OAuthAccessTokenExpired;
|
||||
|
||||
public abstract AuthManager.AuthReport refreshAccessToken(String refreshToken, AuthResponse.AuthContext context /* may be null */);
|
||||
|
||||
public abstract void verifyAuth(AuthResponse.AuthContext context) throws AuthException;
|
||||
|
||||
public abstract PasswordVerifyReport verifyPassword(User user, AuthRequest.AuthPasswordInterface password);
|
||||
|
||||
public abstract AuthManager.AuthReport createOAuthSession(User user, AuthResponse.AuthContext context /* may be null */, PasswordVerifyReport report /* may be null */, boolean minecraftAccess) throws IOException;
|
||||
|
||||
public abstract void init(LaunchServer server);
|
||||
|
||||
// Auth Handler methods
|
||||
protected abstract boolean updateServerID(User user, String serverID) throws IOException;
|
||||
|
||||
|
@ -125,11 +134,11 @@ public boolean joinServer(Client client, String username, String accessToken, St
|
|||
public abstract void close() throws IOException;
|
||||
|
||||
public static class PasswordVerifyReport {
|
||||
public static final PasswordVerifyReport REQUIRED_2FA = new PasswordVerifyReport(-1);
|
||||
public static final PasswordVerifyReport FAILED = new PasswordVerifyReport(false);
|
||||
public final boolean success;
|
||||
public final boolean needMoreFactor;
|
||||
public final List<Integer> factors;
|
||||
public static final PasswordVerifyReport REQUIRED_2FA = new PasswordVerifyReport(-1);
|
||||
public static final PasswordVerifyReport FAILED = new PasswordVerifyReport(false);
|
||||
|
||||
public PasswordVerifyReport(boolean success) {
|
||||
this.success = success;
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
|
||||
public interface User {
|
||||
String getUsername();
|
||||
|
||||
UUID getUUID();
|
||||
|
||||
String getServerId();
|
||||
|
||||
String getAccessToken();
|
||||
|
||||
ClientPermissions getPermissions();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
public interface UserSession {
|
||||
String getID();
|
||||
|
||||
User getUser();
|
||||
|
||||
long getExpireIn();
|
||||
}
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
|
||||
public interface AuthSupportExit {
|
||||
boolean deleteSession(UserSession session);
|
||||
|
||||
boolean exitUser(User user);
|
||||
}
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
|
||||
public interface AuthSupportGetSessionsFromUser {
|
||||
List<UserSession> getSessionsByUser(User user);
|
||||
|
||||
void clearSessionsByUser(User user);
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
public interface UserSupportMoney {
|
||||
long getMoney();
|
||||
|
||||
long getDonateMoney();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.*;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
public class DigestPasswordVerifier extends PasswordVerifier {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public String algo;
|
||||
|
||||
@Override
|
||||
public boolean check(String encryptedPassword, String password) {
|
||||
try {
|
||||
|
|
|
@ -13,6 +13,7 @@ public class DoubleDigestPasswordVerifier extends PasswordVerifier {
|
|||
private transient final Logger logger = LogManager.getLogger();
|
||||
public String algo;
|
||||
public boolean toHexMode;
|
||||
|
||||
@Override
|
||||
public boolean check(String encryptedPassword, String password) {
|
||||
try {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
public abstract class PasswordVerifier {
|
||||
public static final ProviderMap<PasswordVerifier> providers = new ProviderMap<>("PasswordVerifier");
|
||||
private static boolean registeredProviders = false;
|
||||
|
||||
public static void registerProviders() {
|
||||
if (!registeredProviders) {
|
||||
providers.register("plain", PlainPasswordVerifier.class);
|
||||
|
@ -13,5 +14,6 @@ public static void registerProviders() {
|
|||
registeredProviders = true;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean check(String encryptedPassword, String password);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
|
||||
import pro.gravit.launchserver.socket.response.secure.HardwareReportResponse;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class MemoryHWIDProvider extends HWIDProvider implements Reconfigurable {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public double warningSpoofingLevel = -1.0;
|
||||
public double criticalCompareLevel = 1.0;
|
||||
public transient Set<MemoryHWIDEntity> db = ConcurrentHashMap.newKeySet();
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public Map<String, Command> getCommands() {
|
||||
|
|
|
@ -13,16 +13,15 @@
|
|||
import java.sql.*;
|
||||
|
||||
public class MysqlHWIDProvider extends HWIDProvider {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public MySQLSourceConfig mySQLHolder;
|
||||
public double warningSpoofingLevel = -1.0;
|
||||
public double criticalCompareLevel = 1.0;
|
||||
|
||||
public String tableHWID = "hwids";
|
||||
public String tableHWIDLog = "hwidLog";
|
||||
public String tableUsers;
|
||||
public String usersNameColumn;
|
||||
public String usersHWIDColumn;
|
||||
|
||||
private String sqlFindByPublicKey;
|
||||
private String sqlFindByHardware;
|
||||
private String sqlCreateHardware;
|
||||
|
@ -30,8 +29,6 @@ public class MysqlHWIDProvider extends HWIDProvider {
|
|||
private String sqlUpdateHardware;
|
||||
private String sqlUpdateUsers;
|
||||
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public void init(LaunchServer server) {
|
||||
sqlFindByPublicKey = String.format("SELECT hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, banned FROM %s WHERE `publicKey` = ?", tableHWID);
|
||||
|
|
|
@ -33,9 +33,11 @@ public AuthProviderResult auth(String login, AuthRequest.AuthPasswordInterface p
|
|||
firstPassword = ((AuthPlainPassword) password).password;
|
||||
secondPassword = null;
|
||||
} else if (password instanceof Auth2FAPassword) {
|
||||
if (!(((Auth2FAPassword) password).firstPassword instanceof AuthPlainPassword)) throw new AuthException("This password type not supported");
|
||||
if (!(((Auth2FAPassword) password).firstPassword instanceof AuthPlainPassword))
|
||||
throw new AuthException("This password type not supported");
|
||||
firstPassword = ((AuthPlainPassword) ((Auth2FAPassword) password).firstPassword).password;
|
||||
if (!(((Auth2FAPassword) password).secondPassword instanceof AuthTOTPPassword)) throw new AuthException("This password type not supported");
|
||||
if (!(((Auth2FAPassword) password).secondPassword instanceof AuthTOTPPassword))
|
||||
throw new AuthException("This password type not supported");
|
||||
secondPassword = ((AuthTOTPPassword) ((Auth2FAPassword) password).secondPassword).totp;
|
||||
} else {
|
||||
throw new AuthException("This password type not supported");
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import pro.gravit.launchserver.auth.AuthException;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -16,11 +15,10 @@
|
|||
import java.util.Map;
|
||||
|
||||
public final class RejectAuthProvider extends AuthProvider implements Reconfigurable {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public String message;
|
||||
public ArrayList<String> whitelist = new ArrayList<>();
|
||||
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public RejectAuthProvider() {
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import pro.gravit.launchserver.auth.AuthException;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
import pro.gravit.launcher.NeedGarbageCollection;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class BinaryPipeline {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public final List<LauncherBuildTask> tasks = new ArrayList<>();
|
||||
public final AtomicLong count = new AtomicLong(0);
|
||||
public final Path buildDir;
|
||||
public final String nameFormat;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public BinaryPipeline(Path buildDir, String nameFormat) {
|
||||
this.buildDir = buildDir;
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package pro.gravit.launchserver.binary;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.serialize.HOutput;
|
||||
import pro.gravit.launcher.serialize.stream.StreamObject;
|
||||
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
@ -33,7 +31,6 @@
|
|||
import java.util.function.Predicate;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.binary.tasks.*;
|
||||
import pro.gravit.launchserver.components.ProGuardComponent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
|
|
@ -34,12 +34,11 @@
|
|||
|
||||
public class CertificateAutogenTask implements LauncherBuildTask {
|
||||
private final LaunchServer server;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public X509Certificate certificate;
|
||||
public X509CertificateHolder bcCertificate;
|
||||
public CMSSignedDataGenerator signedDataGenerator;
|
||||
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public CertificateAutogenTask(LaunchServer server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
import pro.gravit.launchserver.binary.BuildContext;
|
||||
import pro.gravit.utils.HookException;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -63,7 +62,8 @@ public Path process(Path inputJar) throws IOException {
|
|||
reader.getCp().add(new JarFile(inputJar.toFile()));
|
||||
for (Path e : server.launcherBinary.coreLibs) {
|
||||
reader.getCp().add(new JarFile(e.toFile()));
|
||||
};
|
||||
}
|
||||
;
|
||||
context.pushJarFile(inputJar, (e) -> blacklist.contains(e.getName()), (e) -> true);
|
||||
|
||||
// map for guard
|
||||
|
@ -114,7 +114,8 @@ protected void initProps() {
|
|||
properties.put("launchercore.env", server.config.env);
|
||||
properties.put("launcher.memory", server.config.launcher.memoryLimit);
|
||||
if (server.config.launcher.encryptRuntime) {
|
||||
if (server.runtime.runtimeEncryptKey == null) server.runtime.runtimeEncryptKey = SecurityHelper.randomStringToken();
|
||||
if (server.runtime.runtimeEncryptKey == null)
|
||||
server.runtime.runtimeEncryptKey = SecurityHelper.randomStringToken();
|
||||
properties.put("runtimeconfig.runtimeEncryptKey", server.runtime.runtimeEncryptKey);
|
||||
}
|
||||
properties.put("launcher.certificatePinning", server.config.launcher.certificatePinning);
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
|
||||
public class SignJarTask implements LauncherBuildTask {
|
||||
|
||||
private transient static final Logger logger = LogManager.getLogger();
|
||||
private final LaunchServerConfig.JarSignerConf config;
|
||||
private final LaunchServer srv;
|
||||
private transient static final Logger logger = LogManager.getLogger();
|
||||
|
||||
public SignJarTask(LaunchServerConfig.JarSignerConf config, LaunchServer srv) {
|
||||
this.config = config;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import pro.gravit.launchserver.auth.provider.AuthProvider;
|
||||
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -10,14 +10,13 @@
|
|||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.security.KeyPair;
|
||||
|
||||
public class TestCommand extends Command {
|
||||
private NettyServerSocketHandler handler = null;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
private NettyServerSocketHandler handler = null;
|
||||
|
||||
public TestCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
|
||||
public final class VersionCommand extends Command {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public VersionCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launchserver.command.hash;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -9,7 +8,6 @@
|
|||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.profiles.ClientProfileBuilder;
|
||||
import pro.gravit.launcher.profiles.optional.OptionalFile;
|
||||
|
@ -12,7 +11,6 @@
|
|||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
@ -28,10 +26,6 @@ public SaveProfilesCommand(LaunchServer server) {
|
|||
super(server);
|
||||
}
|
||||
|
||||
public enum MakeProfileOption {
|
||||
LAUNCHWRAPPER, VANILLA, FORGE, FABRIC, LITELOADER
|
||||
}
|
||||
|
||||
public static ClientProfile makeProfile(ClientProfile.Version version, String title, MakeProfileOption... options) {
|
||||
ClientProfileBuilder builder = new ClientProfileBuilder();
|
||||
builder.setVersion(version.name);
|
||||
|
@ -191,4 +185,8 @@ public void invoke(String... args) throws Exception {
|
|||
server.syncProfilesDir();
|
||||
}
|
||||
}
|
||||
|
||||
public enum MakeProfileOption {
|
||||
LAUNCHWRAPPER, VANILLA, FORGE, FABRIC, LITELOADER
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class SyncBinariesCommand extends Command {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public SyncBinariesCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class SyncProfilesCommand extends Command {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public SyncProfilesCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.nio.file.Files;
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.launchserver.launchermodules.LauncherModuleLoader;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ModulesCommand extends Command {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public ModulesCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import pro.gravit.launchserver.socket.WebSocketService;
|
||||
import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.NeedGarbageCollection;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.launchserver.components.Component;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
@ -25,6 +23,28 @@ public ComponentCommand(LaunchServer server) {
|
|||
childCommands.put("load", new LoadCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return "[action] [component name] [more args]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsageDescription() {
|
||||
return "component manager";
|
||||
}
|
||||
|
||||
public void printHelp() {
|
||||
logger.info("Print help for component:");
|
||||
logger.info("component unload [componentName]");
|
||||
logger.info("component load [componentName] [filename]");
|
||||
logger.info("component gc [componentName]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
invokeSubcommands(args);
|
||||
}
|
||||
|
||||
private class UnloadCommand extends SubCommand {
|
||||
public UnloadCommand() {
|
||||
super("[componentName]", "Unload component");
|
||||
|
@ -47,6 +67,7 @@ public void invoke(String... args) throws Exception {
|
|||
logger.info("Component %s unloaded. Use 'config launchserver save' to save changes");
|
||||
}
|
||||
}
|
||||
|
||||
private class LoadCommand extends SubCommand {
|
||||
public LoadCommand() {
|
||||
super("[componentName] [componentType] (json file)", "Load component");
|
||||
|
@ -79,26 +100,4 @@ public void invoke(String... args) throws Exception {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return "[action] [component name] [more args]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsageDescription() {
|
||||
return "component manager";
|
||||
}
|
||||
|
||||
public void printHelp() {
|
||||
logger.info("Print help for component:");
|
||||
logger.info("component unload [componentName]");
|
||||
logger.info("component load [componentName] [filename]");
|
||||
logger.info("component gc [componentName]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
invokeSubcommands(args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import pro.gravit.launcher.request.management.PingServerReportRequest;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class PingServersCommand extends Command {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.auth.handler.MemoryAuthHandler;
|
||||
|
@ -13,14 +12,12 @@
|
|||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.launchserver.components.ProGuardComponent;
|
||||
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||
import pro.gravit.utils.helper.FormatHelper;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
|
@ -238,10 +235,12 @@ public void invoke(String... args) {
|
|||
}
|
||||
logger.info("Check completed");
|
||||
}
|
||||
|
||||
public boolean checkOtherWriteAccess(Path file) throws IOException {
|
||||
Set<PosixFilePermission> permissionSet = Files.getPosixFilePermissions(file);
|
||||
return permissionSet.contains(PosixFilePermission.OTHERS_WRITE);
|
||||
}
|
||||
|
||||
public boolean checkOtherReadOrWriteAccess(Path file) throws IOException {
|
||||
Set<PosixFilePermission> permissionSet = Files.getPosixFilePermissions(file);
|
||||
return permissionSet.contains(PosixFilePermission.OTHERS_WRITE) || permissionSet.contains(PosixFilePermission.OTHERS_READ);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class ServerStatusCommand extends Command {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import pro.gravit.launchserver.binary.tasks.SignJarTask;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.binary.tasks.SignJarTask;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import pro.gravit.launchserver.Reconfigurable;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -14,9 +13,9 @@
|
|||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractLimiter<T> extends Component implements NeedGarbageCollection, Reconfigurable {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public final List<T> exclude = new ArrayList<>();
|
||||
protected final transient Map<T, LimitEntry> map = new HashMap<>();
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public int rateLimit;
|
||||
public int rateLimitMillis;
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.SubCommand;
|
||||
import pro.gravit.utils.helper.*;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
import pro.gravit.utils.helper.UnpackHelper;
|
||||
import proguard.Configuration;
|
||||
import proguard.ConfigurationParser;
|
||||
import proguard.ParseException;
|
||||
|
@ -20,9 +23,13 @@
|
|||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProGuardComponent extends Component implements AutoCloseable, Reconfigurable {
|
||||
private transient static final Logger logger = LogManager.getLogger();
|
||||
public String modeAfter = "MainBuild";
|
||||
public String dir = "proguard";
|
||||
public boolean enabled = true;
|
||||
|
@ -30,7 +37,40 @@ public class ProGuardComponent extends Component implements AutoCloseable, Recon
|
|||
public transient ProguardConf proguardConf;
|
||||
private transient LaunchServer launchServer;
|
||||
private transient ProGuardBuildTask buildTask;
|
||||
private transient static final Logger logger = LogManager.getLogger();
|
||||
|
||||
public static boolean checkFXJMods(Path path) {
|
||||
if (!IOHelper.exists(path.resolve("javafx.base.jmod")))
|
||||
return false;
|
||||
if (!IOHelper.exists(path.resolve("javafx.graphics.jmod")))
|
||||
return false;
|
||||
return IOHelper.exists(path.resolve("javafx.controls.jmod"));
|
||||
}
|
||||
|
||||
public static boolean checkJMods(Path path) {
|
||||
return IOHelper.exists(path.resolve("java.base.jmod"));
|
||||
}
|
||||
|
||||
public static Path tryFindOpenJFXPath(Path jvmDir) {
|
||||
String dirName = jvmDir.getFileName().toString();
|
||||
Path parent = jvmDir.getParent();
|
||||
if (parent == null) return null;
|
||||
Path archJFXPath = parent.resolve(dirName.replace("openjdk", "openjfx")).resolve("jmods");
|
||||
if (Files.isDirectory(archJFXPath)) {
|
||||
return archJFXPath;
|
||||
}
|
||||
Path arch2JFXPath = parent.resolve(dirName.replace("jdk", "openjfx")).resolve("jmods");
|
||||
if (Files.isDirectory(arch2JFXPath)) {
|
||||
return arch2JFXPath;
|
||||
}
|
||||
if (JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) {
|
||||
Path debianJfxPath = Paths.get("/usr/share/openjfx/jmods");
|
||||
if (Files.isDirectory(debianJfxPath)) {
|
||||
return debianJfxPath;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(LaunchServer launchServer) {
|
||||
this.launchServer = launchServer;
|
||||
|
@ -100,8 +140,7 @@ public Path process(Path inputFile) throws IOException {
|
|||
if (checkFXJMods(IOHelper.JVM_DIR.resolve("jmods"))) {
|
||||
logger.debug("JavaFX jmods resolved in JDK path");
|
||||
jfxPath = null;
|
||||
}
|
||||
else if(jfxPath != null && checkFXJMods(jfxPath)) {
|
||||
} else if (jfxPath != null && checkFXJMods(jfxPath)) {
|
||||
logger.debug("JMods resolved in {}", jfxPath.toString());
|
||||
} else {
|
||||
logger.error("JavaFX jmods not found. May be install OpenJFX?");
|
||||
|
@ -126,39 +165,6 @@ public boolean allowDelete() {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean checkFXJMods(Path path) {
|
||||
if (!IOHelper.exists(path.resolve("javafx.base.jmod")))
|
||||
return false;
|
||||
if (!IOHelper.exists(path.resolve("javafx.graphics.jmod")))
|
||||
return false;
|
||||
return IOHelper.exists(path.resolve("javafx.controls.jmod"));
|
||||
}
|
||||
|
||||
public static boolean checkJMods(Path path) {
|
||||
return IOHelper.exists(path.resolve("java.base.jmod"));
|
||||
}
|
||||
|
||||
public static Path tryFindOpenJFXPath(Path jvmDir) {
|
||||
String dirName = jvmDir.getFileName().toString();
|
||||
Path parent = jvmDir.getParent();
|
||||
if(parent == null) return null;
|
||||
Path archJFXPath = parent.resolve(dirName.replace("openjdk", "openjfx")).resolve("jmods");
|
||||
if(Files.isDirectory(archJFXPath)) {
|
||||
return archJFXPath;
|
||||
}
|
||||
Path arch2JFXPath = parent.resolve(dirName.replace("jdk", "openjfx")).resolve("jmods");
|
||||
if(Files.isDirectory(arch2JFXPath)) {
|
||||
return arch2JFXPath;
|
||||
}
|
||||
if(JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) {
|
||||
Path debianJfxPath = Paths.get("/usr/share/openjfx/jmods");
|
||||
if(Files.isDirectory(debianJfxPath)) {
|
||||
return debianJfxPath;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class ProguardConf {
|
||||
public static final String[] JAVA9_OPTS = new String[]{
|
||||
"-libraryjars '<java.home>/jmods/'"
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
import pro.gravit.launchserver.dao.provider.DaoProvider;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
@ -31,6 +30,7 @@
|
|||
import java.util.Map;
|
||||
|
||||
public final class LaunchServerConfig {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public String projectName;
|
||||
public String[] mirrors;
|
||||
public String binaryName;
|
||||
|
@ -40,7 +40,6 @@ public final class LaunchServerConfig {
|
|||
@Deprecated
|
||||
public DaoProvider dao;
|
||||
public SessionStorage sessions;
|
||||
|
||||
// Handlers & Providers
|
||||
public ProtectHandler protectHandler;
|
||||
public Map<String, Component> components;
|
||||
|
@ -51,7 +50,6 @@ public final class LaunchServerConfig {
|
|||
public String startScript;
|
||||
private transient LaunchServer server = null;
|
||||
private transient AuthProviderPair authDefault;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) {
|
||||
LaunchServerConfig newConfig = new LaunchServerConfig();
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public class LaunchServerRuntimeConfig {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public String passwordEncryptKey;
|
||||
public String runtimeEncryptKey;
|
||||
public String oemUnlockKey;
|
||||
public String registerApiKey;
|
||||
public String clientCheckSecret;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public void verify() {
|
||||
if (passwordEncryptKey == null) logger.error("[RuntimeConfig] passwordEncryptKey must not be null");
|
||||
|
|
|
@ -21,11 +21,32 @@
|
|||
public class LogAppender extends AbstractAppender {
|
||||
private static volatile LogAppender INSTANCE;
|
||||
private final Set<Consumer<LogEvent>> set = new HashSet<>();
|
||||
|
||||
public LogAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions, Property[] properties) {
|
||||
super(name, filter, layout, ignoreExceptions, properties);
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
public static LogAppender getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@PluginFactory
|
||||
public static LogAppender createAppender(
|
||||
@PluginAttribute("name") String name,
|
||||
@PluginElement("Layout") Layout<? extends Serializable> layout,
|
||||
@PluginElement("Filter") final Filter filter,
|
||||
@PluginAttribute("otherAttribute") String otherAttribute) {
|
||||
if (name == null) {
|
||||
LOGGER.error("No name provided for MyCustomAppenderImpl");
|
||||
return null;
|
||||
}
|
||||
if (layout == null) {
|
||||
layout = PatternLayout.createDefaultLayout();
|
||||
}
|
||||
return new LogAppender(name, filter, layout, true, Property.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void append(LogEvent event) {
|
||||
try {
|
||||
|
@ -47,24 +68,4 @@ public void addListener(Consumer<LogEvent> consumer) {
|
|||
public void removeListener(Consumer<LogEvent> consumer) {
|
||||
set.remove(consumer);
|
||||
}
|
||||
|
||||
public static LogAppender getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@PluginFactory
|
||||
public static LogAppender createAppender(
|
||||
@PluginAttribute("name") String name,
|
||||
@PluginElement("Layout") Layout<? extends Serializable> layout,
|
||||
@PluginElement("Filter") final Filter filter,
|
||||
@PluginAttribute("otherAttribute") String otherAttribute) {
|
||||
if (name == null) {
|
||||
LOGGER.error("No name provided for MyCustomAppenderImpl");
|
||||
return null;
|
||||
}
|
||||
if (layout == null) {
|
||||
layout = PatternLayout.createDefaultLayout();
|
||||
}
|
||||
return new LogAppender(name, filter, layout, true, Property.EMPTY_ARRAY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
import pro.gravit.launchserver.asm.InjectClassAcceptor;
|
||||
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class SyncLauncherModulesCommand extends Command {
|
||||
private final LauncherModuleLoader mod;
|
||||
|
|
|
@ -38,6 +38,7 @@ public AuthManager(LaunchServer server) {
|
|||
|
||||
/**
|
||||
* Create AuthContext
|
||||
*
|
||||
* @return AuthContext instance
|
||||
*/
|
||||
public AuthResponse.AuthContext makeAuthContext(Client client, AuthResponse.ConnectTypes authType, AuthProviderPair pair, String login, String profileName, String ip) {
|
||||
|
@ -49,6 +50,7 @@ public AuthResponse.AuthContext makeAuthContext(Client client, AuthResponse.Conn
|
|||
|
||||
/**
|
||||
* Validate auth params ans state
|
||||
*
|
||||
* @param context Auth context
|
||||
* @throws AuthException auth not possible
|
||||
*/
|
||||
|
@ -63,38 +65,9 @@ public void check(AuthResponse.AuthContext context) throws AuthException {
|
|||
}
|
||||
}
|
||||
|
||||
public static class AuthReport {
|
||||
public final String minecraftAccessToken;
|
||||
public final String oauthAccessToken;
|
||||
public final String oauthRefreshToken;
|
||||
public final long oauthExpire;
|
||||
|
||||
private AuthReport(String minecraftAccessToken, String oauthAccessToken, String oauthRefreshToken, long oauthExpire) {
|
||||
this.minecraftAccessToken = minecraftAccessToken;
|
||||
this.oauthAccessToken = oauthAccessToken;
|
||||
this.oauthRefreshToken = oauthRefreshToken;
|
||||
this.oauthExpire = oauthExpire;
|
||||
}
|
||||
|
||||
public static AuthReport ofOAuth(String oauthAccessToken, String oauthRefreshToken, long oauthExpire) {
|
||||
return new AuthReport(null, oauthAccessToken, oauthRefreshToken, oauthExpire);
|
||||
}
|
||||
|
||||
public static AuthReport ofOAuthWithMinecraft(String minecraftAccessToken, String oauthAccessToken, String oauthRefreshToken, long oauthExpire) {
|
||||
return new AuthReport(minecraftAccessToken, oauthAccessToken, oauthRefreshToken, oauthExpire);
|
||||
}
|
||||
|
||||
public static AuthReport ofMinecraftAccessToken(String minecraftAccessToken) {
|
||||
return new AuthReport(minecraftAccessToken, null, null, 0);
|
||||
}
|
||||
|
||||
public boolean isUsingOAuth() {
|
||||
return oauthAccessToken != null || oauthRefreshToken != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Full client authorization with password verification
|
||||
*
|
||||
* @param context AuthContext
|
||||
* @param password User password
|
||||
* @return Access token
|
||||
|
@ -176,8 +149,7 @@ private AuthReport authWithCore(AuthResponse.AuthContext context, AuthRequest.Au
|
|||
context.client.coreObject = user;
|
||||
internalAuth(context.client, context.authType, context.pair, user.getUsername(), uuid, user.getPermissions(), result.isUsingOAuth());
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (report.needMoreFactor) {
|
||||
if (report.factors.size() == 1 && report.factors.get(0) == -1) {
|
||||
throw new AuthException(AuthRequestEvent.TWO_FACTOR_NEED_ERROR_MESSAGE);
|
||||
|
@ -211,8 +183,7 @@ public UUID checkServer(Client client, String username, String serverID) throws
|
|||
if (client.auth == null) return null;
|
||||
if (client.auth.isUseCore()) {
|
||||
return client.auth.core.checkServer(client, username, serverID);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return client.auth.handler.checkServer(username, serverID);
|
||||
}
|
||||
}
|
||||
|
@ -231,16 +202,14 @@ public AuthRequest.AuthPasswordInterface decryptPassword(AuthRequest.AuthPasswor
|
|||
Auth2FAPassword auth2FAPassword = (Auth2FAPassword) password;
|
||||
auth2FAPassword.firstPassword = tryDecryptPasswordPlain(auth2FAPassword.firstPassword);
|
||||
auth2FAPassword.secondPassword = tryDecryptPasswordPlain(auth2FAPassword.secondPassword);
|
||||
}
|
||||
else if(password instanceof AuthMultiPassword) {
|
||||
} else if (password instanceof AuthMultiPassword) {
|
||||
AuthMultiPassword multiPassword = (AuthMultiPassword) password;
|
||||
List<AuthRequest.AuthPasswordInterface> list = new ArrayList<>(multiPassword.list.size());
|
||||
for (AuthRequest.AuthPasswordInterface p : multiPassword.list) {
|
||||
list.add(tryDecryptPasswordPlain(p));
|
||||
}
|
||||
multiPassword.list = list;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
password = tryDecryptPasswordPlain(password);
|
||||
}
|
||||
return password;
|
||||
|
@ -276,4 +245,34 @@ private AuthRequest.AuthPasswordInterface tryDecryptPasswordPlain(AuthRequest.Au
|
|||
}
|
||||
return password;
|
||||
}
|
||||
|
||||
public static class AuthReport {
|
||||
public final String minecraftAccessToken;
|
||||
public final String oauthAccessToken;
|
||||
public final String oauthRefreshToken;
|
||||
public final long oauthExpire;
|
||||
|
||||
private AuthReport(String minecraftAccessToken, String oauthAccessToken, String oauthRefreshToken, long oauthExpire) {
|
||||
this.minecraftAccessToken = minecraftAccessToken;
|
||||
this.oauthAccessToken = oauthAccessToken;
|
||||
this.oauthRefreshToken = oauthRefreshToken;
|
||||
this.oauthExpire = oauthExpire;
|
||||
}
|
||||
|
||||
public static AuthReport ofOAuth(String oauthAccessToken, String oauthRefreshToken, long oauthExpire) {
|
||||
return new AuthReport(null, oauthAccessToken, oauthRefreshToken, oauthExpire);
|
||||
}
|
||||
|
||||
public static AuthReport ofOAuthWithMinecraft(String minecraftAccessToken, String oauthAccessToken, String oauthRefreshToken, long oauthExpire) {
|
||||
return new AuthReport(minecraftAccessToken, oauthAccessToken, oauthRefreshToken, oauthExpire);
|
||||
}
|
||||
|
||||
public static AuthReport ofMinecraftAccessToken(String minecraftAccessToken) {
|
||||
return new AuthReport(minecraftAccessToken, null, null, 0);
|
||||
}
|
||||
|
||||
public boolean isUsingOAuth() {
|
||||
return oauthAccessToken != null || oauthRefreshToken != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
import pro.gravit.launcher.LauncherTrustManager;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -50,13 +49,13 @@
|
|||
public class CertificateManager {
|
||||
public final int validDays = 60;
|
||||
public final int minusHours = 6;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public X509CertificateHolder ca;
|
||||
public AsymmetricKeyParameter caKey;
|
||||
public X509CertificateHolder server;
|
||||
public AsymmetricKeyParameter serverKey;
|
||||
public LauncherTrustManager trustManager;
|
||||
public String orgName;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public X509CertificateHolder generateCertificate(String subjectName, PublicKey subjectPublicKey) throws OperatorCreationException {
|
||||
SubjectPublicKeyInfo subjectPubKeyInfo = SubjectPublicKeyInfo.getInstance(subjectPublicKey.getEncoded());
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.*;
|
||||
import java.security.KeyPair;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.interfaces.ECPrivateKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import pro.gravit.launcher.HTTPRequest;
|
||||
import pro.gravit.utils.HttpDownloader;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -17,8 +16,8 @@
|
|||
|
||||
public class MirrorManager {
|
||||
protected final ArrayList<Mirror> list = new ArrayList<>();
|
||||
private Mirror defaultMirror;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
private Mirror defaultMirror;
|
||||
|
||||
public void addMirror(String mirror) {
|
||||
Mirror m = new Mirror(mirror);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler;
|
||||
import pro.gravit.launchserver.socket.handlers.fileserver.FileServerHandler;
|
||||
import pro.gravit.utils.BiHookSet;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class NettyThreadFactory extends DefaultThreadFactory {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
import pro.gravit.utils.BiHookSet;
|
||||
import pro.gravit.utils.ProviderMap;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||
import pro.gravit.launchserver.socket.LauncherNettyServer;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import javax.net.ssl.SSLServerSocketFactory;
|
||||
import java.net.InetSocketAddress;
|
||||
|
@ -13,10 +12,9 @@
|
|||
@SuppressWarnings("unused")
|
||||
public final class NettyServerSocketHandler implements Runnable, AutoCloseable {
|
||||
private transient final LaunchServer server;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
@Deprecated
|
||||
public volatile boolean logConnections = Boolean.getBoolean("launcher.logConnections");
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
public LauncherNettyServer nettyServer;
|
||||
private SSLServerSocketFactory ssf;
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launchserver.socket.NettyConnectContext;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -18,7 +17,6 @@
|
|||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
||||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
|
||||
public class NettyWebAPIHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
import pro.gravit.launchserver.socket.WebSocketService;
|
||||
import pro.gravit.utils.BiHookSet;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import io.netty.handler.stream.ChunkedFile;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import pro.gravit.launchserver.socket.handlers.ContentType;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -5,28 +5,14 @@
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||
import pro.gravit.launcher.request.auth.password.*;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.auth.AuthException;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.auth.provider.AuthProvider;
|
||||
import pro.gravit.launchserver.auth.provider.AuthProviderDAOResult;
|
||||
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import pro.gravit.launchserver.manangers.AuthManager;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse;
|
||||
import pro.gravit.utils.HookException;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AuthResponse extends SimpleResponse {
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse;
|
||||
import pro.gravit.utils.HookException;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class CheckServerResponse extends SimpleResponse {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public String serverID;
|
||||
public String username;
|
||||
public String client;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
|
|
|
@ -9,13 +9,12 @@
|
|||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
import pro.gravit.utils.HookException;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class JoinServerResponse extends SimpleResponse {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
public String serverID;
|
||||
public String accessToken;
|
||||
public String username;
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
|
|
|
@ -19,22 +19,19 @@
|
|||
import java.util.Map;
|
||||
|
||||
public class RestoreResponse extends SimpleResponse {
|
||||
@FunctionalInterface
|
||||
public interface ExtendedTokenProvider {
|
||||
boolean accept(Client client, AuthProviderPair pair, String extendedToken);
|
||||
}
|
||||
public static Map<String, ExtendedTokenProvider> providers = new HashMap<>();
|
||||
private static boolean registeredProviders = false;
|
||||
public String authId;
|
||||
public String accessToken;
|
||||
public Map<String, String> extended;
|
||||
public boolean needUserInfo;
|
||||
|
||||
public static void registerProviders(LaunchServer server) {
|
||||
if (!registeredProviders) {
|
||||
providers.put(LauncherRequestEvent.LAUNCHER_EXTENDED_TOKEN_NAME, new LauncherResponse.LauncherTokenVerifier(server));
|
||||
registeredProviders = true;
|
||||
}
|
||||
}
|
||||
public String authId;
|
||||
public String accessToken;
|
||||
public Map<String, String> extended;
|
||||
public boolean needUserInfo;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
|
@ -94,4 +91,9 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
|||
sendResult(new RestoreRequestEvent(invalidTokens));
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ExtendedTokenProvider {
|
||||
boolean accept(Client client, AuthProviderPair pair, String extendedToken);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
|||
if (user == null) {
|
||||
sendError("User not found");
|
||||
return;
|
||||
}
|
||||
else username = user.getUsername();
|
||||
} else username = user.getUsername();
|
||||
} else {
|
||||
username = pair.handler.uuidToUsername(uuid);
|
||||
if (username == null) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package pro.gravit.launchserver.socket.response.update;
|
||||
|
||||
import io.jsonwebtoken.*;
|
||||
import io.jsonwebtoken.JwtParser;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -74,6 +76,14 @@ public String createLauncherExtendedToken() {
|
|||
.compact();
|
||||
}
|
||||
|
||||
private boolean checkSecure(String hash, String salt) {
|
||||
if (hash == null || salt == null) return false;
|
||||
byte[] normal_hash = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA256,
|
||||
server.runtime.clientCheckSecret.concat(".").concat(salt));
|
||||
byte[] launcher_hash = Base64.getDecoder().decode(hash);
|
||||
return Arrays.equals(normal_hash, launcher_hash);
|
||||
}
|
||||
|
||||
public static class LauncherTokenVerifier implements RestoreResponse.ExtendedTokenProvider {
|
||||
private final LaunchServer server;
|
||||
private final JwtParser parser;
|
||||
|
@ -102,12 +112,4 @@ public boolean accept(Client client, AuthProviderPair pair, String extendedToken
|
|||
}
|
||||
}
|
||||
|
||||
private boolean checkSecure(String hash, String salt) {
|
||||
if (hash == null || salt == null) return false;
|
||||
byte[] normal_hash = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA256,
|
||||
server.runtime.clientCheckSecret.concat(".").concat(salt));
|
||||
byte[] launcher_hash = Base64.getDecoder().decode(hash);
|
||||
return Arrays.equals(normal_hash, launcher_hash);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<Configuration status="INFO" packages="pro.gravit.launchserver.config.log4j">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} %highlight{[%-5level]}{FATAL=red, ERROR=red, WARN=yellow, INFO=default, DEBUG=green, TRACE=blue} %highlight{%msg}{FATAL=red, ERROR=red, WARN=yellow, INFO=default, DEBUG=green, TRACE=blue}%n" />
|
||||
<PatternLayout
|
||||
pattern="%d{HH:mm:ss.SSS} %highlight{[%-5level]}{FATAL=red, ERROR=red, WARN=yellow, INFO=default, DEBUG=green, TRACE=blue} %highlight{%msg}{FATAL=red, ERROR=red, WARN=yellow, INFO=default, DEBUG=green, TRACE=blue}%n"/>
|
||||
<Filters>
|
||||
<MarkerFilter marker="JANSI" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
|
||||
<MarkerFilter marker="NOJANSI" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
|
|
|
@ -25,11 +25,7 @@
|
|||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.KeyPair;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
import java.security.interfaces.ECPrivateKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
|
||||
public class ConfigurationTest {
|
||||
@TempDir
|
||||
|
@ -61,6 +57,7 @@ public static void prepare() throws Throwable {
|
|||
.setCommandHandler(new StdCommandHandler(false));
|
||||
launchServer = builder.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reloadTest() throws Exception {
|
||||
AuthProvider provider = new AuthProvider() {
|
||||
|
|
|
@ -13,14 +13,9 @@
|
|||
import pro.gravit.launchserver.manangers.LaunchServerGsonManager;
|
||||
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
||||
import pro.gravit.utils.command.StdCommandHandler;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.security.KeyPair;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
import java.security.interfaces.ECPrivateKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
|
||||
public class StartLaunchServerTest {
|
||||
@TempDir
|
||||
|
|
|
@ -9,6 +9,13 @@
|
|||
public class TestLaunchServerConfigManager implements LaunchServer.LaunchServerConfigManager {
|
||||
public LaunchServerConfig config;
|
||||
public LaunchServerRuntimeConfig runtimeConfig;
|
||||
|
||||
public TestLaunchServerConfigManager() {
|
||||
config = LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST);
|
||||
runtimeConfig = new LaunchServerRuntimeConfig();
|
||||
runtimeConfig.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LaunchServerConfig readConfig() throws IOException {
|
||||
return config;
|
||||
|
@ -28,10 +35,4 @@ public void writeConfig(LaunchServerConfig config) throws IOException {
|
|||
public void writeRuntimeConfig(LaunchServerRuntimeConfig config) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
public TestLaunchServerConfigManager() {
|
||||
config = LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST);
|
||||
runtimeConfig = new LaunchServerRuntimeConfig();
|
||||
runtimeConfig.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<Configuration status="INFO">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} %highlight{[%-5level]}{FATAL=red, ERROR=red, WARN=yellow, INFO=default, DEBUG=green, TRACE=blue} %highlight{%msg}{FATAL=red, ERROR=red, WARN=yellow, INFO=default, DEBUG=green, TRACE=blue}%n" />
|
||||
<PatternLayout
|
||||
pattern="%d{HH:mm:ss.SSS} %highlight{[%-5level]}{FATAL=red, ERROR=red, WARN=yellow, INFO=default, DEBUG=green, TRACE=blue} %highlight{%msg}{FATAL=red, ERROR=red, WARN=yellow, INFO=default, DEBUG=green, TRACE=blue}%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
|
|
|
@ -293,6 +293,7 @@ public static boolean isExistExtJavaLibrary(Path jvmDir, String name) {
|
|||
return IOHelper.isFile(jrePath) || IOHelper.isFile(jdkPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClientLauncherWrapperContext {
|
||||
public JavaVersion javaVersion;
|
||||
public Path executePath;
|
||||
|
@ -305,6 +306,7 @@ public static class ClientLauncherWrapperContext {
|
|||
public List<String> jvmModules = new ArrayList<>();
|
||||
public List<String> clientArgs = new ArrayList<>();
|
||||
public List<Path> javaFXPaths = new ArrayList<>();
|
||||
|
||||
public void addSystemProperty(String name) {
|
||||
String property = System.getProperty(name);
|
||||
if (property != null)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
import pro.gravit.launcher.request.RequestException;
|
||||
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||
import pro.gravit.launcher.request.auth.GetAvailabilityAuthRequest;
|
||||
import pro.gravit.launcher.request.auth.RestoreSessionRequest;
|
||||
import pro.gravit.launcher.request.websockets.StdWebSocketService;
|
||||
import pro.gravit.launcher.utils.NativeJVMHalt;
|
||||
import pro.gravit.utils.helper.*;
|
||||
|
@ -40,12 +39,12 @@ public class LauncherEngine {
|
|||
public static ClientLauncherProcess.ClientParams clientParams;
|
||||
public static LauncherGuardInterface guard;
|
||||
public static ClientModuleManager modulesManager;
|
||||
public final boolean clientInstance;
|
||||
// Instance
|
||||
private final AtomicBoolean started = new AtomicBoolean(false);
|
||||
public RuntimeProvider runtimeProvider;
|
||||
public ECPublicKey publicKey;
|
||||
public ECPrivateKey privateKey;
|
||||
public final boolean clientInstance;
|
||||
|
||||
private LauncherEngine(boolean clientInstance) {
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
import pro.gravit.launcher.request.RequestException;
|
||||
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||
import pro.gravit.launcher.request.auth.GetAvailabilityAuthRequest;
|
||||
import pro.gravit.launcher.request.auth.RestoreSessionRequest;
|
||||
import pro.gravit.launcher.serialize.HInput;
|
||||
import pro.gravit.launcher.utils.DirWatcher;
|
||||
import pro.gravit.utils.helper.*;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
|
||||
public final class ClientModuleManager extends SimpleModuleManager {
|
||||
public ClientModuleManager() {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
import pro.gravit.launcher.ClientLauncherWrapper;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ClientWrapperModule {
|
||||
void wrapperPhase(ClientLauncherWrapper.ClientLauncherWrapperContext context);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ public final class LauncherConfig extends StreamObject {
|
|||
@LauncherInject("launcher.port")
|
||||
public final int clientPort;
|
||||
public final LauncherTrustManager trustManager;
|
||||
@Deprecated
|
||||
public ECPublicKey publicKey = null;
|
||||
public final ECPublicKey ecdsaPublicKey;
|
||||
public final RSAPublicKey rsaPublicKey;
|
||||
public final Map<String, byte[]> runtime;
|
||||
|
@ -48,6 +46,8 @@ public final class LauncherConfig extends StreamObject {
|
|||
public final String runtimeEncryptKey;
|
||||
@LauncherInject("launcher.address")
|
||||
public final String address;
|
||||
@Deprecated
|
||||
public ECPublicKey publicKey = null;
|
||||
@LauncherInject("runtimeconfig.secretKeyClient")
|
||||
public String secretKeyClient;
|
||||
@LauncherInject("runtimeconfig.oemUnlockKey")
|
||||
|
|
|
@ -61,6 +61,11 @@ public AuthRequestEvent(ClientPermissions permissions, PlayerProfile playerProfi
|
|||
this.oauth = oauth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "auth";
|
||||
}
|
||||
|
||||
public static class OAuthRequestEvent {
|
||||
public final String accessToken;
|
||||
public final String refreshToken;
|
||||
|
@ -72,9 +77,4 @@ public OAuthRequestEvent(String accessToken, String refreshToken, long expire) {
|
|||
this.expire = expire;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "auth";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,11 @@ public enum ServerFeature {
|
|||
}
|
||||
}
|
||||
|
||||
public interface AuthAvailabilityDetails extends TypeSerializeInterface {
|
||||
}
|
||||
|
||||
public static class AuthAvailability {
|
||||
public final List<AuthAvailabilityDetails> details;
|
||||
@LauncherNetworkAPI
|
||||
public String name;
|
||||
@LauncherNetworkAPI
|
||||
|
@ -48,8 +52,6 @@ public static class AuthAvailability {
|
|||
@LauncherNetworkAPI
|
||||
public AuthType secondType;
|
||||
|
||||
public final List<AuthAvailabilityDetails> details;
|
||||
|
||||
@Deprecated
|
||||
public AuthAvailability(String name, String displayName, AuthType firstType, AuthType secondType) {
|
||||
this.name = name;
|
||||
|
@ -81,6 +83,4 @@ public enum AuthType {
|
|||
OTHER
|
||||
}
|
||||
}
|
||||
public interface AuthAvailabilityDetails extends TypeSerializeInterface {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
|
||||
public class LauncherRequestEvent extends RequestEvent {
|
||||
public static final String LAUNCHER_EXTENDED_TOKEN_NAME = "launcher";
|
||||
@SuppressWarnings("unused")
|
||||
private static final UUID uuid = UUID.fromString("d54cc12a-4f59-4f23-9b10-f527fdd2e38f");
|
||||
public static final String LAUNCHER_EXTENDED_TOKEN_NAME = "launcher";
|
||||
@LauncherNetworkAPI
|
||||
public String url;
|
||||
@LauncherNetworkAPI
|
||||
|
|
|
@ -5,26 +5,15 @@
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class LauncherModule {
|
||||
protected final LauncherModuleInfo moduleInfo;
|
||||
private final static class EventEntity<T extends Event> {
|
||||
final Class<T> clazz;
|
||||
final EventHandler<T> handler;
|
||||
|
||||
private EventEntity(EventHandler<T> handler, Class<T> clazz) {
|
||||
this.clazz = clazz;
|
||||
this.handler = handler;
|
||||
}
|
||||
}
|
||||
private final List<EventEntity<? extends Event>> eventList = new ArrayList<>(4);
|
||||
protected LauncherModulesManager modulesManager;
|
||||
protected ModulesConfigManager modulesConfigManager;
|
||||
protected InitStatus initStatus = InitStatus.CREATED;
|
||||
private LauncherModulesContext context;
|
||||
private LauncherTrustManager.CheckClassResult checkResult;
|
||||
|
||||
protected LauncherModule() {
|
||||
moduleInfo = new LauncherModuleInfo("UnknownModule");
|
||||
}
|
||||
|
@ -70,6 +59,17 @@ public final LauncherTrustManager.CheckClassResult getCheckResult() {
|
|||
return new LauncherTrustManager.CheckClassResult(this.checkResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal method used by the ModuleManager
|
||||
* DO NOT TOUCH
|
||||
*
|
||||
* @param result Check result
|
||||
*/
|
||||
public final void setCheckResult(LauncherTrustManager.CheckClassResult result) {
|
||||
if (this.checkResult != null) throw new IllegalStateException("Module already set check result");
|
||||
this.checkResult = result;
|
||||
}
|
||||
|
||||
protected final LauncherModule requireModule(String name, Version minVersion) {
|
||||
if (context == null) throw new IllegalStateException("requireModule must be used in init() phase");
|
||||
LauncherModule module = context.getModulesManager().getModule(name);
|
||||
|
@ -91,17 +91,6 @@ else if(module.moduleInfo.version.isLowerThan(minVersion))
|
|||
throw new RuntimeException(String.format("Module %s required %s v%s or higher (current version %s)", moduleInfo.name, requiredModuleName, minVersion.getVersionString(), module.moduleInfo.version.getVersionString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal method used by the ModuleManager
|
||||
* DO NOT TOUCH
|
||||
*
|
||||
* @param result Check result
|
||||
*/
|
||||
public final void setCheckResult(LauncherTrustManager.CheckClassResult result) {
|
||||
if (this.checkResult != null) throw new IllegalStateException("Module already set check result");
|
||||
this.checkResult = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called before initializing all modules and resolving dependencies.
|
||||
* <b>You can</b>:
|
||||
|
@ -213,12 +202,21 @@ public boolean isAvailable() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface EventHandler<T extends Event> {
|
||||
void event(T e);
|
||||
}
|
||||
|
||||
private final static class EventEntity<T extends Event> {
|
||||
final Class<T> clazz;
|
||||
final EventHandler<T> handler;
|
||||
|
||||
private EventEntity(EventHandler<T> handler, Class<T> clazz) {
|
||||
this.clazz = clazz;
|
||||
this.handler = handler;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Event {
|
||||
protected boolean cancel = false;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import pro.gravit.launcher.LauncherNetworkAPI;
|
||||
import pro.gravit.launcher.hasher.FileNameMatcher;
|
||||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.profiles.optional.OptionalDepend;
|
||||
import pro.gravit.launcher.profiles.optional.OptionalFile;
|
||||
import pro.gravit.launcher.profiles.optional.OptionalTrigger;
|
||||
|
@ -83,6 +82,59 @@ public final class ClientProfile implements Comparable<ClientProfile> {
|
|||
@LauncherNetworkAPI
|
||||
private String mainClass;
|
||||
|
||||
public ClientProfile() {
|
||||
update = new ArrayList<>();
|
||||
updateExclusions = new ArrayList<>();
|
||||
updateShared = new ArrayList<>();
|
||||
updateVerify = new ArrayList<>();
|
||||
updateOptional = new HashSet<>();
|
||||
jvmArgs = new ArrayList<>();
|
||||
classPath = new ArrayList<>();
|
||||
altClassPath = new ArrayList<>();
|
||||
clientArgs = new ArrayList<>();
|
||||
compatClasses = new ArrayList<>();
|
||||
properties = new HashMap<>();
|
||||
servers = new ArrayList<>(1);
|
||||
securityManagerConfig = SecurityManagerConfig.CLIENT;
|
||||
classLoaderConfig = ClassLoaderConfig.LAUNCHER;
|
||||
signedClientConfig = SignedClientConfig.NONE;
|
||||
runtimeInClientConfig = RuntimeInClientConfig.NONE;
|
||||
}
|
||||
|
||||
public ClientProfile(List<String> update, List<String> updateExclusions, List<String> updateShared, List<String> updateVerify, Set<OptionalFile> updateOptional, List<String> jvmArgs, List<String> classPath, List<String> altClassPath, List<String> clientArgs, List<String> compatClasses, Map<String, String> properties, List<ServerProfile> servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) {
|
||||
this.update = update;
|
||||
this.updateExclusions = updateExclusions;
|
||||
this.updateShared = updateShared;
|
||||
this.updateVerify = updateVerify;
|
||||
this.updateOptional = updateOptional;
|
||||
this.jvmArgs = jvmArgs;
|
||||
this.classPath = classPath;
|
||||
this.altClassPath = altClassPath;
|
||||
this.clientArgs = clientArgs;
|
||||
this.compatClasses = compatClasses;
|
||||
this.properties = properties;
|
||||
this.servers = servers;
|
||||
this.securityManagerConfig = securityManagerConfig;
|
||||
this.classLoaderConfig = classLoaderConfig;
|
||||
this.signedClientConfig = signedClientConfig;
|
||||
this.runtimeInClientConfig = runtimeInClientConfig;
|
||||
this.version = version;
|
||||
this.assetIndex = assetIndex;
|
||||
this.dir = dir;
|
||||
this.assetDir = assetDir;
|
||||
this.recommendJavaVersion = recommendJavaVersion;
|
||||
this.minJavaVersion = minJavaVersion;
|
||||
this.maxJavaVersion = maxJavaVersion;
|
||||
this.warnMissJavaVersion = warnMissJavaVersion;
|
||||
this.settings = settings;
|
||||
this.sortIndex = sortIndex;
|
||||
this.uuid = uuid;
|
||||
this.title = title;
|
||||
this.info = info;
|
||||
this.updateFastCheck = updateFastCheck;
|
||||
this.mainClass = mainClass;
|
||||
}
|
||||
|
||||
public ServerProfile getDefaultServerProfile() {
|
||||
for (ServerProfile profile : servers) {
|
||||
if (profile.isDefault) return profile;
|
||||
|
@ -205,8 +257,6 @@ public void updateOptionalGraph() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Deprecated
|
||||
public OptionalFile getOptionalFile(String file, OptionalType type) {
|
||||
for (OptionalFile f : updateOptional)
|
||||
|
@ -406,8 +456,6 @@ public void setRuntimeInClientConfig(RuntimeInClientConfig runtimeInClientConfig
|
|||
this.runtimeInClientConfig = runtimeInClientConfig;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum Version {
|
||||
MC125("1.2.5", 29),
|
||||
MC147("1.4.7", 51),
|
||||
|
@ -495,10 +543,6 @@ public static class ServerProfile {
|
|||
public int serverPort;
|
||||
public boolean isDefault = true;
|
||||
|
||||
public InetSocketAddress toSocketAddress() {
|
||||
return InetSocketAddress.createUnresolved(serverAddress, serverPort);
|
||||
}
|
||||
|
||||
public ServerProfile() {
|
||||
}
|
||||
|
||||
|
@ -514,6 +558,10 @@ public ServerProfile(String name, String serverAddress, int serverPort, boolean
|
|||
this.serverPort = serverPort;
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public InetSocketAddress toSocketAddress() {
|
||||
return InetSocketAddress.createUnresolved(serverAddress, serverPort);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ProfileDefaultSettings {
|
||||
|
@ -521,57 +569,4 @@ public static class ProfileDefaultSettings {
|
|||
public boolean autoEnter;
|
||||
public boolean fullScreen;
|
||||
}
|
||||
|
||||
public ClientProfile() {
|
||||
update = new ArrayList<>();
|
||||
updateExclusions = new ArrayList<>();
|
||||
updateShared = new ArrayList<>();
|
||||
updateVerify = new ArrayList<>();
|
||||
updateOptional = new HashSet<>();
|
||||
jvmArgs = new ArrayList<>();
|
||||
classPath = new ArrayList<>();
|
||||
altClassPath = new ArrayList<>();
|
||||
clientArgs = new ArrayList<>();
|
||||
compatClasses = new ArrayList<>();
|
||||
properties = new HashMap<>();
|
||||
servers = new ArrayList<>(1);
|
||||
securityManagerConfig = SecurityManagerConfig.CLIENT;
|
||||
classLoaderConfig = ClassLoaderConfig.LAUNCHER;
|
||||
signedClientConfig = SignedClientConfig.NONE;
|
||||
runtimeInClientConfig = RuntimeInClientConfig.NONE;
|
||||
}
|
||||
|
||||
public ClientProfile(List<String> update, List<String> updateExclusions, List<String> updateShared, List<String> updateVerify, Set<OptionalFile> updateOptional, List<String> jvmArgs, List<String> classPath, List<String> altClassPath, List<String> clientArgs, List<String> compatClasses, Map<String, String> properties, List<ServerProfile> servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) {
|
||||
this.update = update;
|
||||
this.updateExclusions = updateExclusions;
|
||||
this.updateShared = updateShared;
|
||||
this.updateVerify = updateVerify;
|
||||
this.updateOptional = updateOptional;
|
||||
this.jvmArgs = jvmArgs;
|
||||
this.classPath = classPath;
|
||||
this.altClassPath = altClassPath;
|
||||
this.clientArgs = clientArgs;
|
||||
this.compatClasses = compatClasses;
|
||||
this.properties = properties;
|
||||
this.servers = servers;
|
||||
this.securityManagerConfig = securityManagerConfig;
|
||||
this.classLoaderConfig = classLoaderConfig;
|
||||
this.signedClientConfig = signedClientConfig;
|
||||
this.runtimeInClientConfig = runtimeInClientConfig;
|
||||
this.version = version;
|
||||
this.assetIndex = assetIndex;
|
||||
this.dir = dir;
|
||||
this.assetDir = assetDir;
|
||||
this.recommendJavaVersion = recommendJavaVersion;
|
||||
this.minJavaVersion = minJavaVersion;
|
||||
this.maxJavaVersion = maxJavaVersion;
|
||||
this.warnMissJavaVersion = warnMissJavaVersion;
|
||||
this.settings = settings;
|
||||
this.sortIndex = sortIndex;
|
||||
this.uuid = uuid;
|
||||
this.title = title;
|
||||
this.info = info;
|
||||
this.updateFastCheck = updateFastCheck;
|
||||
this.mainClass = mainClass;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,6 @@ public class OptionalView {
|
|||
public Map<OptionalFile, Set<OptionalFile>> dependenciesCountMap = new HashMap<>();
|
||||
public Map<OptionalFile, OptionalFileInstallInfo> installInfo = new HashMap<>();
|
||||
public Set<OptionalFile> all;
|
||||
public static class OptionalFileInstallInfo {
|
||||
public boolean isManual;
|
||||
}
|
||||
|
||||
public OptionalView(ClientProfile profile) {
|
||||
this.all = profile.getOptional();
|
||||
|
@ -162,4 +159,8 @@ private boolean contains(OptionalFile file, OptionalFile[] array) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class OptionalFileInstallInfo {
|
||||
public boolean isManual;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class Request<R extends WebSocketEvent> implements WebSocketRequest {
|
||||
public static StdWebSocketService service;
|
||||
|
@ -25,9 +23,6 @@ public abstract class Request<R extends WebSocketEvent> implements WebSocketRequ
|
|||
private static String authId;
|
||||
private static long tokenExpiredTime;
|
||||
private static List<ExtendedTokenCallback> extendedTokenCallbacks = new ArrayList<>(4);
|
||||
public interface ExtendedTokenCallback {
|
||||
String tryGetNewToken(String name);
|
||||
}
|
||||
@LauncherNetworkAPI
|
||||
public final UUID requestUUID = UUID.randomUUID();
|
||||
private transient final AtomicBoolean started = new AtomicBoolean(false);
|
||||
|
@ -50,10 +45,6 @@ public static void setOAuth(String authId, AuthRequestEvent.OAuthRequestEvent ev
|
|||
}
|
||||
}
|
||||
|
||||
public void addExtendedTokenCallback(ExtendedTokenCallback cb) {
|
||||
extendedTokenCallbacks.add(cb);
|
||||
}
|
||||
|
||||
public static AuthRequestEvent.OAuthRequestEvent getOAuth() {
|
||||
return oauth;
|
||||
}
|
||||
|
@ -159,6 +150,10 @@ public static void requestError(String message) throws RequestException {
|
|||
throw new RequestException(message);
|
||||
}
|
||||
|
||||
public void addExtendedTokenCallback(ExtendedTokenCallback cb) {
|
||||
extendedTokenCallbacks.add(cb);
|
||||
}
|
||||
|
||||
public R request() throws Exception {
|
||||
if (!started.compareAndSet(false, true))
|
||||
throw new IllegalStateException("Request already started");
|
||||
|
@ -167,7 +162,6 @@ public R request() throws Exception {
|
|||
return requestDo(service);
|
||||
}
|
||||
|
||||
|
||||
public R request(StdWebSocketService service) throws Exception {
|
||||
if (!started.compareAndSet(false, true))
|
||||
throw new IllegalStateException("Request already started");
|
||||
|
@ -178,4 +172,8 @@ protected R requestDo(StdWebSocketService service) throws Exception {
|
|||
return service.requestSync(this);
|
||||
}
|
||||
|
||||
public interface ExtendedTokenCallback {
|
||||
String tryGetNewToken(String name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
import pro.gravit.launcher.LauncherNetworkAPI;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
import pro.gravit.launcher.request.auth.details.AuthPasswordDetails;
|
||||
import pro.gravit.launcher.request.auth.details.AuthWebViewDetails;
|
||||
import pro.gravit.launcher.request.auth.password.*;
|
||||
import pro.gravit.launcher.request.websockets.WebSocketRequest;
|
||||
import pro.gravit.utils.ProviderMap;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import pro.gravit.launcher.LauncherNetworkAPI;
|
||||
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||
|
||||
@Deprecated
|
||||
public class AuthECPassword implements AuthRequest.AuthPasswordInterface {
|
||||
@LauncherNetworkAPI
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
public class AuthMultiPassword implements AuthRequest.AuthPasswordInterface {
|
||||
public List<AuthRequest.AuthPasswordInterface> list;
|
||||
|
||||
@Override
|
||||
public boolean check() {
|
||||
return list != null && list.stream().allMatch(l -> l != null && l.check());
|
||||
|
|
|
@ -24,6 +24,22 @@ public Version(int major, int minor, int patch) {
|
|||
release = Type.UNKNOWN;
|
||||
}
|
||||
|
||||
public Version(int major, int minor, int patch, int build) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.patch = patch;
|
||||
this.build = build;
|
||||
release = Type.UNKNOWN;
|
||||
}
|
||||
|
||||
public Version(int major, int minor, int patch, int build, Type release) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.patch = patch;
|
||||
this.build = build;
|
||||
this.release = release;
|
||||
}
|
||||
|
||||
public static Version of(int major, int minor, int patch) {
|
||||
return new Version(major, minor, patch);
|
||||
}
|
||||
|
@ -36,24 +52,6 @@ public static Version of(int major, int minor, int patch, int build, Type releas
|
|||
return new Version(major, minor, patch, build, release);
|
||||
}
|
||||
|
||||
|
||||
public Version(int major, int minor, int patch, int build) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.patch = patch;
|
||||
this.build = build;
|
||||
release = Type.UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
public Version(int major, int minor, int patch, int build, Type release) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.patch = patch;
|
||||
this.build = build;
|
||||
this.release = release;
|
||||
}
|
||||
|
||||
public static Version getVersion() {
|
||||
return new Version(MAJOR, MINOR, PATCH, BUILD, RELEASE);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import pro.gravit.utils.command.Command;
|
||||
import pro.gravit.utils.command.CommandException;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
import pro.gravit.utils.helper.FormatHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
import javax.script.ScriptEngineFactory;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue