mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
Merge pull request #110 from GravitLauncher/optimizations
Optimizations
This commit is contained in:
commit
6bc949752d
106 changed files with 682 additions and 501 deletions
|
@ -1,8 +1,39 @@
|
|||
package ru.gravit.launchserver;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.security.KeyPair;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.hasher.HashedDir;
|
||||
|
@ -22,37 +53,33 @@
|
|||
import ru.gravit.launchserver.binary.EXELauncherBinary;
|
||||
import ru.gravit.launchserver.binary.JARLauncherBinary;
|
||||
import ru.gravit.launchserver.binary.LauncherBinary;
|
||||
import ru.gravit.launchserver.binary.ProguardConf;
|
||||
import ru.gravit.launchserver.command.handler.CommandHandler;
|
||||
import ru.gravit.launchserver.command.handler.JLineCommandHandler;
|
||||
import ru.gravit.launchserver.command.handler.StdCommandHandler;
|
||||
import ru.gravit.launchserver.config.*;
|
||||
import ru.gravit.launchserver.manangers.*;
|
||||
import ru.gravit.launchserver.config.AuthHandlerAdapter;
|
||||
import ru.gravit.launchserver.config.AuthProviderAdapter;
|
||||
import ru.gravit.launchserver.config.HWIDHandlerAdapter;
|
||||
import ru.gravit.launchserver.config.PermissionsHandlerAdapter;
|
||||
import ru.gravit.launchserver.config.TextureProviderAdapter;
|
||||
import ru.gravit.launchserver.manangers.BuildHookManager;
|
||||
import ru.gravit.launchserver.manangers.MirrorManager;
|
||||
import ru.gravit.launchserver.manangers.ModulesManager;
|
||||
import ru.gravit.launchserver.manangers.ReconfigurableManager;
|
||||
import ru.gravit.launchserver.manangers.ReloadManager;
|
||||
import ru.gravit.launchserver.manangers.SessionManager;
|
||||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.launchserver.socket.ServerSocketHandler;
|
||||
import ru.gravit.launchserver.texture.RequestTextureProvider;
|
||||
import ru.gravit.launchserver.texture.TextureProvider;
|
||||
import ru.gravit.utils.helper.*;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
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 ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.security.KeyPair;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
public final class LaunchServer implements Runnable, AutoCloseable {
|
||||
public final class LaunchServer implements Runnable {
|
||||
public static final class Config {
|
||||
public int port;
|
||||
|
||||
|
@ -211,9 +238,7 @@ public static void main(String... args) throws Throwable {
|
|||
// Start LaunchServer
|
||||
Instant start = Instant.now();
|
||||
try {
|
||||
try (LaunchServer lsrv = new LaunchServer(IOHelper.WORKING_DIR)) {
|
||||
lsrv.run();
|
||||
}
|
||||
new LaunchServer(IOHelper.WORKING_DIR).run();
|
||||
} catch (Throwable exc) {
|
||||
LogHelper.error(exc);
|
||||
return;
|
||||
|
@ -464,7 +489,12 @@ public static void initGson()
|
|||
}
|
||||
|
||||
private LauncherBinary binary() {
|
||||
if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this);
|
||||
try {
|
||||
Class.forName("net.sf.launch4j.Builder");
|
||||
if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
LogHelper.warning("Launch4J isn't in classpath.");
|
||||
}
|
||||
return new EXELauncherBinary(this);
|
||||
}
|
||||
|
||||
|
@ -474,7 +504,6 @@ public void buildLauncherBinaries() throws IOException {
|
|||
launcherEXEBinary.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
serverSocketHandler.close();
|
||||
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
|
||||
import java.io.IOException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.FileVisitOption;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Collections;
|
||||
import java.util.jar.JarFile;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package ru.gravit.launchserver.asm;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
@ -12,6 +7,12 @@
|
|||
import java.util.List;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
/**
|
||||
* Позволяет искать методы внутри незагруженных классов и общие суперклассы для
|
||||
* чего угодно. Работает через поиск class-файлов в classpath.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ru.gravit.launchserver.asm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* ClassWriter с другой реализацией метода getCommonSuperClass: при его
|
||||
* использовании не происходит загрузки классов.
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ru.gravit.launchserver.auth;
|
||||
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
|
||||
public class AuthLimiter implements NeedGarbageCollection {
|
||||
static class AuthEntry {
|
||||
public int value;
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package ru.gravit.launchserver.auth;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.mysql.cj.jdbc.MysqlDataSource;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public final class MySQLSourceConfig implements AutoCloseable {
|
||||
|
||||
public static final int TIMEOUT = VerifyHelper.verifyInt(
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class AuthHandler implements AutoCloseable {
|
||||
private static final Map<String, Class> AUTH_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
private static final Map<String, Class<? extends AuthHandler>> AUTH_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
private static boolean registredHandl = false;
|
||||
|
||||
|
||||
|
@ -20,18 +20,18 @@ public static UUID authError(String message) throws AuthException {
|
|||
}
|
||||
|
||||
|
||||
public static void registerHandler(String name, Class adapter) {
|
||||
public static void registerHandler(String name, Class<? extends AuthHandler> adapter) {
|
||||
VerifyHelper.verifyIDName(name);
|
||||
VerifyHelper.putIfAbsent(AUTH_HANDLERS, name, Objects.requireNonNull(adapter, "adapter"),
|
||||
String.format("Auth handler has been already registered: '%s'", name));
|
||||
}
|
||||
public static Class getHandlerClass(String name)
|
||||
public static Class<? extends AuthHandler> getHandlerClass(String name)
|
||||
{
|
||||
return AUTH_HANDLERS.get(name);
|
||||
}
|
||||
public static String getHandlerName(Class clazz)
|
||||
public static String getHandlerName(Class<AuthHandler> clazz)
|
||||
{
|
||||
for(Map.Entry<String,Class> e: AUTH_HANDLERS.entrySet())
|
||||
for(Map.Entry<String,Class<? extends AuthHandler>> e: AUTH_HANDLERS.entrySet())
|
||||
{
|
||||
if(e.getValue().equals(clazz)) return e.getKey();
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
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.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
public final class BinaryFileAuthHandler extends FileAuthHandler {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection {
|
||||
public static final class Entry {
|
||||
|
||||
|
|
|
@ -1,17 +1,25 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.stream.StreamObject;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.utils.helper.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class FileAuthHandler extends AuthHandler {
|
||||
public static final class Entry extends StreamObject {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public final class MemoryAuthHandler extends CachedAuthHandler {
|
||||
private static String toUsername(UUID uuid) {
|
||||
byte[] bytes = ByteBuffer.allocate(16).
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
import ru.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
@ -9,6 +7,8 @@
|
|||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
|
||||
public final class MySQLAuthHandler extends CachedAuthHandler {
|
||||
private MySQLSourceConfig mySQLHolder;
|
||||
private String uuidColumn;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public final class NullAuthHandler extends AuthHandler {
|
||||
private volatile AuthHandler handler;
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ru.gravit.launchserver.auth.hwid;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
|
||||
public class AcceptHWIDHandler extends HWIDHandler {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package ru.gravit.launchserver.auth.hwid;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class HWIDHandler implements AutoCloseable {
|
||||
private static final Map<String, Class> HW_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
private static final Map<String, Class<? extends HWIDHandler>> HW_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
private static boolean registredHandl = false;
|
||||
|
||||
|
||||
public static void registerHandler(String name, Class adapter) {
|
||||
public static void registerHandler(String name, Class<? extends HWIDHandler> adapter) {
|
||||
VerifyHelper.verifyIDName(name);
|
||||
VerifyHelper.putIfAbsent(HW_HANDLERS, name, Objects.requireNonNull(adapter, "adapter"),
|
||||
String.format("HWID handler has been already registered: '%s'", name));
|
||||
|
@ -44,13 +44,13 @@ public void check(HWID hwid, String username) throws HWIDException {
|
|||
|
||||
public abstract void unban(List<HWID> hwid) throws HWIDException;
|
||||
|
||||
public static Class getHandlerClass(String name)
|
||||
public static Class<? extends HWIDHandler> getHandlerClass(String name)
|
||||
{
|
||||
return HW_HANDLERS.get(name);
|
||||
}
|
||||
public static String getHandlerName(Class clazz)
|
||||
public static String getHandlerName(Class<? extends HWIDHandler> clazz)
|
||||
{
|
||||
for(Map.Entry<String,Class> e: HW_HANDLERS.entrySet())
|
||||
for(Map.Entry<String,Class<? extends HWIDHandler>> e: HW_HANDLERS.entrySet())
|
||||
{
|
||||
if(e.getValue().equals(clazz)) return e.getKey();
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package ru.gravit.launchserver.auth.hwid;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.utils.HTTPRequest;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.utils.HTTPRequest;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public final class JsonHWIDHandler extends HWIDHandler {
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
package ru.gravit.launchserver.auth.hwid;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -13,6 +7,12 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class MysqlHWIDHandler extends HWIDHandler {
|
||||
private MySQLSourceConfig mySQLHolder;
|
||||
private String query;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ru.gravit.launchserver.auth.permissions;
|
||||
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
|
||||
public class ConfigPermissionsHandler extends PermissionsHandler {
|
||||
public boolean isAdmin = false;
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package ru.gravit.launchserver.auth.permissions;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.Reloadable;
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
@ -16,6 +9,14 @@
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.Reloadable;
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable {
|
||||
public String filename = "permissions.json";
|
||||
public static Map<String,ClientPermissions> map;
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
package ru.gravit.launchserver.auth.permissions;
|
||||
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class PermissionsHandler {
|
||||
private static final Map<String, Class> PERMISSIONS_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
private static final Map<String, Class<? extends PermissionsHandler>> PERMISSIONS_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
private static boolean registredHandl = false;
|
||||
public static void registerHandler(String name, Class adapter) {
|
||||
public static void registerHandler(String name, Class<? extends PermissionsHandler> adapter) {
|
||||
VerifyHelper.verifyIDName(name);
|
||||
VerifyHelper.putIfAbsent(PERMISSIONS_HANDLERS, name, Objects.requireNonNull(adapter, "adapter"),
|
||||
String.format("Auth handler has been already registered: '%s'", name));
|
||||
}
|
||||
public static Class getHandlerClass(String name)
|
||||
public static Class<? extends PermissionsHandler> getHandlerClass(String name)
|
||||
{
|
||||
return PERMISSIONS_HANDLERS.get(name);
|
||||
}
|
||||
public static String getHandlerName(Class clazz)
|
||||
public static String getHandlerName(Class<? extends PermissionsHandler> clazz)
|
||||
{
|
||||
for(Map.Entry<String,Class> e: PERMISSIONS_HANDLERS.entrySet())
|
||||
for(Map.Entry<String,Class<? extends PermissionsHandler>> e: PERMISSIONS_HANDLERS.entrySet())
|
||||
{
|
||||
if(e.getValue().equals(clazz)) return e.getKey();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public final class AcceptAuthProvider extends AuthProvider {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.handler.AuthHandler;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.handler.AuthHandler;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class AuthProvider implements AutoCloseable {
|
||||
private static final Map<String, Class> AUTH_PROVIDERS = new ConcurrentHashMap<>(8);
|
||||
private static final Map<String, Class<? extends AuthProvider>> AUTH_PROVIDERS = new ConcurrentHashMap<>(8);
|
||||
private static boolean registredProv = false;
|
||||
private transient LaunchServer server = LaunchServer.server;
|
||||
|
||||
|
@ -22,7 +21,7 @@ public static AuthProviderResult authError(String message) throws AuthException
|
|||
}
|
||||
|
||||
|
||||
public static void registerProvider(String name, Class adapter) {
|
||||
public static void registerProvider(String name, Class<? extends AuthProvider> adapter) {
|
||||
VerifyHelper.putIfAbsent(AUTH_PROVIDERS, name, Objects.requireNonNull(adapter, "adapter"),
|
||||
String.format("Auth provider has been already registered: '%s'", name));
|
||||
}
|
||||
|
@ -52,13 +51,13 @@ public AuthHandler getAccociateHandler(int this_position) {
|
|||
@Override
|
||||
public abstract void close() throws IOException;
|
||||
|
||||
public static Class getProviderClass(String name)
|
||||
public static Class<? extends AuthProvider> getProviderClass(String name)
|
||||
{
|
||||
return AUTH_PROVIDERS.get(name);
|
||||
}
|
||||
public static String getProviderName(Class clazz)
|
||||
public static String getProviderName(Class<? extends AuthProvider> clazz)
|
||||
{
|
||||
for(Map.Entry<String,Class> e: AUTH_PROVIDERS.entrySet())
|
||||
for(Map.Entry<String,Class<? extends AuthProvider>> e: AUTH_PROVIDERS.entrySet())
|
||||
{
|
||||
if(e.getValue().equals(clazz)) return e.getKey();
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.HTTPRequest;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.HTTPRequest;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public final class JsonAuthProvider extends AuthProvider {
|
||||
private Gson gson = new Gson();
|
||||
private URL url;
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import ru.gravit.utils.HTTPRequest;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import ru.gravit.utils.HTTPRequest;
|
||||
|
||||
public final class MojangAuthProvider extends AuthProvider {
|
||||
private static final Pattern UUID_REGEX = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})");
|
||||
private static final URL URL;
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public final class MySQLAuthProvider extends AuthProvider {
|
||||
private MySQLSourceConfig mySQLHolder;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public final class NullAuthProvider extends AuthProvider {
|
||||
private volatile AuthProvider provider;
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public final class RequestAuthProvider extends AuthProvider {
|
||||
private String url;
|
||||
private Pattern response;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
|
@ -10,6 +8,8 @@
|
|||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
public class BuildContext {
|
||||
public final ZipOutputStream output;
|
||||
public final JAConfigurator config;
|
||||
|
@ -38,7 +38,7 @@ public void pushJarFile(ZipInputStream input) throws IOException {
|
|||
e = input.getNextEntry();
|
||||
continue;
|
||||
}
|
||||
output.putNextEntry(e);
|
||||
output.putNextEntry(IOHelper.newZipEntry(e));
|
||||
IOHelper.transfer(input, output);
|
||||
fileList.add(e.getName());
|
||||
e = input.getNextEntry();
|
||||
|
@ -52,7 +52,7 @@ public void pushJarFile(ZipInputStream input, Set<String> blacklist) throws IOEx
|
|||
e = input.getNextEntry();
|
||||
continue;
|
||||
}
|
||||
output.putNextEntry(e);
|
||||
output.putNextEntry(IOHelper.newZipEntry(e));
|
||||
IOHelper.transfer(input, output);
|
||||
fileList.add(e.getName());
|
||||
e = input.getNextEntry();
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import net.sf.launch4j.Builder;
|
||||
import net.sf.launch4j.Log;
|
||||
import net.sf.launch4j.config.*;
|
||||
import net.sf.launch4j.config.Config;
|
||||
import net.sf.launch4j.config.ConfigPersister;
|
||||
import net.sf.launch4j.config.Jre;
|
||||
import net.sf.launch4j.config.LanguageID;
|
||||
import net.sf.launch4j.config.VersionInfo;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class EXEL4JLauncherBinary extends LauncherBinary {
|
||||
private final static class Launch4JLog extends Log {
|
||||
private static final Launch4JLog INSTANCE = new Launch4JLog();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class EXELauncherBinary extends LauncherBinary {
|
||||
|
||||
public EXELauncherBinary(LaunchServer server) {
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import javassist.*;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javassist.CannotCompileException;
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtConstructor;
|
||||
import javassist.CtMethod;
|
||||
import javassist.NotFoundException;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
|
||||
public class JAConfigurator implements AutoCloseable {
|
||||
public ClassPool pool;
|
||||
public CtClass ctClass;
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import javassist.CannotCompileException;
|
||||
import javassist.NotFoundException;
|
||||
import proguard.Configuration;
|
||||
import proguard.ConfigurationParser;
|
||||
import proguard.ParseException;
|
||||
import proguard.ProGuard;
|
||||
import ru.gravit.launcher.AutogenConfig;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.asm.ClassMetadataReader;
|
||||
import ru.gravit.launchserver.manangers.BuildHookManager.ZipBuildHook;
|
||||
import ru.gravit.utils.helper.*;
|
||||
import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
|
||||
import static ru.gravit.utils.helper.IOHelper.newZipEntry;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -34,7 +20,25 @@
|
|||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static ru.gravit.utils.helper.IOHelper.newZipEntry;
|
||||
import javassist.CannotCompileException;
|
||||
import javassist.NotFoundException;
|
||||
import proguard.Configuration;
|
||||
import proguard.ConfigurationParser;
|
||||
import proguard.ParseException;
|
||||
import proguard.ProGuard;
|
||||
import ru.gravit.launcher.AutogenConfig;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.asm.ClassMetadataReader;
|
||||
import ru.gravit.launchserver.manangers.BuildHookManager.ZipBuildHook;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
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 ru.gravit.utils.helper.UnpackHelper;
|
||||
|
||||
public final class JARLauncherBinary extends LauncherBinary {
|
||||
|
||||
|
@ -122,7 +126,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
|
|||
runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
|
||||
guardDir = server.dir.resolve(Launcher.GUARD_DIR);
|
||||
initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE);
|
||||
obfJar = server.dir.resolve(server.config.binaryName + "-obfed.jar");
|
||||
obfJar = server.dir.resolve(server.config.binaryName + "-obfPre.jar");
|
||||
obfOutJar = server.config.buildPostTransform.enabled ? server.dir.resolve(server.config.binaryName + "-obf.jar")
|
||||
: syncBinaryFile;
|
||||
cleanJar = server.dir.resolve(server.config.binaryName + "-clean.jar");
|
||||
|
@ -158,7 +162,7 @@ public void build() throws IOException {
|
|||
ZipEntry e = input.getNextEntry();
|
||||
while (e != null) {
|
||||
String filename = e.getName();
|
||||
output.putNextEntry(IOHelper.newZipEntry(e.getName()));
|
||||
output.putNextEntry(IOHelper.newZipEntry(e));
|
||||
if (filename.endsWith(".class")) {
|
||||
String classname = filename.replace('/', '.').substring(0, filename.length() - ".class".length());
|
||||
byte[] bytes;
|
||||
|
@ -222,7 +226,7 @@ private void stdBuild() throws IOException {
|
|||
continue;
|
||||
}
|
||||
try {
|
||||
output.putNextEntry(IOHelper.newZipEntry(e.getName()));
|
||||
output.putNextEntry(IOHelper.newZipEntry(e));
|
||||
} catch (ZipException ex) {
|
||||
LogHelper.error(ex);
|
||||
e = input.getNextEntry();
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import ru.gravit.launcher.serialize.signed.DigestBytesHolder;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public abstract class LauncherBinary {
|
||||
|
||||
public final LaunchServer server;
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package ru.gravit.launchserver;
|
||||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public class ProguardConf {
|
||||
private static final String charsFirst = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";
|
||||
private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ";
|
||||
|
@ -37,7 +42,7 @@ public ProguardConf(LaunchServer srv) {
|
|||
if (srv.config.genMappings) confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'");
|
||||
confStrs.add("-obfuscationdictionary \'" + words.toFile().getName() + "\'");
|
||||
confStrs.add("-injar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-nonObf.jar\'");
|
||||
confStrs.add("-outjar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-obfed.jar\'");
|
||||
confStrs.add("-outjar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-obfPre.jar\'");
|
||||
confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'");
|
||||
confStrs.add(readConf());
|
||||
|
||||
|
@ -55,7 +60,6 @@ private void genConfig(boolean force) throws IOException {
|
|||
public void genWords(boolean force) throws IOException {
|
||||
if (IOHelper.exists(words) && !force) return;
|
||||
Files.deleteIfExists(words);
|
||||
words.toFile().createNewFile();
|
||||
SecureRandom rand = SecurityHelper.newRandom();
|
||||
rand.setSeed(SecureRandom.getSeed(32));
|
||||
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(IOHelper.newOutput(words), IOHelper.UNICODE_CHARSET))) {
|
|
@ -1,10 +1,10 @@
|
|||
package ru.gravit.launchserver.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class Command {
|
||||
|
||||
protected static String parseUsername(String username) throws CommandException {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ru.gravit.launchserver.command.auth;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProvider;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class AuthCommand extends Command {
|
||||
public AuthCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.command.auth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BanCommand extends Command {
|
||||
public BanCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ru.gravit.launchserver.command.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class UUIDToUsernameCommand extends Command {
|
||||
public UUIDToUsernameCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.command.auth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UnbanCommand extends Command {
|
||||
public UnbanCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ru.gravit.launchserver.command.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class UsernameToUUIDCommand extends Command {
|
||||
public UsernameToUUIDCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.gravit.launchserver.command.basic;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public final class HelpCommand extends Command {
|
||||
private static void printCommand(String name, Command command) {
|
||||
String args = command.getArgsDescription();
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.command.basic;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
|
@ -19,7 +22,8 @@ public String getUsageDescription() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) {
|
||||
public void invoke(String... args) throws IOException {
|
||||
server.proguardConf.prepare(true);
|
||||
Files.deleteIfExists(server.proguardConf.mappings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ru.gravit.launchserver.command.basic;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class RegenProguardDictCommand extends Command {
|
||||
|
||||
public RegenProguardDictCommand(LaunchServer server) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.command.basic;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
public class RemoveMappingsProguardCommand extends Command {
|
||||
|
||||
public RemoveMappingsProguardCommand(LaunchServer server) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ru.gravit.launchserver.command.basic;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import java.io.Writer;
|
||||
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
@ -8,8 +9,6 @@
|
|||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
public class TestCommand extends Command {
|
||||
public TestCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,22 +1,17 @@
|
|||
package ru.gravit.launchserver.command.dump;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.handler.CachedAuthHandler;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.handler.CachedAuthHandler;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class DumpEntryCacheCommand extends Command {
|
||||
public DumpEntryCacheCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
package ru.gravit.launchserver.command.dump;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import javafx.scene.media.MediaException;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -16,6 +7,14 @@
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class DumpSessionsCommand extends Command {
|
||||
public DumpSessionsCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,25 +1,52 @@
|
|||
package ru.gravit.launchserver.command.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
import ru.gravit.launchserver.command.auth.*;
|
||||
import ru.gravit.launchserver.command.basic.*;
|
||||
import ru.gravit.launchserver.command.auth.AuthCommand;
|
||||
import ru.gravit.launchserver.command.auth.BanCommand;
|
||||
import ru.gravit.launchserver.command.auth.UUIDToUsernameCommand;
|
||||
import ru.gravit.launchserver.command.auth.UnbanCommand;
|
||||
import ru.gravit.launchserver.command.auth.UsernameToUUIDCommand;
|
||||
import ru.gravit.launchserver.command.basic.BuildCommand;
|
||||
import ru.gravit.launchserver.command.basic.ClearCommand;
|
||||
import ru.gravit.launchserver.command.basic.DebugCommand;
|
||||
import ru.gravit.launchserver.command.basic.GCCommand;
|
||||
import ru.gravit.launchserver.command.basic.HelpCommand;
|
||||
import ru.gravit.launchserver.command.basic.LogConnectionsCommand;
|
||||
import ru.gravit.launchserver.command.basic.ProguardCleanCommand;
|
||||
import ru.gravit.launchserver.command.basic.RebindCommand;
|
||||
import ru.gravit.launchserver.command.basic.RegenProguardDictCommand;
|
||||
import ru.gravit.launchserver.command.basic.RemoveMappingsProguardCommand;
|
||||
import ru.gravit.launchserver.command.basic.StopCommand;
|
||||
import ru.gravit.launchserver.command.basic.TestCommand;
|
||||
import ru.gravit.launchserver.command.basic.VersionCommand;
|
||||
import ru.gravit.launchserver.command.dump.DumpEntryCacheCommand;
|
||||
import ru.gravit.launchserver.command.dump.DumpSessionsCommand;
|
||||
import ru.gravit.launchserver.command.hash.*;
|
||||
import ru.gravit.launchserver.command.hash.DownloadAssetCommand;
|
||||
import ru.gravit.launchserver.command.hash.DownloadClientCommand;
|
||||
import ru.gravit.launchserver.command.hash.IndexAssetCommand;
|
||||
import ru.gravit.launchserver.command.hash.SyncBinariesCommand;
|
||||
import ru.gravit.launchserver.command.hash.SyncProfilesCommand;
|
||||
import ru.gravit.launchserver.command.hash.SyncUpdatesCommand;
|
||||
import ru.gravit.launchserver.command.hash.UnindexAssetCommand;
|
||||
import ru.gravit.launchserver.command.modules.LoadModuleCommand;
|
||||
import ru.gravit.launchserver.command.modules.ModulesCommand;
|
||||
import ru.gravit.launchserver.command.service.*;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class CommandHandler implements Runnable {
|
||||
private static String[] parse(CharSequence line) throws CommandException {
|
||||
boolean quoted = false;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.gravit.launchserver.command.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import jline.console.ConsoleReader;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.LogHelper.Output;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class JLineCommandHandler extends CommandHandler {
|
||||
private final class JLineOutput implements Output {
|
||||
@Override
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.command.handler;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
public final class StdCommandHandler extends CommandHandler {
|
||||
private final BufferedReader reader;
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
import ru.gravit.launcher.profiles.ClientProfile.Version;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
@ -7,10 +11,6 @@
|
|||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
public final class DownloadAssetCommand extends Command {
|
||||
|
||||
public DownloadAssetCommand(LaunchServer server) {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.profiles.ClientProfile.Version;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
|
@ -10,13 +16,6 @@
|
|||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
public final class DownloadClientCommand extends Command {
|
||||
|
||||
public DownloadClientCommand(LaunchServer server) {
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
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.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
|
@ -19,6 +9,17 @@
|
|||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
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;
|
||||
|
||||
public final class IndexAssetCommand extends Command {
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class SyncBinariesCommand extends Command {
|
||||
public SyncBinariesCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class SyncProfilesCommand extends Command {
|
||||
public SyncProfilesCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public final class SyncUpdatesCommand extends Command {
|
||||
public SyncUpdatesCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.command.CommandException;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public final class UnindexAssetCommand extends Command {
|
||||
private static JsonParser parser = new JsonParser();
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.command.modules;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
public class LoadModuleCommand extends Command {
|
||||
public LoadModuleCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class ReloadListCommand extends Command {
|
||||
public ReloadListCommand(LaunchServer server) {
|
||||
|
|
|
@ -23,7 +23,8 @@ public String getUsageDescription() {
|
|||
return "Change authProvider";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
verifyArgs(args,2);
|
||||
if(providersCache == null) providersCache = new AuthProvider[server.config.authProvider.length];
|
||||
|
@ -32,7 +33,7 @@ public void invoke(String... args) throws Exception {
|
|||
{
|
||||
if(providersCache[index] == null)
|
||||
{
|
||||
AcceptAuthProvider provider = new AcceptAuthProvider();
|
||||
AcceptAuthProvider provider = new AcceptAuthProvider();
|
||||
providersCache[index] = server.config.authProvider[index];
|
||||
server.config.authProvider[index] = provider;
|
||||
LogHelper.info("AuthProvider[%d] is AcceptAuthProvider",index);
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
import ru.gravit.launchserver.auth.handler.AuthHandler;
|
||||
import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import ru.gravit.launchserver.auth.handler.AuthHandler;
|
||||
|
||||
public class AuthHandlerAdapter implements JsonSerializer<AuthHandler>, JsonDeserializer<AuthHandler> {
|
||||
private static final String PROP_NAME = "type";
|
||||
@Override
|
||||
public AuthHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
|
||||
Class<AuthHandler> cls = AuthHandler.getHandlerClass(typename);
|
||||
Class<? extends AuthHandler> cls = AuthHandler.getHandlerClass(typename);
|
||||
|
||||
|
||||
return (AuthHandler) context.deserialize(json, cls);
|
||||
|
@ -21,7 +28,8 @@ public AuthHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializati
|
|||
public JsonElement serialize(AuthHandler src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject jo = context.serialize(src).getAsJsonObject();
|
||||
|
||||
String classPath = AuthHandler.getHandlerName(src.getClass());
|
||||
@SuppressWarnings("unchecked")
|
||||
String classPath = AuthHandler.getHandlerName((Class<AuthHandler>) src.getClass());
|
||||
jo.add(PROP_NAME, new JsonPrimitive(classPath));
|
||||
|
||||
return jo;
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
import ru.gravit.launchserver.auth.handler.AuthHandler;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProvider;
|
||||
import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import ru.gravit.launchserver.auth.provider.AuthProvider;
|
||||
|
||||
public class AuthProviderAdapter implements JsonSerializer<AuthProvider>, JsonDeserializer<AuthProvider> {
|
||||
private static final String PROP_NAME = "type";
|
||||
@Override
|
||||
public AuthProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
|
||||
Class<AuthProvider> cls = AuthProvider.getProviderClass(typename);
|
||||
Class<? extends AuthProvider> cls = AuthProvider.getProviderClass(typename);
|
||||
|
||||
|
||||
return (AuthProvider) context.deserialize(json, cls);
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
import ru.gravit.launchserver.auth.handler.AuthHandler;
|
||||
import ru.gravit.launchserver.auth.hwid.HWIDHandler;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import ru.gravit.launchserver.auth.hwid.HWIDHandler;
|
||||
|
||||
public class HWIDHandlerAdapter implements JsonSerializer<HWIDHandler>, JsonDeserializer<HWIDHandler> {
|
||||
private static final String PROP_NAME = "type";
|
||||
@Override
|
||||
public HWIDHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
|
||||
Class<HWIDHandler> cls = HWIDHandler.getHandlerClass(typename);
|
||||
Class<? extends HWIDHandler> cls = HWIDHandler.getHandlerClass(typename);
|
||||
|
||||
|
||||
return (HWIDHandler) context.deserialize(json, cls);
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
import ru.gravit.launchserver.auth.handler.AuthHandler;
|
||||
import ru.gravit.launchserver.auth.permissions.PermissionsHandler;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import ru.gravit.launchserver.auth.permissions.PermissionsHandler;
|
||||
|
||||
public class PermissionsHandlerAdapter implements JsonSerializer<PermissionsHandler>, JsonDeserializer<PermissionsHandler> {
|
||||
private static final String PROP_NAME = "type";
|
||||
@Override
|
||||
public PermissionsHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
|
||||
Class<PermissionsHandler> cls = PermissionsHandler.getHandlerClass(typename);
|
||||
Class<? extends PermissionsHandler> cls = PermissionsHandler.getHandlerClass(typename);
|
||||
|
||||
|
||||
return (PermissionsHandler) context.deserialize(json, cls);
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProvider;
|
||||
import ru.gravit.launchserver.texture.TextureProvider;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import ru.gravit.launchserver.texture.TextureProvider;
|
||||
|
||||
public class TextureProviderAdapter implements JsonSerializer<TextureProvider>, JsonDeserializer<TextureProvider> {
|
||||
private static final String PROP_NAME = "type";
|
||||
@Override
|
||||
public TextureProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
|
||||
Class<AuthProvider> cls = TextureProvider.getProviderClass(typename);
|
||||
Class<? extends TextureProvider> cls = TextureProvider.getProviderClass(typename);
|
||||
|
||||
|
||||
return (TextureProvider) context.deserialize(json, cls);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.fileserver;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public class ClosingChannelFutureListener implements ChannelFutureListener {
|
||||
public final Closeable[] close;
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package ru.gravit.launchserver.fileserver;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import io.netty.handler.stream.ChunkedFile;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import static io.netty.handler.codec.http.HttpMethod.GET;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.FOUND;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_MODIFIED;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
||||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
@ -16,12 +18,38 @@
|
|||
import java.net.URLDecoder;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpMethod.GET;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.*;
|
||||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelProgressiveFuture;
|
||||
import io.netty.channel.ChannelProgressiveFutureListener;
|
||||
import io.netty.channel.DefaultFileRegion;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpResponse;
|
||||
import io.netty.handler.codec.http.DefaultHttpResponse;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import io.netty.handler.codec.http.HttpChunkedInput;
|
||||
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
import io.netty.handler.codec.http.HttpHeaderValues;
|
||||
import io.netty.handler.codec.http.HttpResponse;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.handler.codec.http.HttpUtil;
|
||||
import io.netty.handler.codec.http.LastHttpContent;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import io.netty.handler.stream.ChunkedFile;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
public class FileServerHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import ru.gravit.launcher.AutogenConfig;
|
||||
import ru.gravit.launcher.modules.TestClientModule;
|
||||
import ru.gravit.launchserver.binary.BuildContext;
|
||||
import ru.gravit.launchserver.binary.JAConfigurator;
|
||||
import ru.gravit.launchserver.binary.JARLauncherBinary;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import ru.gravit.launcher.AutogenConfig;
|
||||
import ru.gravit.launcher.modules.TestClientModule;
|
||||
import ru.gravit.launchserver.binary.BuildContext;
|
||||
import ru.gravit.launchserver.binary.JAConfigurator;
|
||||
import ru.gravit.launchserver.binary.JARLauncherBinary;
|
||||
|
||||
public class BuildHookManager {
|
||||
@FunctionalInterface
|
||||
public interface ZipBuildHook {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
public class MirrorManager {
|
||||
public class Mirror {
|
||||
URL url;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ru.gravit.launcher.modules.SimpleModuleManager;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.modules.CoreModule;
|
||||
import ru.gravit.launchserver.modules.LaunchServerModuleContext;
|
||||
import ru.gravit.utils.PublicURLClassLoader;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ModulesManager extends SimpleModuleManager {
|
||||
public ModulesManager(LaunchServer lsrv) {
|
||||
modules = new ArrayList<>(1);
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import ru.gravit.launchserver.asm.SafeClassWriter;
|
||||
import ru.gravit.launchserver.binary.JARLauncherBinary;
|
||||
import ru.gravit.launchserver.manangers.BuildHookManager.Transformer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NodeTransformer implements Transformer {
|
||||
@FunctionalInterface
|
||||
public interface ClassNodeTransformer {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import ru.gravit.launchserver.Reconfigurable;
|
||||
import ru.gravit.launchserver.Reloadable;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import ru.gravit.launchserver.Reloadable;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ReloadManager {
|
||||
private final HashMap<String,Reloadable> RELOADABLES = new HashMap<>();
|
||||
public void registerReloadable(String name,Reloadable reloadable)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
|
||||
public class SessionManager implements NeedGarbageCollection {
|
||||
|
||||
public static final long SESSION_TIMEOUT = 10 * 60 * 1000; // 10 минут
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.gravit.launchserver.response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class PingResponse extends Response {
|
||||
public PingResponse(LaunchServer server, long id, HInput input, HOutput output, String ip) {
|
||||
super(server, id, input, output, ip);
|
||||
|
|
|
@ -1,21 +1,30 @@
|
|||
package ru.gravit.launchserver.response;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ru.gravit.launcher.request.RequestException;
|
||||
import ru.gravit.launcher.request.RequestType;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.response.auth.*;
|
||||
import ru.gravit.launchserver.response.auth.AuthResponse;
|
||||
import ru.gravit.launchserver.response.auth.AuthServerResponse;
|
||||
import ru.gravit.launchserver.response.auth.ChangeServerResponse;
|
||||
import ru.gravit.launchserver.response.auth.CheckServerResponse;
|
||||
import ru.gravit.launchserver.response.auth.JoinServerResponse;
|
||||
import ru.gravit.launchserver.response.auth.SetProfileResponse;
|
||||
import ru.gravit.launchserver.response.profile.BatchProfileByUsernameResponse;
|
||||
import ru.gravit.launchserver.response.profile.ProfileByUUIDResponse;
|
||||
import ru.gravit.launchserver.response.profile.ProfileByUsernameResponse;
|
||||
import ru.gravit.launchserver.response.update.*;
|
||||
import ru.gravit.launchserver.response.update.LauncherResponse;
|
||||
import ru.gravit.launchserver.response.update.LegacyLauncherResponse;
|
||||
import ru.gravit.launchserver.response.update.ProfilesResponse;
|
||||
import ru.gravit.launchserver.response.update.UpdateListResponse;
|
||||
import ru.gravit.launchserver.response.update.UpdateResponse;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class Response {
|
||||
@FunctionalInterface
|
||||
public interface Factory<R> {
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package ru.gravit.launchserver.response.auth;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
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.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.hwid.HWIDException;
|
||||
|
@ -19,12 +25,6 @@
|
|||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class AuthResponse extends Response {
|
||||
private static String echo(int length) {
|
||||
char[] chars = new char[length];
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package ru.gravit.launchserver.response.auth;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
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.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.hwid.HWIDException;
|
||||
|
@ -17,11 +22,6 @@
|
|||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public final class AuthServerResponse extends Response {
|
||||
private static String echo(int length) {
|
||||
char[] chars = new char[length];
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.response.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
|
@ -10,9 +13,6 @@
|
|||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class CheckServerResponse extends Response {
|
||||
|
||||
public CheckServerResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ru.gravit.launchserver.response.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
|
@ -10,8 +12,6 @@
|
|||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class JoinServerResponse extends Response {
|
||||
|
||||
public JoinServerResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package ru.gravit.launchserver.response.auth;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
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.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class SetProfileResponse extends Response {
|
||||
public SetProfileResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
super(server, session, input, output, ip);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.response.profile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
|
@ -7,9 +10,6 @@
|
|||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class BatchProfileByUsernameResponse extends Response {
|
||||
|
||||
public BatchProfileByUsernameResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.response.profile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.profiles.Texture;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
|
@ -9,9 +12,6 @@
|
|||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ProfileByUUIDResponse extends Response {
|
||||
|
||||
public static PlayerProfile getProfile(LaunchServer server, UUID uuid, String username, String client) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.response.profile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
|
@ -7,9 +10,6 @@
|
|||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ProfileByUsernameResponse extends Response {
|
||||
|
||||
public static void writeProfile(LaunchServer server, HOutput output, String username, String client) throws IOException {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.response.update;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.signed.DigestBytesHolder;
|
||||
|
@ -7,9 +10,6 @@
|
|||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class LauncherResponse extends Response {
|
||||
|
||||
public LauncherResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ru.gravit.launchserver.response.update;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
|
@ -7,8 +9,6 @@
|
|||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class LegacyLauncherResponse extends Response {
|
||||
|
||||
public LegacyLauncherResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package ru.gravit.launchserver.response.update;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
public final class ProfilesResponse extends Response {
|
||||
|
||||
public ProfilesResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.response.update;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import ru.gravit.launcher.hasher.HashedDir;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
|
@ -7,9 +10,6 @@
|
|||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.response.Response;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
public final class UpdateListResponse extends Response {
|
||||
|
||||
public UpdateListResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
package ru.gravit.launchserver.response.update;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
|
||||
import ru.gravit.launcher.hasher.HashedDir;
|
||||
import ru.gravit.launcher.hasher.HashedEntry;
|
||||
import ru.gravit.launcher.hasher.HashedEntry.Type;
|
||||
|
@ -14,14 +22,6 @@
|
|||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
|
||||
public final class UpdateResponse extends Response {
|
||||
|
||||
public UpdateResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
|
|
|
@ -1,5 +1,34 @@
|
|||
package ru.gravit.launchserver.socket;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.UnrecoverableKeyException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLServerSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
|
@ -24,29 +53,6 @@
|
|||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLServerSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.security.*;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@SuppressWarnings({"unused", "rawtypes"})
|
||||
public final class NettyServerSocketHandler implements Runnable, AutoCloseable {
|
||||
private static final String WEBSOCKET_PATH = "/api";
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package ru.gravit.launchserver.socket;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.request.RequestException;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
|
@ -11,11 +16,6 @@
|
|||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
|
||||
public final class ResponseThread implements Runnable {
|
||||
class Handshake {
|
||||
int type;
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
package ru.gravit.launchserver.socket;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import ru.gravit.launcher.managers.GarbageManager;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.manangers.SessionManager;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public final class ServerSocketHandler implements Runnable, AutoCloseable {
|
||||
public interface Listener {
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ru.gravit.launchserver.socket.websocket;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.group.DefaultChannelGroup;
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
package ru.gravit.launchserver.socket.websocket;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpMethod.GET;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
|
||||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import static io.netty.handler.codec.rtsp.RtspResponseStatuses.NOT_FOUND;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpResponse;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpUtil;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpMethod.GET;
|
||||
import static io.netty.handler.codec.http.HttpResponseStatus.*;
|
||||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import static io.netty.handler.codec.rtsp.RtspResponseStatuses.NOT_FOUND;
|
||||
|
||||
public class WebSocketIndexPageHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
|
||||
private final String websocketPath;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package ru.gravit.launchserver.socket.websocket;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
@ -21,8 +24,6 @@
|
|||
import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@SuppressWarnings({"unused", "rawtypes"})
|
||||
public class WebSocketService {
|
||||
public final ChannelGroup channels;
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
package ru.gravit.launchserver.socket.websocket.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import ru.gravit.launchserver.socket.websocket.WebSocketService;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import ru.gravit.launchserver.socket.websocket.WebSocketService;
|
||||
|
||||
public class JsonResponseAdapter implements JsonSerializer<JsonResponseInterface>, JsonDeserializer<JsonResponseInterface> {
|
||||
private final WebSocketService service;
|
||||
private static final String PROP_NAME = "type";
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package ru.gravit.launchserver.socket.websocket.json.auth;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.hwid.HWIDException;
|
||||
|
@ -15,8 +16,6 @@
|
|||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class AuthResponse implements JsonResponseInterface {
|
||||
public String login;
|
||||
public String client;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.socket.websocket.json.update;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
|
@ -7,9 +10,6 @@
|
|||
import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface;
|
||||
import ru.gravit.utils.Version;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
public class LauncherResponse implements JsonResponseInterface {
|
||||
public Version version;
|
||||
public String hash;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ru.gravit.launchserver.texture;
|
||||
|
||||
import ru.gravit.launcher.profiles.Texture;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launcher.profiles.Texture;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public final class NullTextureProvider extends TextureProvider {
|
||||
private volatile TextureProvider provider;
|
||||
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
package ru.gravit.launchserver.texture;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.profiles.Texture;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class RequestTextureProvider extends TextureProvider {
|
||||
public RequestTextureProvider() {
|
||||
}
|
||||
|
||||
private static final UUID ZERO_UUID = new UUID(0, 0);
|
||||
|
||||
public RequestTextureProvider(String skinURL, String cloakURL) {
|
||||
this.skinURL = skinURL;
|
||||
this.cloakURL = cloakURL;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue