mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Сокетная передача параметров
This commit is contained in:
parent
87fb00de54
commit
a32434e446
1 changed files with 52 additions and 15 deletions
|
@ -6,7 +6,7 @@
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
import java.net.URL;
|
import java.net.*;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.FileVisitResult;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -303,12 +303,32 @@ public static Process launch(
|
||||||
// Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars)
|
// Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars)
|
||||||
LogHelper.debug("Writing ClientLauncher params");
|
LogHelper.debug("Writing ClientLauncher params");
|
||||||
Path paramsFile = Files.createTempFile("ClientLauncherParams", ".bin");
|
Path paramsFile = Files.createTempFile("ClientLauncherParams", ".bin");
|
||||||
try (HOutput output = new HOutput(IOHelper.newOutput(paramsFile))) {
|
CommonHelper.newThread("Client params writter",false,() ->
|
||||||
params.write(output);
|
{
|
||||||
profile.write(output);
|
try {
|
||||||
assetHDir.write(output);
|
try (ServerSocket socket = new ServerSocket()) {
|
||||||
clientHDir.write(output);
|
socket.setReuseAddress(true);
|
||||||
}
|
socket.bind(new InetSocketAddress("127.0.0.1", 54983));
|
||||||
|
Socket client = socket.accept();
|
||||||
|
try (HOutput output = new HOutput(client.getOutputStream())) {
|
||||||
|
params.write(output);
|
||||||
|
profile.write(output);
|
||||||
|
assetHDir.write(output);
|
||||||
|
clientHDir.write(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogHelper.error(e);
|
||||||
|
try (HOutput output = new HOutput(IOHelper.newOutput(paramsFile))) {
|
||||||
|
params.write(output);
|
||||||
|
profile.write(output);
|
||||||
|
assetHDir.write(output);
|
||||||
|
clientHDir.write(output);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
LogHelper.error(e1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
// Resolve java bin and set permissions
|
// Resolve java bin and set permissions
|
||||||
LogHelper.debug("Resolving JVM binary");
|
LogHelper.debug("Resolving JVM binary");
|
||||||
//Path javaBin = IOHelper.resolveJavaBin(jvmDir);
|
//Path javaBin = IOHelper.resolveJavaBin(jvmDir);
|
||||||
|
@ -394,16 +414,33 @@ public static void main(String... args) throws Throwable {
|
||||||
SignedObjectHolder<ClientProfile> profile;
|
SignedObjectHolder<ClientProfile> profile;
|
||||||
SignedObjectHolder<HashedDir> assetHDir, clientHDir;
|
SignedObjectHolder<HashedDir> assetHDir, clientHDir;
|
||||||
RSAPublicKey publicKey = Launcher.getConfig().publicKey;
|
RSAPublicKey publicKey = Launcher.getConfig().publicKey;
|
||||||
try (HInput input = new HInput(IOHelper.newInput(paramsFile))) {
|
try {
|
||||||
params = new Params(input);
|
try (Socket socket = IOHelper.newSocket()) {
|
||||||
profile = new SignedObjectHolder<>(input, publicKey, ClientProfile.RO_ADAPTER);
|
socket.connect(new InetSocketAddress("127.0.0.1", 54983));
|
||||||
|
try (HInput input = new HInput(socket.getInputStream())) {
|
||||||
|
params = new Params(input);
|
||||||
|
profile = new SignedObjectHolder<>(input, publicKey, ClientProfile.RO_ADAPTER);
|
||||||
|
|
||||||
// Read hdirs
|
// Read hdirs
|
||||||
assetHDir = new SignedObjectHolder<>(input, publicKey, HashedDir::new);
|
assetHDir = new SignedObjectHolder<>(input, publicKey, HashedDir::new);
|
||||||
clientHDir = new SignedObjectHolder<>(input, publicKey, HashedDir::new);
|
clientHDir = new SignedObjectHolder<>(input, publicKey, HashedDir::new);
|
||||||
} finally {
|
}
|
||||||
Files.delete(paramsFile);
|
}
|
||||||
|
} catch (IOException ex)
|
||||||
|
{
|
||||||
|
LogHelper.error(ex);
|
||||||
|
try (HInput input = new HInput(IOHelper.newInput(paramsFile))) {
|
||||||
|
params = new Params(input);
|
||||||
|
profile = new SignedObjectHolder<>(input, publicKey, ClientProfile.RO_ADAPTER);
|
||||||
|
|
||||||
|
// Read hdirs
|
||||||
|
assetHDir = new SignedObjectHolder<>(input, publicKey, HashedDir::new);
|
||||||
|
clientHDir = new SignedObjectHolder<>(input, publicKey, HashedDir::new);
|
||||||
|
} finally {
|
||||||
|
Files.delete(paramsFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
title = params.title;
|
title = params.title;
|
||||||
Launcher.modulesManager.initModules();
|
Launcher.modulesManager.initModules();
|
||||||
// Verify ClientLauncher sign and classpath
|
// Verify ClientLauncher sign and classpath
|
||||||
|
|
Loading…
Reference in a new issue