mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FEATURE] Блокировка консоли лаунчера
This commit is contained in:
parent
b432f8f13f
commit
02613ceef4
10 changed files with 83 additions and 12 deletions
|
@ -303,7 +303,7 @@ function doLaunchClient(assetDir, assetHDir, clientDir, clientHDir, profile, pp,
|
||||||
}
|
}
|
||||||
|
|
||||||
function doDebugClient(process) {
|
function doDebugClient(process) {
|
||||||
if (!LogHelper.isDebugEnabled()) {
|
if (!settings.debug) {
|
||||||
javafx.application.Platform.exit();
|
javafx.application.Platform.exit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ function makeAuthRequest(login, rsaPassword, callback) {
|
||||||
|
|
||||||
function launchClient(assetHDir, clientHDir, profile, params, callback) {
|
function launchClient(assetHDir, clientHDir, profile, params, callback) {
|
||||||
var task = newTask(function() ClientLauncher.launch(assetHDir, clientHDir,
|
var task = newTask(function() ClientLauncher.launch(assetHDir, clientHDir,
|
||||||
profile, params, LogHelper.isDebugEnabled()));
|
profile, params, settings.debug));
|
||||||
processing.setTaskProperties(task, callback, null, true);
|
processing.setTaskProperties(task, callback, null, true);
|
||||||
task.updateMessage("Запуск выбранного клиента");
|
task.updateMessage("Запуск выбранного клиента");
|
||||||
startTask(task);
|
startTask(task);
|
||||||
|
|
|
@ -79,9 +79,9 @@ var settingsOverlay = {
|
||||||
});
|
});
|
||||||
|
|
||||||
var debugBox = settingsOverlay.overlay.lookup("#debug");
|
var debugBox = settingsOverlay.overlay.lookup("#debug");
|
||||||
debugBox.setSelected(LogHelper.isDebugEnabled());
|
debugBox.setSelected(settings.debug);
|
||||||
debugBox.selectedProperty()["addListener(javafx.beans.value.ChangeListener)"](
|
debugBox.selectedProperty()["addListener(javafx.beans.value.ChangeListener)"](
|
||||||
function(o, ov, nv) LogHelper.setDebugEnabled(nv));
|
function(o, ov, nv) settings.debug = nv);
|
||||||
|
|
||||||
holder.lookup("#apply").setOnAction(function(event) overlay.hide(0, null));
|
holder.lookup("#apply").setOnAction(function(event) overlay.hide(0, null));
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,25 +16,45 @@
|
||||||
|
|
||||||
public class ClientLauncherWrapper {
|
public class ClientLauncherWrapper {
|
||||||
public static final String MAGIC_ARG = "-Djdk.attach.allowAttachSelf";
|
public static final String MAGIC_ARG = "-Djdk.attach.allowAttachSelf";
|
||||||
|
public static final String WAIT_PROCESS_PROPERTY = "launcher.waitProcess";
|
||||||
|
public static boolean waitProcess = Boolean.getBoolean(WAIT_PROCESS_PROPERTY);
|
||||||
|
|
||||||
public static void main(String[] arguments) throws IOException, InterruptedException {
|
public static void main(String[] arguments) throws IOException, InterruptedException {
|
||||||
LogHelper.printVersion("Launcher");
|
LogHelper.printVersion("Launcher");
|
||||||
LogHelper.printLicense("Launcher");
|
LogHelper.printLicense("Launcher");
|
||||||
LogHelper.info("Restart Launcher with JavaAgent...");
|
|
||||||
LogHelper.info("If need debug output use -Dlauncher.debug=true");
|
|
||||||
LogHelper.info("If need stacktrace output use -Dlauncher.stacktrace=true");
|
|
||||||
JVMHelper.checkStackTrace(ClientLauncherWrapper.class);
|
JVMHelper.checkStackTrace(ClientLauncherWrapper.class);
|
||||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||||
EnvHelper.checkDangerousParams();
|
EnvHelper.checkDangerousParams();
|
||||||
LogHelper.debug("Restart Launcher");
|
LauncherConfig config = Launcher.getConfig();
|
||||||
|
LogHelper.info("Launcher for project %s", config.projectname);
|
||||||
|
if(config.environment.equals(LauncherConfig.LauncherEnvironment.PROD))
|
||||||
|
{
|
||||||
|
if(System.getProperty(LogHelper.DEBUG_PROPERTY) != null)
|
||||||
|
{
|
||||||
|
LogHelper.warning("Found -Dlauncher.debug=true");
|
||||||
|
}
|
||||||
|
if(System.getProperty(LogHelper.STACKTRACE_PROPERTY) != null)
|
||||||
|
{
|
||||||
|
LogHelper.warning("Found -Dlauncher.stacktrace=true");
|
||||||
|
}
|
||||||
|
LogHelper.info("Debug mode disabled (found env PRODUCTION)");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogHelper.info("If need debug output use -Dlauncher.debug=true");
|
||||||
|
LogHelper.info("If need stacktrace output use -Dlauncher.stacktrace=true");
|
||||||
|
if(LogHelper.isDebugEnabled()) waitProcess = true;
|
||||||
|
}
|
||||||
|
LogHelper.info("Restart Launcher with JavaAgent...");
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||||
if (LogHelper.isDebugEnabled()) processBuilder.inheritIO();
|
if(waitProcess) processBuilder.inheritIO();
|
||||||
Path javaBin = IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home")));
|
Path javaBin = IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home")));
|
||||||
List<String> args = new LinkedList<>();
|
List<String> args = new LinkedList<>();
|
||||||
args.add(javaBin.toString());
|
args.add(javaBin.toString());
|
||||||
String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString();
|
String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString();
|
||||||
args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled())));
|
args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled())));
|
||||||
args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled())));
|
args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled())));
|
||||||
|
args.add(JVMHelper.jvmProperty(LogHelper.DEV_PROPERTY, Boolean.toString(LogHelper.isDevEnabled())));
|
||||||
JVMHelper.addSystemPropertyToArgs(args, DirBridge.CUSTOMDIR_PROPERTY);
|
JVMHelper.addSystemPropertyToArgs(args, DirBridge.CUSTOMDIR_PROPERTY);
|
||||||
JVMHelper.addSystemPropertyToArgs(args, DirBridge.USE_CUSTOMDIR_PROPERTY);
|
JVMHelper.addSystemPropertyToArgs(args, DirBridge.USE_CUSTOMDIR_PROPERTY);
|
||||||
JVMHelper.addSystemPropertyToArgs(args, DirBridge.USE_OPTDIR_PROPERTY);
|
JVMHelper.addSystemPropertyToArgs(args, DirBridge.USE_OPTDIR_PROPERTY);
|
||||||
|
@ -48,7 +68,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
LogHelper.debug("Commandline: " + args);
|
LogHelper.debug("Commandline: " + args);
|
||||||
processBuilder.command(args);
|
processBuilder.command(args);
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
if (!LogHelper.isDebugEnabled()) {
|
if (!waitProcess) {
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
if (!process.isAlive()) {
|
if (!process.isAlive()) {
|
||||||
int errorcode = process.exitValue();
|
int errorcode = process.exitValue();
|
||||||
|
|
|
@ -31,7 +31,11 @@ public static void main(String... args) throws Throwable {
|
||||||
// Start Launcher
|
// Start Launcher
|
||||||
initGson();
|
initGson();
|
||||||
ConsoleManager.initConsole();
|
ConsoleManager.initConsole();
|
||||||
LogHelper.setStacktraceEnabled(true);
|
LauncherConfig config = Launcher.getConfig();
|
||||||
|
if(config.environment.equals(LauncherConfig.LauncherEnvironment.PROD))
|
||||||
|
{
|
||||||
|
if(!LauncherAgent.isStarted()) throw new SecurityException("LauncherAgent must started");
|
||||||
|
}
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
new LauncherEngine().start(args);
|
new LauncherEngine().start(args);
|
||||||
|
|
|
@ -21,6 +21,8 @@ public class NewLauncherSettings {
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public boolean autoEnter;
|
public boolean autoEnter;
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
public boolean debug;
|
||||||
|
@LauncherAPI
|
||||||
public boolean fullScreen;
|
public boolean fullScreen;
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public boolean offline;
|
public boolean offline;
|
||||||
|
|
|
@ -375,7 +375,7 @@ public static Process launch(
|
||||||
}
|
}
|
||||||
// Let's rock!
|
// Let's rock!
|
||||||
process = builder.start();
|
process = builder.start();
|
||||||
if (!LogHelper.isDebugEnabled()) {
|
if (!pipeOutput) {
|
||||||
for (int i = 0; i < 50; ++i) {
|
for (int i = 0; i < 50; ++i) {
|
||||||
if (!process.isAlive()) {
|
if (!process.isAlive()) {
|
||||||
int exitCode = process.exitValue();
|
int exitCode = process.exitValue();
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package ru.gravit.launcher.console;
|
||||||
|
|
||||||
|
import ru.gravit.launcher.managers.ConsoleManager;
|
||||||
|
import ru.gravit.utils.command.Command;
|
||||||
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
public class UnlockCommand extends Command {
|
||||||
|
@Override
|
||||||
|
public String getArgsDescription() {
|
||||||
|
return "[key]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsageDescription() {
|
||||||
|
return "Unlock other commands";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(String... args) throws Exception {
|
||||||
|
verifyArgs(args, 1);
|
||||||
|
if(ConsoleManager.checkUnlockKey(args[0]))
|
||||||
|
{
|
||||||
|
LogHelper.info("Unlock successful");
|
||||||
|
ConsoleManager.unlock();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogHelper.error("Unlock key incorrect");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package ru.gravit.launcher.managers;
|
package ru.gravit.launcher.managers;
|
||||||
|
|
||||||
|
import ru.gravit.launcher.console.UnlockCommand;
|
||||||
import ru.gravit.utils.command.CommandHandler;
|
import ru.gravit.utils.command.CommandHandler;
|
||||||
import ru.gravit.utils.command.JLineCommandHandler;
|
import ru.gravit.utils.command.JLineCommandHandler;
|
||||||
import ru.gravit.utils.command.StdCommandHandler;
|
import ru.gravit.utils.command.StdCommandHandler;
|
||||||
|
@ -33,5 +34,14 @@ public static void initConsole() throws IOException
|
||||||
public static void registerCommands()
|
public static void registerCommands()
|
||||||
{
|
{
|
||||||
handler.registerCommand("help", new HelpCommand(handler));
|
handler.registerCommand("help", new HelpCommand(handler));
|
||||||
|
handler.registerCommand("unlock", new UnlockCommand());
|
||||||
|
}
|
||||||
|
public static boolean checkUnlockKey(String key)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public static void unlock()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ public static AutogenConfig getAutogenConfig() {
|
||||||
public final Map<String, byte[]> runtime;
|
public final Map<String, byte[]> runtime;
|
||||||
public final boolean isWarningMissArchJava;
|
public final boolean isWarningMissArchJava;
|
||||||
public boolean isNettyEnabled;
|
public boolean isNettyEnabled;
|
||||||
|
public LauncherEnvironment environment;
|
||||||
|
|
||||||
public final String guardLicenseName;
|
public final String guardLicenseName;
|
||||||
public final String guardLicenseKey;
|
public final String guardLicenseKey;
|
||||||
|
@ -58,6 +59,7 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
|
||||||
else if (config.env == 3) env = LauncherEnvironment.PROD;
|
else if (config.env == 3) env = LauncherEnvironment.PROD;
|
||||||
else env = LauncherEnvironment.STD;
|
else env = LauncherEnvironment.STD;
|
||||||
Launcher.applyLauncherEnv(env);
|
Launcher.applyLauncherEnv(env);
|
||||||
|
environment = env;
|
||||||
// Read signed runtime
|
// Read signed runtime
|
||||||
int count = input.readLength(0);
|
int count = input.readLength(0);
|
||||||
Map<String, byte[]> localResources = new HashMap<>(count);
|
Map<String, byte[]> localResources = new HashMap<>(count);
|
||||||
|
@ -83,6 +85,7 @@ public LauncherConfig(String address, RSAPublicKey publicKey, Map<String, byte[]
|
||||||
guardType = "no";
|
guardType = "no";
|
||||||
isWarningMissArchJava = true;
|
isWarningMissArchJava = true;
|
||||||
isNettyEnabled = false;
|
isNettyEnabled = false;
|
||||||
|
environment = LauncherEnvironment.STD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
@ -98,6 +101,7 @@ public LauncherConfig(String address, RSAPublicKey publicKey, Map<String, byte[]
|
||||||
guardType = "no";
|
guardType = "no";
|
||||||
isWarningMissArchJava = true;
|
isWarningMissArchJava = true;
|
||||||
isNettyEnabled = false;
|
isNettyEnabled = false;
|
||||||
|
environment = LauncherEnvironment.STD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue