mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Сохранение сессий лаунчера при старте клиента
This commit is contained in:
parent
0c9bb41bee
commit
ece52dd025
2 changed files with 16 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
||||||
import ru.gravit.launcher.hasher.HashedDir;
|
import ru.gravit.launcher.hasher.HashedDir;
|
||||||
import ru.gravit.launcher.profiles.ClientProfile;
|
import ru.gravit.launcher.profiles.ClientProfile;
|
||||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||||
|
import ru.gravit.launcher.request.Request;
|
||||||
import ru.gravit.launcher.request.update.LegacyLauncherRequest;
|
import ru.gravit.launcher.request.update.LegacyLauncherRequest;
|
||||||
import ru.gravit.launcher.serialize.HInput;
|
import ru.gravit.launcher.serialize.HInput;
|
||||||
import ru.gravit.launcher.serialize.HOutput;
|
import ru.gravit.launcher.serialize.HOutput;
|
||||||
|
@ -80,6 +81,8 @@ public static final class Params extends StreamObject {
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public final int height;
|
public final int height;
|
||||||
private final byte[] launcherDigest;
|
private final byte[] launcherDigest;
|
||||||
|
@LauncherAPI
|
||||||
|
public final long session;
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfile pp, String accessToken,
|
public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfile pp, String accessToken,
|
||||||
|
@ -100,11 +103,13 @@ public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfil
|
||||||
this.ram = ram;
|
this.ram = ram;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
this.session = Request.getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public Params(HInput input) throws Exception {
|
public Params(HInput input) throws Exception {
|
||||||
launcherDigest = input.readByteArray(0);
|
launcherDigest = input.readByteArray(0);
|
||||||
|
session = input.readLong();
|
||||||
// Client paths
|
// Client paths
|
||||||
assetDir = IOHelper.toPath(input.readString(0));
|
assetDir = IOHelper.toPath(input.readString(0));
|
||||||
clientDir = IOHelper.toPath(input.readString(0));
|
clientDir = IOHelper.toPath(input.readString(0));
|
||||||
|
@ -128,6 +133,7 @@ public Params(HInput input) throws Exception {
|
||||||
@Override
|
@Override
|
||||||
public void write(HOutput output) throws IOException {
|
public void write(HOutput output) throws IOException {
|
||||||
output.writeByteArray(launcherDigest, 0);
|
output.writeByteArray(launcherDigest, 0);
|
||||||
|
output.writeLong(session);
|
||||||
// Client paths
|
// Client paths
|
||||||
output.writeString(assetDir.toString(), 0);
|
output.writeString(assetDir.toString(), 0);
|
||||||
output.writeString(clientDir.toString(), 0);
|
output.writeString(clientDir.toString(), 0);
|
||||||
|
@ -443,6 +449,7 @@ public static void main(String... args) throws Throwable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Launcher.profile = profile;
|
Launcher.profile = profile;
|
||||||
|
Request.setSession(params.session);
|
||||||
Launcher.modulesManager.initModules();
|
Launcher.modulesManager.initModules();
|
||||||
// Verify ClientLauncher sign and classpath
|
// Verify ClientLauncher sign and classpath
|
||||||
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
||||||
|
|
|
@ -13,7 +13,15 @@
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public abstract class Request<R> {
|
public abstract class Request<R> {
|
||||||
private static final long session = SecurityHelper.secureRandom.nextLong();
|
private static long session = SecurityHelper.secureRandom.nextLong();
|
||||||
|
|
||||||
|
public static void setSession(long session) {
|
||||||
|
Request.session = session;
|
||||||
|
}
|
||||||
|
public static long getSession()
|
||||||
|
{
|
||||||
|
return Request.session;
|
||||||
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public static void requestError(String message) throws RequestException {
|
public static void requestError(String message) throws RequestException {
|
||||||
|
|
Loading…
Reference in a new issue