Перевод конфигов на Json часть 3

Комплируется, пока не работает
This commit is contained in:
Gravit 2018-12-23 23:22:19 +07:00
parent 7c35cb0a34
commit 79891d711e
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
19 changed files with 85 additions and 156 deletions

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.auth;
import ru.gravit.launcher.NeedGarbageCollection;
import ru.gravit.launcher.serialize.config.entry.StringConfigEntry;
import ru.gravit.launchserver.LaunchServer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@ -60,7 +60,7 @@ public AuthLimiter(LaunchServer srv) {
map = new HashMap<>();
excludeIps = new ArrayList<>();
if (srv.config.authLimitExclusions != null)
srv.config.authLimitExclusions.stream(StringConfigEntry.class).forEach(excludeIps::add);
excludeIps.addAll(Arrays.asList(srv.config.authLimitExclusions));
rateLimit = srv.config.authRateLimit;
rateLimitMilis = srv.config.authRateLimitMilis;
}

View file

@ -3,11 +3,6 @@
import com.mysql.cj.jdbc.MysqlDataSource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import ru.gravit.launcher.serialize.config.ConfigObject;
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry;
import ru.gravit.launcher.serialize.config.entry.IntegerConfigEntry;
import ru.gravit.launcher.serialize.config.entry.StringConfigEntry;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.VerifyHelper;
@ -15,7 +10,7 @@
import java.sql.Connection;
import java.sql.SQLException;
public final class MySQLSourceConfig extends ConfigObject implements AutoCloseable {
public final class MySQLSourceConfig implements AutoCloseable {
public static final int TIMEOUT = VerifyHelper.verifyInt(
Integer.parseUnsignedInt(System.getProperty("launcher.mysql.idleTimeout", Integer.toString(5000))),
@ -28,13 +23,13 @@ public final class MySQLSourceConfig extends ConfigObject implements AutoCloseab
private final String poolName;
// Config
private final String address;
private final int port;
private final boolean useSSL;
private final boolean verifyCertificates;
private final String username;
private final String password;
private final String database;
private String address;
private int port;
private boolean useSSL;
private boolean verifyCertificates;
private String username;
private String password;
private String database;
private String timeZone;
// Cache
@ -42,23 +37,8 @@ public final class MySQLSourceConfig extends ConfigObject implements AutoCloseab
private boolean hikari;
public MySQLSourceConfig(String poolName, BlockConfigEntry block) {
super(block);
public MySQLSourceConfig(String poolName) {
this.poolName = poolName;
address = VerifyHelper.verify(block.getEntryValue("address", StringConfigEntry.class),
VerifyHelper.NOT_EMPTY, "MySQL address can't be empty");
port = VerifyHelper.verifyInt(block.getEntryValue("port", IntegerConfigEntry.class),
VerifyHelper.range(0, 65535), "Illegal MySQL port");
username = VerifyHelper.verify(block.getEntryValue("username", StringConfigEntry.class),
VerifyHelper.NOT_EMPTY, "MySQL username can't be empty");
password = block.getEntryValue("password", StringConfigEntry.class);
database = VerifyHelper.verify(block.getEntryValue("database", StringConfigEntry.class),
VerifyHelper.NOT_EMPTY, "MySQL database can't be empty");
timeZone = block.hasEntry("timezone") ? VerifyHelper.verify(block.getEntryValue("timezone", StringConfigEntry.class),
VerifyHelper.NOT_EMPTY, "MySQL time zone can't be empty") : null;
// Password shouldn't be verified
useSSL = block.hasEntry("useSSL") ? block.getEntryValue("useSSL", BooleanConfigEntry.class) : true;
verifyCertificates = block.hasEntry("verifyCertificates") ? block.getEntryValue("verifyCertificates", BooleanConfigEntry.class) : false;
}
@Override

View file

@ -35,7 +35,6 @@ public static void registerProviders() {
// Auth providers that doesn't do nothing :D
registerProvider("com.mojang", MojangAuthProvider.class);
registerProvider("mysql", MySQLAuthProvider.class);
registerProvider("file", FileAuthProvider.class);
registerProvider("request", RequestAuthProvider.class);
registerProvider("json", JsonAuthProvider.class);
registredProv = true;

View file

@ -1,10 +1,8 @@
package ru.gravit.launchserver.command.hash;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.profiles.ClientProfile.Version;
import ru.gravit.launcher.serialize.config.TextConfigReader;
import ru.gravit.launcher.serialize.config.TextConfigWriter;
import ru.gravit.launcher.serialize.config.entry.StringConfigEntry;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.launchserver.command.CommandException;
@ -55,14 +53,12 @@ public void invoke(String... args) throws IOException, CommandException {
ClientProfile client;
String profilePath = String.format("ru/gravit/launchserver/defaults/profile%s.cfg", version.name);
try (BufferedReader reader = IOHelper.newReader(IOHelper.getResourceURL(profilePath))) {
client = new ClientProfile(TextConfigReader.read(reader, false));
client = Launcher.gson.fromJson(reader,ClientProfile.class);
}
client.setTitle(dirName);
client.block.getEntry("dir", StringConfigEntry.class).setValue(dirName);
client.block.getEntry("title", StringConfigEntry.class).setValue(dirName);
try (BufferedWriter writer = IOHelper.newWriter(IOHelper.resolveIncremental(server.profilesDir,
dirName, "cfg"))) {
TextConfigWriter.write(client.block, writer, true);
Launcher.gson.toJson(client,writer);
}
// Finished

View file

@ -77,13 +77,13 @@ public void reply() throws Exception {
return;
}
if (isClient) {
Collection<SignedObjectHolder<ClientProfile>> profiles = server.getProfiles();
for (SignedObjectHolder<ClientProfile> p : profiles) {
if (p.object.getTitle().equals(client)) {
if (!p.object.isWhitelistContains(login)) {
Collection<ClientProfile> profiles = server.getProfiles();
for (ClientProfile p : profiles) {
if (p.getTitle().equals(client)) {
if (!p.isWhitelistContains(login)) {
throw new AuthException(server.config.whitelistRejectString);
}
clientData.profile = p.object;
clientData.profile = p;
}
}
if (clientData.profile == null) {

View file

@ -64,13 +64,13 @@ public void reply() throws Exception {
AuthProvider.authError(String.format("Illegal result: '%s'", result.username));
return;
}
Collection<SignedObjectHolder<ClientProfile>> profiles = server.getProfiles();
for (SignedObjectHolder<ClientProfile> p : profiles) {
if (p.object.getTitle().equals(client)) {
if (!p.object.isWhitelistContains(login)) {
Collection<ClientProfile> profiles = server.getProfiles();
for (ClientProfile p : profiles) {
if (p.getTitle().equals(client)) {
if (!p.isWhitelistContains(login)) {
throw new AuthException(server.config.whitelistRejectString);
}
clientData.profile = p.object;
clientData.profile = p;
}
}
if (clientData.profile == null) {

View file

@ -21,14 +21,14 @@ public void reply() throws Exception {
String client = input.readString(SerializeLimits.MAX_CLIENT);
Client clientData = server.sessionManager.getClient(session);
if (!clientData.isAuth) requestError("You not auth");
Collection<SignedObjectHolder<ClientProfile>> profiles = server.getProfiles();
for (SignedObjectHolder<ClientProfile> p : profiles) {
if (p.object.getTitle().equals(client)) {
if (!p.object.isWhitelistContains(clientData.username)) {
Collection<ClientProfile> profiles = server.getProfiles();
for (ClientProfile p : profiles) {
if (p.getTitle().equals(client)) {
if (!p.isWhitelistContains(clientData.username)) {
requestError(server.config.whitelistRejectString);
return;
}
clientData.profile = p.object;
clientData.profile = p;
writeNoError(output);
output.writeBoolean(true);
break;

View file

@ -1,5 +1,6 @@
package ru.gravit.launchserver.response.update;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.serialize.HInput;
import ru.gravit.launcher.serialize.HOutput;
@ -29,11 +30,11 @@ public void reply() throws IOException {
return;
}
writeNoError(output);
Collection<SignedObjectHolder<ClientProfile>> profiles = server.getProfiles();
Collection<ClientProfile> profiles = server.getProfiles();
output.writeLength(profiles.size(), 0);
for (SignedObjectHolder<ClientProfile> profile : profiles) {
LogHelper.debug("Writted profile: %s", profile.object.getTitle());
profile.write(output);
for (ClientProfile profile : profiles) {
LogHelper.debug("Writted profile: %s", profile.getTitle());
output.writeString(Launcher.gson.toJson(profile),0);
}
}
}

View file

@ -42,10 +42,9 @@ public void reply() throws IOException {
requestError("Assess denied");
return;
}
for (SignedObjectHolder<ClientProfile> p : server.getProfiles()) {
ClientProfile profile = p.object;
if (!clientData.profile.getTitle().equals(profile.getTitle())) continue;
if (!profile.isWhitelistContains(clientData.username)) {
for (ClientProfile p : server.getProfiles()) {
if (!clientData.profile.getTitle().equals(p.getTitle())) continue;
if (!p.isWhitelistContains(clientData.username)) {
requestError("You don't download this folder");
return;
}

View file

@ -56,13 +56,13 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
AuthProvider.authError(String.format("Illegal result: '%s'", result.username));
return;
}
Collection<SignedObjectHolder<ClientProfile>> profiles = LaunchServer.server.getProfiles();
for (SignedObjectHolder<ClientProfile> p : profiles) {
if (p.object.getTitle().equals(client)) {
if (!p.object.isWhitelistContains(login)) {
Collection<ClientProfile> profiles = LaunchServer.server.getProfiles();
for (ClientProfile p : profiles) {
if (p.getTitle().equals(client)) {
if (!p.isWhitelistContains(login)) {
throw new AuthException(LaunchServer.server.config.whitelistRejectString);
}
clientData.profile = p.object;
clientData.profile = p;
}
}
if (clientData.profile == null) {

View file

@ -1,7 +1,6 @@
package ru.gravit.launchserver.texture;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
import ru.gravit.utils.helper.VerifyHelper;
import java.io.IOException;
@ -11,10 +10,6 @@
public final class NullTextureProvider extends TextureProvider {
private volatile TextureProvider provider;
public NullTextureProvider(BlockConfigEntry block) {
super(block);
}
@Override
public void close() throws IOException {
TextureProvider provider = this.provider;

View file

@ -2,8 +2,6 @@
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
import ru.gravit.launcher.serialize.config.entry.StringConfigEntry;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
@ -32,19 +30,9 @@ private static String getTextureURL(String url, UUID uuid, String username, Stri
}
// Instance
private final String skinURL;
private String skinURL;
private final String cloakURL;
public RequestTextureProvider(BlockConfigEntry block) {
super(block);
skinURL = block.getEntryValue("skinsURL", StringConfigEntry.class);
cloakURL = block.getEntryValue("cloaksURL", StringConfigEntry.class);
// Verify
IOHelper.verifyURL(getTextureURL(skinURL, ZERO_UUID, "skinUsername", ""));
IOHelper.verifyURL(getTextureURL(cloakURL, ZERO_UUID, "cloakUsername", ""));
}
private String cloakURL;
@Override
public void close() {

View file

@ -1,8 +1,6 @@
package ru.gravit.launchserver.texture;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.launcher.serialize.config.ConfigObject;
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
import ru.gravit.utils.helper.VerifyHelper;
import java.io.IOException;
@ -11,40 +9,27 @@
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public abstract class TextureProvider extends ConfigObject implements AutoCloseable {
private static final Map<String, Adapter<TextureProvider>> TEXTURE_PROVIDERS = new ConcurrentHashMap<>(2);
public abstract class TextureProvider implements AutoCloseable {
private static final Map<String, Class> TEXTURE_PROVIDERS = new ConcurrentHashMap<>(2);
private static boolean registredProv = false;
public static TextureProvider newProvider(String name, BlockConfigEntry block) {
VerifyHelper.verifyIDName(name);
Adapter<TextureProvider> authHandlerAdapter = VerifyHelper.getMapValue(TEXTURE_PROVIDERS, name,
String.format("Unknown texture provider: '%s'", name));
return authHandlerAdapter.convert(block);
}
public static void registerProvider(String name, Adapter<TextureProvider> adapter) {
public static void registerProvider(String name, Class adapter) {
VerifyHelper.putIfAbsent(TEXTURE_PROVIDERS, name, Objects.requireNonNull(adapter, "adapter"),
String.format("Texture provider has been already registered: '%s'", name));
}
public static void registerProviders() {
if (!registredProv) {
registerProvider("null", NullTextureProvider::new);
registerProvider("void", VoidTextureProvider::new);
registerProvider("null", NullTextureProvider.class);
registerProvider("void", VoidTextureProvider.class);
// Auth providers that doesn't do nothing :D
registerProvider("request", RequestTextureProvider::new);
registerProvider("request", RequestTextureProvider.class);
registredProv = true;
}
}
protected TextureProvider(BlockConfigEntry block) {
super(block);
}
@Override
public abstract void close() throws IOException;

View file

@ -1,14 +1,10 @@
package ru.gravit.launchserver.texture;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
import java.util.UUID;
public final class VoidTextureProvider extends TextureProvider {
public VoidTextureProvider(BlockConfigEntry block) {
super(block);
}
@Override
public void close() {

View file

@ -27,10 +27,6 @@
import ru.gravit.launcher.request.uuid.ProfileByUsernameRequest;
import ru.gravit.launcher.serialize.HInput;
import ru.gravit.launcher.serialize.HOutput;
import ru.gravit.launcher.serialize.config.ConfigObject;
import ru.gravit.launcher.serialize.config.TextConfigReader;
import ru.gravit.launcher.serialize.config.TextConfigWriter;
import ru.gravit.launcher.serialize.config.entry.*;
import ru.gravit.launcher.serialize.signed.SignedBytesHolder;
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
import ru.gravit.launcher.serialize.stream.EnumSerializer;
@ -96,18 +92,6 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
bindings.put("SignedObjectHolderClass", SignedObjectHolder.class);
bindings.put("EnumSerializerClass", EnumSerializer.class);
// Set config serialization class bindings
bindings.put("ConfigObjectClass", ConfigObject.class);
bindings.put("ConfigObjectAdapterClass", ConfigObject.Adapter.class);
bindings.put("BlockConfigEntryClass", BlockConfigEntry.class);
bindings.put("BooleanConfigEntryClass", BooleanConfigEntry.class);
bindings.put("IntegerConfigEntryClass", IntegerConfigEntry.class);
bindings.put("ListConfigEntryClass", ListConfigEntry.class);
bindings.put("StringConfigEntryClass", StringConfigEntry.class);
bindings.put("ConfigEntryTypeClass", ConfigEntry.Type.class);
bindings.put("TextConfigReaderClass", TextConfigReader.class);
bindings.put("TextConfigWriterClass", TextConfigWriter.class);
// Set helper class bindings
bindings.put("CommonHelperClass", CommonHelper.class);
bindings.put("IOHelperClass", IOHelper.class);

View file

@ -292,7 +292,7 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
@LauncherAPI
public static Process launch(
SignedObjectHolder<HashedDir> assetHDir, SignedObjectHolder<HashedDir> clientHDir,
SignedObjectHolder<ClientProfile> profile, Params params, boolean pipeOutput) throws Throwable {
ClientProfile profile, Params params, boolean pipeOutput) throws Throwable {
// Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars)
LogHelper.debug("Writing ClientLauncher params");
CommonHelper.newThread("Client params writter", false, () ->
@ -314,7 +314,7 @@ public static Process launch(
}
try (HOutput output = new HOutput(client.getOutputStream())) {
params.write(output);
profile.write(output);
output.writeString(Launcher.gson.toJson(profile),0);
assetHDir.write(output);
clientHDir.write(output);
}
@ -363,7 +363,7 @@ public static Process launch(
}
// Add classpath and main class
String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString();
Collections.addAll(args, profile.object.getJvmArgs());
Collections.addAll(args, profile.getJvmArgs());
Collections.addAll(args, "-Djava.library.path=".concat(params.clientDir.resolve(NATIVES_DIR).toString())); // Add Native Path
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
if (wrapper)
@ -412,7 +412,7 @@ public static void main(String... args) throws Throwable {
// Read and delete params file
LogHelper.debug("Reading ClientLauncher params");
Params params;
SignedObjectHolder<ClientProfile> profile;
ClientProfile profile;
SignedObjectHolder<HashedDir> assetHDir, clientHDir;
RSAPublicKey publicKey = Launcher.getConfig().publicKey;
try {
@ -420,7 +420,7 @@ public static void main(String... args) throws Throwable {
socket.connect(new InetSocketAddress(SOCKET_HOST, SOCKET_PORT));
try (HInput input = new HInput(socket.getInputStream())) {
params = new Params(input);
profile = new SignedObjectHolder<>(input, publicKey, ClientProfile.RO_ADAPTER);
profile = gson.fromJson(input.readString(0),ClientProfile.class);
// Read hdirs
assetHDir = new SignedObjectHolder<>(input, publicKey, HashedDir::new);
@ -432,26 +432,26 @@ public static void main(String... args) throws Throwable {
System.exit(-98);
return;
}
Launcher.profile = profile.object;
Launcher.profile = profile;
Launcher.modulesManager.initModules();
// Verify ClientLauncher sign and classpath
LogHelper.debug("Verifying ClientLauncher sign and classpath");
//TODO: GO TO DIGEST
//SecurityHelper.verifySign(LegacyLauncherRequest.BINARY_PATH, params.launcherDigest, publicKey);
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.object.getClassPath());
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
for (Path classpathURL : classPath) {
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
}
URL[] classpathurls = resolveClassPath(params.clientDir, profile.object.getClassPath());
URL[] classpathurls = resolveClassPath(params.clientDir, profile.getClassPath());
classLoader = new PublicURLClassLoader(classpathurls, ClassLoader.getSystemClassLoader());
Thread.currentThread().setContextClassLoader(classLoader);
classLoader.nativePath = params.clientDir.resolve(NATIVES_DIR).toString();
PublicURLClassLoader.systemclassloader = classLoader;
// Start client with WatchService monitoring
boolean digest = !profile.object.isUpdateFastCheck();
boolean digest = !profile.isUpdateFastCheck();
LogHelper.debug("Starting JVM and client WatchService");
FileNameMatcher assetMatcher = profile.object.getAssetUpdateMatcher();
FileNameMatcher clientMatcher = profile.object.getClientUpdateMatcher();
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
FileNameMatcher clientMatcher = profile.getClientUpdateMatcher();
try (DirWatcher assetWatcher = new DirWatcher(params.assetDir, assetHDir.object, assetMatcher, digest);
DirWatcher clientWatcher = new DirWatcher(params.clientDir, clientHDir.object, clientMatcher, digest)) {
// Verify current state of all dirs
@ -467,30 +467,30 @@ public static void main(String... args) throws Throwable {
// Start WatchService, and only then client
CommonHelper.newThread("Asset Directory Watcher", true, assetWatcher).start();
CommonHelper.newThread("Client Directory Watcher", true, clientWatcher).start();
launch(profile.object, params);
launch(profile, params);
}
}
@LauncherAPI
public void launchLocal(SignedObjectHolder<HashedDir> assetHDir, SignedObjectHolder<HashedDir> clientHDir,
SignedObjectHolder<ClientProfile> profile, Params params) throws Throwable {
ClientProfile profile, Params params) throws Throwable {
RSAPublicKey publicKey = Launcher.getConfig().publicKey;
LogHelper.debug("Verifying ClientLauncher sign and classpath");
SecurityHelper.verifySign(LegacyLauncherRequest.BINARY_PATH, params.launcherDigest, publicKey);
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.object.getClassPath());
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
for (Path classpathURL : classPath) {
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
}
URL[] classpathurls = resolveClassPath(params.clientDir, profile.object.getClassPath());
URL[] classpathurls = resolveClassPath(params.clientDir, profile.getClassPath());
classLoader = new PublicURLClassLoader(classpathurls, ClassLoader.getSystemClassLoader());
Thread.currentThread().setContextClassLoader(classLoader);
classLoader.nativePath = params.clientDir.resolve(NATIVES_DIR).toString();
PublicURLClassLoader.systemclassloader = classLoader;
// Start client with WatchService monitoring
boolean digest = !profile.object.isUpdateFastCheck();
boolean digest = !profile.isUpdateFastCheck();
LogHelper.debug("Starting JVM and client WatchService");
FileNameMatcher assetMatcher = profile.object.getAssetUpdateMatcher();
FileNameMatcher clientMatcher = profile.object.getClientUpdateMatcher();
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
FileNameMatcher clientMatcher = profile.getClientUpdateMatcher();
try (DirWatcher assetWatcher = new DirWatcher(params.assetDir, assetHDir.object, assetMatcher, digest);
DirWatcher clientWatcher = new DirWatcher(params.clientDir, clientHDir.object, clientMatcher, digest)) {
// Verify current state of all dirs
@ -506,7 +506,7 @@ public void launchLocal(SignedObjectHolder<HashedDir> assetHDir, SignedObjectHol
// Start WatchService, and only then client
CommonHelper.newThread("Asset Directory Watcher", true, assetWatcher).start();
CommonHelper.newThread("Client Directory Watcher", true, clientWatcher).start();
launch(profile.object, params);
launch(profile, params);
}
}

View file

@ -44,7 +44,7 @@ public class LauncherSettings {
@LauncherAPI
public byte[] lastDigest;
@LauncherAPI
public List<SignedObjectHolder<ClientProfile>> lastProfiles = new LinkedList<>();
public List<ClientProfile> lastProfiles = new LinkedList<>();
@LauncherAPI
public Map<String, SignedObjectHolder<HashedDir>> lastHDirs = new HashMap<>(16);
@ -108,7 +108,7 @@ public void read(HInput input) throws IOException, SignatureException {
lastProfiles.clear();
int lastProfilesCount = input.readLength(0);
for (int i = 0; i < lastProfilesCount; i++) {
lastProfiles.add(new SignedObjectHolder<>(input, publicKey, ClientProfile.RO_ADAPTER));
lastProfiles.add(Launcher.gson.fromJson(input.readString(0),ClientProfile.class));
}
lastHDirs.clear();
int lastHDirsCount = input.readLength(0);
@ -149,8 +149,8 @@ public void write(HOutput output) throws IOException {
output.writeByteArray(lastDigest, 0);
}
output.writeLength(lastProfiles.size(), 0);
for (SignedObjectHolder<ClientProfile> profile : lastProfiles) {
profile.write(output);
for (ClientProfile profile : lastProfiles) {
output.writeString(Launcher.gson.toJson(profile),0);
}
output.writeLength(lastHDirs.size(), 0);
for (Map.Entry<String, SignedObjectHolder<HashedDir>> entry : lastHDirs.entrySet()) {

View file

@ -26,11 +26,11 @@
public final class LegacyLauncherRequest extends Request<Result> {
public static final class Result {
@LauncherAPI
public final List<SignedObjectHolder<ClientProfile>> profiles;
public final List<ClientProfile> profiles;
private final byte[] binary;
private final byte[] sign;
public Result(byte[] binary, byte[] sign, List<SignedObjectHolder<ClientProfile>> profiles) {
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);
@ -116,9 +116,12 @@ protected Result requestDo(HInput input, HOutput output) throws Exception {
// Read clients profiles list
int count = input.readLength(0);
List<SignedObjectHolder<ClientProfile>> profiles = new ArrayList<>(count);
List<ClientProfile> profiles = new ArrayList<>(count);
for (int i = 0; i < count; i++)
profiles.add(new SignedObjectHolder<>(input, publicKey, ClientProfile.RO_ADAPTER));
{
String prof = input.readString(0);
profiles.add(Launcher.gson.fromJson(prof,ClientProfile.class));
}
// Return request result
return new Result(null, sign, profiles);

View file

@ -1,5 +1,6 @@
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;
@ -48,8 +49,10 @@ protected Result requestDo(HInput input, HOutput output) throws Exception {
int count = input.readLength(0);
List<ClientProfile> profiles = new ArrayList<>(count);
for (int i = 0; i < count; i++)
profiles.add(new SignedObjectHolder<>(input, config.publicKey, ClientProfile.RO_ADAPTER));
{
String prof = input.readString(0);
profiles.add(Launcher.gson.fromJson(prof,ClientProfile.class));
}
// Return request result
return new Result(profiles);
}