mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[REFRACTOR] Чистка Request от кода старого протокола
This commit is contained in:
parent
dbb07dee79
commit
c1903428eb
20 changed files with 44 additions and 343 deletions
|
@ -5,7 +5,8 @@
|
|||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.response.update.*;
|
||||
import ru.gravit.launchserver.response.update.LauncherResponse;
|
||||
import ru.gravit.launchserver.response.update.LegacyLauncherResponse;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.auth.RestoreSessionRequest;
|
||||
import ru.gravit.launcher.request.update.LegacyLauncherRequest;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
import ru.gravit.launcher.managers.HasherManager;
|
||||
import ru.gravit.launcher.managers.HasherStore;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.update.LegacyLauncherRequest;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||
|
||||
|
@ -44,21 +43,6 @@ public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, S
|
|||
};
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public static LegacyLauncherRequest.Result offlineLauncherRequest() throws IOException {
|
||||
if (settings.lastDigest == null || settings.lastProfiles.isEmpty()) {
|
||||
Request.requestError("Запуск в оффлайн-режиме невозможен");
|
||||
}
|
||||
|
||||
// Verify launcher signature
|
||||
//TODO: TO DIGEST
|
||||
//SecurityHelper.verifySign(LegacyLauncherRequest.BINARY_PATH,
|
||||
// settings.lastDigest, Launcher.getConfig().publicKey);
|
||||
|
||||
// Return last sign and profiles
|
||||
return new LegacyLauncherRequest.Result(null, settings.lastDigest, settings.lastProfiles);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public static void makeJsonRequest(RequestInterface request, Runnable callback) {
|
||||
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.profiles.Texture;
|
||||
import ru.gravit.launcher.profiles.optional.OptionalFile;
|
||||
import ru.gravit.launcher.request.*;
|
||||
import ru.gravit.launcher.request.PingRequest;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestException;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.auth.AuthRequest;
|
||||
import ru.gravit.launcher.request.auth.CheckServerRequest;
|
||||
import ru.gravit.launcher.request.auth.JoinServerRequest;
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
package ru.gravit.launcher.request;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class PingRequest extends Request<Void> {
|
||||
|
||||
@LauncherAPI
|
||||
public PingRequest() {
|
||||
this(null);
|
||||
@Override
|
||||
protected Void requestDo() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public PingRequest(LauncherConfig config) {
|
||||
super(config);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
package ru.gravit.launcher.request;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public abstract class Request<R> {
|
||||
|
@ -28,37 +21,15 @@ public static void requestError(String message) throws RequestException {
|
|||
throw new RequestException(message);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
protected transient final LauncherConfig config;
|
||||
|
||||
private transient final AtomicBoolean started = new AtomicBoolean(false);
|
||||
|
||||
@LauncherAPI
|
||||
protected Request() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
protected Request(LauncherConfig config) {
|
||||
this.config = config == null ? Launcher.getConfig() : config;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
protected final void readError(HInput input) throws IOException {
|
||||
String error = input.readString(0);
|
||||
if (!error.isEmpty())
|
||||
requestError(error);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public R request() throws Exception {
|
||||
if (!started.compareAndSet(false, true))
|
||||
throw new IllegalStateException("Request already started");
|
||||
return requestWebSockets();
|
||||
return requestDo();
|
||||
}
|
||||
|
||||
protected R requestWebSockets() throws Exception {
|
||||
return null;
|
||||
}
|
||||
protected abstract R requestDo() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
package ru.gravit.launcher.request.auth;
|
||||
|
||||
import ru.gravit.launcher.*;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class AuthRequest extends Request<AuthRequestEvent> implements RequestInterface {
|
||||
@LauncherNetworkAPI
|
||||
private final String login;
|
||||
|
@ -36,8 +30,7 @@ public enum ConnectTypes {
|
|||
}
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid) {
|
||||
super(config);
|
||||
public AuthRequest(String login, byte[] password, HWID hwid) {
|
||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||
this.encryptedPassword = password.clone();
|
||||
this.hwid = hwid;
|
||||
|
@ -48,8 +41,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
|
|||
}
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String auth_id) {
|
||||
super(config);
|
||||
public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) {
|
||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||
this.encryptedPassword = password.clone();
|
||||
this.hwid = hwid;
|
||||
|
@ -60,8 +52,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
|
|||
}
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String customText, String auth_id) {
|
||||
super(config);
|
||||
public AuthRequest(String login, byte[] password, HWID hwid, String customText, String auth_id) {
|
||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||
this.encryptedPassword = password.clone();
|
||||
this.hwid = hwid;
|
||||
|
@ -71,11 +62,6 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
|
|||
authType = ConnectTypes.CLIENT;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(String login, byte[] password, HWID hwid) {
|
||||
this(null, login, password, hwid);
|
||||
}
|
||||
|
||||
public AuthRequest(String login, byte[] encryptedPassword, String auth_id, ConnectTypes authType) {
|
||||
this.login = login;
|
||||
this.encryptedPassword = encryptedPassword;
|
||||
|
@ -87,15 +73,10 @@ public AuthRequest(String login, byte[] encryptedPassword, String auth_id, Conne
|
|||
}
|
||||
|
||||
@Override
|
||||
public AuthRequestEvent requestWebSockets() throws Exception {
|
||||
public AuthRequestEvent requestDo() throws Exception {
|
||||
return (AuthRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) {
|
||||
this(null, login, password, hwid, auth_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "auth";
|
||||
|
|
|
@ -1,24 +1,13 @@
|
|||
package ru.gravit.launcher.request.auth;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.events.request.CheckServerRequestEvent;
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.ResultInterface;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class CheckServerRequest extends Request<CheckServerRequestEvent> implements RequestInterface {
|
||||
@LauncherNetworkAPI
|
||||
private final String username;
|
||||
|
@ -26,19 +15,13 @@ public final class CheckServerRequest extends Request<CheckServerRequestEvent> i
|
|||
private final String serverID;
|
||||
|
||||
@LauncherAPI
|
||||
public CheckServerRequest(LauncherConfig config, String username, String serverID) {
|
||||
super(config);
|
||||
public CheckServerRequest(String username, String serverID) {
|
||||
this.username = VerifyHelper.verifyUsername(username);
|
||||
this.serverID = VerifyHelper.verifyServerID(serverID);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public CheckServerRequest(String username, String serverID) {
|
||||
this(null, username, serverID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckServerRequestEvent requestWebSockets() throws Exception
|
||||
public CheckServerRequestEvent requestDo() throws Exception
|
||||
{
|
||||
return (CheckServerRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package ru.gravit.launcher.request.auth;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.events.request.JoinServerRequestEvent;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
|
@ -27,22 +22,17 @@ public final class JoinServerRequest extends Request<JoinServerRequestEvent> imp
|
|||
private final String serverID;
|
||||
|
||||
@LauncherAPI
|
||||
public JoinServerRequest(LauncherConfig config, String username, String accessToken, String serverID) {
|
||||
super(config);
|
||||
public JoinServerRequest(String username, String accessToken, String serverID) {
|
||||
this.username = VerifyHelper.verifyUsername(username);
|
||||
this.accessToken = SecurityHelper.verifyToken(accessToken);
|
||||
this.serverID = VerifyHelper.verifyServerID(serverID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JoinServerRequestEvent requestWebSockets() throws IOException, InterruptedException {
|
||||
public JoinServerRequestEvent requestDo() throws IOException, InterruptedException {
|
||||
return (JoinServerRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public JoinServerRequest(String username, String accessToken, String serverID) {
|
||||
this(null, username, accessToken, serverID);
|
||||
}
|
||||
@Override
|
||||
public String getType() {
|
||||
return "joinServer";
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package ru.gravit.launcher.request.auth;
|
||||
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import ru.gravit.launcher.events.request.RestoreSessionRequestEvent;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +16,7 @@ public RestoreSessionRequest(long session) {
|
|||
this.session = session;
|
||||
}
|
||||
@Override
|
||||
public RestoreSessionRequestEvent requestWebSockets() throws IOException, InterruptedException {
|
||||
public RestoreSessionRequestEvent requestDo() throws IOException, InterruptedException {
|
||||
return (RestoreSessionRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,24 @@
|
|||
package ru.gravit.launcher.request.auth;
|
||||
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.events.request.SetProfileRequestEvent;
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
|
||||
public class SetProfileRequest extends Request<SetProfileRequestEvent> implements RequestInterface {
|
||||
private transient ClientProfile profile;
|
||||
@LauncherNetworkAPI
|
||||
public String client;
|
||||
|
||||
public SetProfileRequest(LauncherConfig config, ClientProfile profile) {
|
||||
super(config);
|
||||
public SetProfileRequest(ClientProfile profile) {
|
||||
this.profile = profile;
|
||||
this.client = profile.getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetProfileRequestEvent requestWebSockets() throws Exception {
|
||||
public SetProfileRequestEvent requestDo() throws Exception {
|
||||
return (SetProfileRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,23 +2,18 @@
|
|||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.downloader.ListDownloader;
|
||||
import ru.gravit.launcher.events.request.LauncherRequestEvent;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.JVMHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -35,7 +30,7 @@ public final class LauncherRequest extends Request<LauncherRequestEvent> impleme
|
|||
public static final boolean EXE_BINARY = IOHelper.hasExtension(BINARY_PATH, "exe");
|
||||
|
||||
@LauncherAPI
|
||||
public static void update(LauncherConfig config, LauncherRequestEvent result) throws IOException {
|
||||
public static void update(LauncherRequestEvent result) throws IOException {
|
||||
List<String> args = new ArrayList<>(8);
|
||||
args.add(IOHelper.resolveJavaBin(null).toString());
|
||||
if (LogHelper.isDebugEnabled())
|
||||
|
@ -70,21 +65,15 @@ public static void update(LauncherConfig config, LauncherRequestEvent result) th
|
|||
throw new AssertionError("Why Launcher wasn't restarted?!");
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public LauncherRequest() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherRequestEvent requestWebSockets() throws Exception {
|
||||
public LauncherRequestEvent requestDo() throws Exception {
|
||||
LauncherRequestEvent result = (LauncherRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
if (result.needUpdate) update(config, result);
|
||||
if (result.needUpdate) update(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public LauncherRequest(LauncherConfig config) {
|
||||
super(config);
|
||||
public LauncherRequest() {
|
||||
Path launcherPath = IOHelper.getCodeSource(LauncherRequest.class);
|
||||
try {
|
||||
digest = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA512, launcherPath);
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
package ru.gravit.launcher.request.update;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.update.LegacyLauncherRequest.Result;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.JVMHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.SignatureException;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class LegacyLauncherRequest extends Request<Result> {
|
||||
public static final class Result {
|
||||
@LauncherAPI
|
||||
public final List<ClientProfile> profiles;
|
||||
private final byte[] binary;
|
||||
private final byte[] sign;
|
||||
|
||||
public Result(byte[] binary, byte[] sign, List<ClientProfile> profiles) {
|
||||
this.binary = binary == null ? null : binary.clone();
|
||||
this.sign = sign.clone();
|
||||
this.profiles = Collections.unmodifiableList(profiles);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public byte[] getBinary() {
|
||||
return binary == null ? null : binary.clone();
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public byte[] getSign() {
|
||||
return sign.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public static final Path BINARY_PATH = IOHelper.getCodeSource(Launcher.class);
|
||||
|
||||
@LauncherAPI
|
||||
public static final boolean EXE_BINARY = IOHelper.hasExtension(BINARY_PATH, "exe");
|
||||
|
||||
@LauncherAPI
|
||||
public static void update(LauncherConfig config, Result result) throws SignatureException, IOException {
|
||||
SecurityHelper.verifySign(result.binary, result.sign, config.publicKey);
|
||||
|
||||
// Prepare process builder to start new instance (java -jar works for Launch4J's EXE too)
|
||||
List<String> args = new ArrayList<>(8);
|
||||
args.add(IOHelper.resolveJavaBin(null).toString());
|
||||
if (LogHelper.isDebugEnabled())
|
||||
args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled())));
|
||||
args.add("-jar");
|
||||
args.add(BINARY_PATH.toString());
|
||||
ProcessBuilder builder = new ProcessBuilder(args.toArray(new String[0]));
|
||||
builder.inheritIO();
|
||||
|
||||
// Rewrite and start new instance
|
||||
IOHelper.write(BINARY_PATH, result.binary);
|
||||
builder.start();
|
||||
|
||||
// Kill current instance
|
||||
JVMHelper.RUNTIME.exit(255);
|
||||
throw new AssertionError("Why Launcher wasn't restarted?!");
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public LegacyLauncherRequest() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public LegacyLauncherRequest(LauncherConfig config) {
|
||||
super(config);
|
||||
}
|
||||
}
|
|
@ -1,34 +1,14 @@
|
|||
package ru.gravit.launcher.request.update;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.events.request.ProfilesRequestEvent;
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class ProfilesRequest extends Request<ProfilesRequestEvent> implements RequestInterface {
|
||||
|
||||
@LauncherAPI
|
||||
public ProfilesRequest() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public ProfilesRequest(LauncherConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfilesRequestEvent requestWebSockets() throws Exception {
|
||||
public ProfilesRequestEvent requestDo() throws Exception {
|
||||
return (ProfilesRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +1,14 @@
|
|||
package ru.gravit.launcher.request.update;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.events.request.UpdateListRequestEvent;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
|
||||
public final class UpdateListRequest extends Request<UpdateListRequestEvent> implements RequestInterface {
|
||||
@LauncherAPI
|
||||
public UpdateListRequest() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public UpdateListRequest(LauncherConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateListRequestEvent requestWebSockets() throws Exception {
|
||||
public UpdateListRequestEvent requestDo() throws Exception {
|
||||
return (UpdateListRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.downloader.ListDownloader;
|
||||
import ru.gravit.launcher.events.request.UpdateRequestEvent;
|
||||
|
@ -11,33 +10,23 @@
|
|||
import ru.gravit.launcher.hasher.HashedEntry;
|
||||
import ru.gravit.launcher.hasher.HashedFile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.UpdateAction;
|
||||
import ru.gravit.launcher.request.update.UpdateRequest.State.Callback;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.SignatureException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.Queue;
|
||||
|
||||
public final class UpdateRequest extends Request<UpdateRequestEvent> implements RequestInterface {
|
||||
|
||||
|
@ -200,7 +189,7 @@ private static void fillActionsQueue(Queue<UpdateAction> queue, HashedDir mismat
|
|||
}
|
||||
|
||||
@Override
|
||||
public UpdateRequestEvent requestWebSockets() throws Exception {
|
||||
public UpdateRequestEvent requestDo() throws Exception {
|
||||
LogHelper.debug("Start update request");
|
||||
UpdateRequestEvent e = (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
LogHelper.debug("Start update");
|
||||
|
@ -243,19 +232,13 @@ public UpdateRequestEvent requestWebSockets() throws Exception {
|
|||
private transient Instant startTime;
|
||||
|
||||
@LauncherAPI
|
||||
public UpdateRequest(LauncherConfig config, String dirName, Path dir, FileNameMatcher matcher, boolean digest) {
|
||||
super(config);
|
||||
public UpdateRequest(String dirName, Path dir, FileNameMatcher matcher, boolean digest) {
|
||||
this.dirName = IOHelper.verifyFileName(dirName);
|
||||
this.dir = Objects.requireNonNull(dir, "dir");
|
||||
this.matcher = matcher;
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public UpdateRequest(String dirName, Path dir, FileNameMatcher matcher, boolean digest) {
|
||||
this(null, dirName, dir, matcher, digest);
|
||||
}
|
||||
|
||||
private void deleteExtraDir(Path subDir, HashedDir subHDir, boolean flag) throws IOException {
|
||||
for (Entry<String, HashedEntry> mapEntry : subHDir.map().entrySet()) {
|
||||
String name = mapEntry.getKey();
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package ru.gravit.launcher.request.uuid;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent;
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
@ -28,8 +23,7 @@ class Entry {
|
|||
private final Entry[] list;
|
||||
|
||||
@LauncherAPI
|
||||
public BatchProfileByUsernameRequest(LauncherConfig config, String... usernames) throws IOException {
|
||||
super(config);
|
||||
public BatchProfileByUsernameRequest(String... usernames) throws IOException {
|
||||
this.list = new Entry[usernames.length];
|
||||
for(int i=0;i<usernames.length;++i)
|
||||
{
|
||||
|
@ -40,13 +34,8 @@ public BatchProfileByUsernameRequest(LauncherConfig config, String... usernames)
|
|||
for (String username : usernames)
|
||||
VerifyHelper.verifyUsername(username);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public BatchProfileByUsernameRequest(String... usernames) throws IOException {
|
||||
this(null, usernames);
|
||||
}
|
||||
@Override
|
||||
public BatchProfileByUsernameRequestEvent requestWebSockets() throws IOException, InterruptedException {
|
||||
public BatchProfileByUsernameRequestEvent requestDo() throws IOException, InterruptedException {
|
||||
return (BatchProfileByUsernameRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
package ru.gravit.launcher.request.uuid;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.events.request.ProfileByUUIDRequestEvent;
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
@ -23,18 +16,12 @@ public final class ProfileByUUIDRequest extends Request<ProfileByUUIDRequestEven
|
|||
private final UUID uuid;
|
||||
|
||||
@LauncherAPI
|
||||
public ProfileByUUIDRequest(LauncherConfig config, UUID uuid) {
|
||||
super(config);
|
||||
public ProfileByUUIDRequest(UUID uuid) {
|
||||
this.uuid = Objects.requireNonNull(uuid, "uuid");
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public ProfileByUUIDRequest(UUID uuid) {
|
||||
this(null, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileByUUIDRequestEvent requestWebSockets() throws IOException, InterruptedException {
|
||||
public ProfileByUUIDRequestEvent requestDo() throws IOException, InterruptedException {
|
||||
return (ProfileByUUIDRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
package ru.gravit.launcher.request.uuid;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||
import ru.gravit.launcher.events.request.ProfileByUsernameRequestEvent;
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -22,18 +15,12 @@ public final class ProfileByUsernameRequest extends Request<ProfileByUsernameReq
|
|||
private final String username;
|
||||
|
||||
@LauncherAPI
|
||||
public ProfileByUsernameRequest(LauncherConfig config, String username) {
|
||||
super(config);
|
||||
public ProfileByUsernameRequest(String username) {
|
||||
this.username = VerifyHelper.verifyUsername(username);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public ProfileByUsernameRequest(String username) {
|
||||
this(null, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileByUsernameRequestEvent requestWebSockets() throws IOException, InterruptedException {
|
||||
public ProfileByUsernameRequestEvent requestDo() throws IOException, InterruptedException {
|
||||
return (ProfileByUsernameRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public boolean auth() {
|
|||
LauncherConfig cfg = Launcher.getConfig();
|
||||
AuthRequest request = new AuthRequest(config.login, SecurityHelper.newRSAEncryptCipher(cfg.publicKey).doFinal(IOHelper.encode(config.password)), config.auth_id, AuthRequest.ConnectTypes.SERVER);
|
||||
permissions = request.request().permissions;
|
||||
ProfilesRequestEvent result = new ProfilesRequest(cfg).request();
|
||||
ProfilesRequestEvent result = new ProfilesRequest().request();
|
||||
for (ClientProfile p : result.profiles) {
|
||||
LogHelper.debug("Get profile: %s", p.getTitle());
|
||||
if (p.getTitle().equals(config.title)) {
|
||||
|
|
Loading…
Reference in a new issue