mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[ANY] IDEA Code Reformat
This commit is contained in:
parent
a2b3ac523b
commit
9884730b1b
141 changed files with 1277 additions and 1529 deletions
|
@ -1,42 +1,7 @@
|
|||
package ru.gravit.launchserver;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ProcessBuilder.Redirect;
|
||||
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.ArrayList;
|
||||
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 ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.hasher.HashedDir;
|
||||
|
@ -52,24 +17,12 @@
|
|||
import ru.gravit.launchserver.auth.permissions.PermissionsHandler;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProvider;
|
||||
import ru.gravit.launchserver.auth.provider.RejectAuthProvider;
|
||||
import ru.gravit.launchserver.binary.EXEL4JLauncherBinary;
|
||||
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.binary.*;
|
||||
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.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.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.config.*;
|
||||
import ru.gravit.launchserver.manangers.*;
|
||||
import ru.gravit.launchserver.manangers.hook.AuthHookManager;
|
||||
import ru.gravit.launchserver.manangers.hook.BuildHookManager;
|
||||
import ru.gravit.launchserver.manangers.hook.SocketHookManager;
|
||||
|
@ -77,12 +30,28 @@
|
|||
import ru.gravit.launchserver.socket.ServerSocketHandler;
|
||||
import ru.gravit.launchserver.texture.RequestTextureProvider;
|
||||
import ru.gravit.launchserver.texture.TextureProvider;
|
||||
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 ru.gravit.utils.helper.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ProcessBuilder.Redirect;
|
||||
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 {
|
||||
public static final class Config {
|
||||
|
@ -178,24 +147,19 @@ public void setAddress(String address) {
|
|||
|
||||
public void verify() {
|
||||
VerifyHelper.verify(getAddress(), VerifyHelper.NOT_EMPTY, "LaunchServer address can't be empty");
|
||||
if(authHandler == null)
|
||||
{
|
||||
if (authHandler == null) {
|
||||
throw new NullPointerException("AuthHandler must not be null");
|
||||
}
|
||||
if(authProvider == null || authProvider[0] == null)
|
||||
{
|
||||
if (authProvider == null || authProvider[0] == null) {
|
||||
throw new NullPointerException("AuthProvider must not be null");
|
||||
}
|
||||
if(textureProvider == null)
|
||||
{
|
||||
if (textureProvider == null) {
|
||||
throw new NullPointerException("TextureProvider must not be null");
|
||||
}
|
||||
if(permissionsHandler == null)
|
||||
{
|
||||
if (permissionsHandler == null) {
|
||||
throw new NullPointerException("PermissionsHandler must not be null");
|
||||
}
|
||||
if(env == null)
|
||||
{
|
||||
if (env == null) {
|
||||
throw new NullPointerException("Env must not be null");
|
||||
}
|
||||
}
|
||||
|
@ -403,8 +367,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
|
|||
config = Launcher.gson.fromJson(reader, Config.class);
|
||||
}
|
||||
config.verify();
|
||||
for(AuthProvider provider : config.authProvider)
|
||||
{
|
||||
for (AuthProvider provider : config.authProvider) {
|
||||
provider.init();
|
||||
}
|
||||
config.authHandler.init();
|
||||
|
@ -425,8 +388,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
|
|||
reloadManager.registerReloadable("permissionsHandler", (Reloadable) config.permissionsHandler);
|
||||
if (config.authHandler instanceof Reloadable)
|
||||
reloadManager.registerReloadable("authHandler", (Reloadable) config.authHandler);
|
||||
for(int i=0;i<config.authProvider.length;++i)
|
||||
{
|
||||
for (int i = 0; i < config.authProvider.length; ++i) {
|
||||
AuthProvider provider = config.authProvider[i];
|
||||
if (provider instanceof Reloadable)
|
||||
reloadManager.registerReloadable("authHandler".concat(String.valueOf(i)), (Reloadable) provider);
|
||||
|
@ -446,8 +408,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
|
|||
reconfigurableManager.registerReconfigurable("permissionsHandler", (Reconfigurable) config.permissionsHandler);
|
||||
if (config.authHandler instanceof Reconfigurable)
|
||||
reconfigurableManager.registerReconfigurable("authHandler", (Reconfigurable) config.authHandler);
|
||||
for(int i=0;i<config.authProvider.length;++i)
|
||||
{
|
||||
for (int i = 0; i < config.authProvider.length; ++i) {
|
||||
AuthProvider provider = config.authProvider[i];
|
||||
if (provider instanceof Reconfigurable)
|
||||
reconfigurableManager.registerReconfigurable("authHandler".concat(String.valueOf(i)), (Reconfigurable) provider);
|
||||
|
@ -492,8 +453,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
|
|||
modulesManager.postInitModules();
|
||||
}
|
||||
|
||||
public static void initGson()
|
||||
{
|
||||
public static void initGson() {
|
||||
if (Launcher.gson != null) return;
|
||||
Launcher.gsonBuilder = new GsonBuilder();
|
||||
Launcher.gsonBuilder.registerTypeAdapter(AuthProvider.class, new AuthProviderAdapter());
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
public interface Reconfigurable {
|
||||
void reconfig(String action, String[] args);
|
||||
|
||||
void printConfigHelp();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package ru.gravit.launchserver;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Reloadable {
|
||||
void reload() throws Exception;
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
|
||||
import java.io.IOException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
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.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Collections;
|
||||
import java.util.jar.JarFile;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
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.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -8,12 +13,6 @@
|
|||
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,17 +1,15 @@
|
|||
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,15 +1,15 @@
|
|||
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<? extends AuthHandler>> AUTH_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
private static boolean registredHandl = false;
|
||||
|
@ -25,14 +25,13 @@ public static void registerHandler(String name, Class<? extends AuthHandler> ada
|
|||
VerifyHelper.putIfAbsent(AUTH_HANDLERS, name, Objects.requireNonNull(adapter, "adapter"),
|
||||
String.format("Auth handler has been already registered: '%s'", name));
|
||||
}
|
||||
public static Class<? extends AuthHandler> getHandlerClass(String name)
|
||||
{
|
||||
|
||||
public static Class<? extends AuthHandler> getHandlerClass(String name) {
|
||||
return AUTH_HANDLERS.get(name);
|
||||
}
|
||||
public static String getHandlerName(Class<AuthHandler> clazz)
|
||||
{
|
||||
for(Map.Entry<String,Class<? extends AuthHandler>> e: AUTH_HANDLERS.entrySet())
|
||||
{
|
||||
|
||||
public static String getHandlerName(Class<AuthHandler> clazz) {
|
||||
for (Map.Entry<String, Class<? extends AuthHandler>> e : AUTH_HANDLERS.entrySet()) {
|
||||
if (e.getValue().equals(clazz)) return e.getKey();
|
||||
}
|
||||
return null;
|
||||
|
@ -66,8 +65,7 @@ public static void registerHandlers() {
|
|||
|
||||
public abstract String uuidToUsername(UUID uuid) throws IOException;
|
||||
|
||||
public void init()
|
||||
{
|
||||
public void init() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,17 +1,17 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection {
|
||||
public static final class Entry {
|
||||
|
||||
|
@ -28,6 +28,7 @@ public Entry(UUID uuid, String username, String accessToken, String serverID) {
|
|||
this.serverID = serverID == null ? null : VerifyHelper.verifyServerID(serverID);
|
||||
}
|
||||
}
|
||||
|
||||
private transient final Map<UUID, Entry> entryCache = new HashMap<>(1024);
|
||||
private transient final Map<String, UUID> usernamesCache = new HashMap<>(1024);
|
||||
|
||||
|
@ -114,12 +115,11 @@ public Map<String, UUID> getUsernamesCache() {
|
|||
return usernamesCache;
|
||||
}
|
||||
|
||||
public void loadEntryCache(Map<UUID, Entry> map)
|
||||
{
|
||||
public void loadEntryCache(Map<UUID, Entry> map) {
|
||||
entryCache.putAll(map);
|
||||
}
|
||||
public void loadUsernameCache(Map<String, UUID> map)
|
||||
{
|
||||
|
||||
public void loadUsernameCache(Map<String, UUID> map) {
|
||||
usernamesCache.putAll(map);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,17 @@
|
|||
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.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;
|
||||
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;
|
||||
|
||||
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,5 +1,8 @@
|
|||
package ru.gravit.launchserver.auth.handler;
|
||||
|
||||
import ru.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
@ -7,9 +10,6 @@
|
|||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import ru.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public final class MySQLAuthHandler extends CachedAuthHandler {
|
||||
private MySQLSourceConfig mySQLHolder;
|
||||
private String uuidColumn;
|
||||
|
@ -23,9 +23,9 @@ public final class MySQLAuthHandler extends CachedAuthHandler {
|
|||
private transient String queryByUsernameSQL;
|
||||
private transient String updateAuthSQL;
|
||||
private transient String updateServerIDSQL;
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
public void init() {
|
||||
//Verify
|
||||
if (mySQLHolder == null) LogHelper.error("[Verify][AuthHandler] mySQLHolder cannot be null");
|
||||
if (uuidColumn == null) LogHelper.error("[Verify][AuthHandler] uuidColumn cannot be null");
|
||||
|
@ -43,6 +43,7 @@ public void init()
|
|||
updateServerIDSQL = String.format("UPDATE %s SET %s=? WHERE %s=? LIMIT 1",
|
||||
table, serverIDColumn, uuidColumn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
mySQLHolder.close();
|
||||
|
|
|
@ -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,13 +1,13 @@
|
|||
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<? extends HWIDHandler>> HW_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
private static boolean registredHandl = false;
|
||||
|
@ -44,14 +44,12 @@ public void check(HWID hwid, String username) throws HWIDException {
|
|||
|
||||
public abstract void unban(List<HWID> hwid) throws HWIDException;
|
||||
|
||||
public static Class<? extends HWIDHandler> getHandlerClass(String name)
|
||||
{
|
||||
public static Class<? extends HWIDHandler> getHandlerClass(String name) {
|
||||
return HW_HANDLERS.get(name);
|
||||
}
|
||||
public static String getHandlerName(Class<? extends HWIDHandler> clazz)
|
||||
{
|
||||
for(Map.Entry<String,Class<? extends HWIDHandler>> e: HW_HANDLERS.entrySet())
|
||||
{
|
||||
|
||||
public static String getHandlerName(Class<? extends HWIDHandler> clazz) {
|
||||
for (Map.Entry<String, Class<? extends HWIDHandler>> e : HW_HANDLERS.entrySet()) {
|
||||
if (e.getValue().equals(clazz)) return e.getKey();
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1,19 +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.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
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,5 +1,11 @@
|
|||
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;
|
||||
|
@ -7,12 +13,6 @@
|
|||
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;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
public class ConfigPermissionsHandler extends PermissionsHandler {
|
||||
public boolean isAdmin = false;
|
||||
public boolean isServer = false;
|
||||
|
||||
@Override
|
||||
public ClientPermissions getPermissions(String username) {
|
||||
ClientPermissions permissions = new ClientPermissions();
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package ru.gravit.launchserver.auth.permissions;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import ru.gravit.launcher.ClientPermissions;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.Reloadable;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
@ -9,14 +16,6 @@
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import ru.gravit.launcher.ClientPermissions;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.Reloadable;
|
||||
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;
|
||||
|
@ -25,40 +24,38 @@ public class JsonFilePermissionsHandler extends PermissionsHandler implements Re
|
|||
public void reload() {
|
||||
map.clear();
|
||||
Path path = Paths.get(filename);
|
||||
Type type = new TypeToken<Map<String,ClientPermissions>>(){}.getType();
|
||||
try(Reader reader = IOHelper.newReader(path))
|
||||
{
|
||||
Type type = new TypeToken<Map<String, ClientPermissions>>() {
|
||||
}.getType();
|
||||
try (Reader reader = IOHelper.newReader(path)) {
|
||||
map = Launcher.gson.fromJson(reader, type);
|
||||
} catch (IOException e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Enity
|
||||
{
|
||||
public static class Enity {
|
||||
public String username;
|
||||
public ClientPermissions permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientPermissions getPermissions(String username)
|
||||
{
|
||||
public ClientPermissions getPermissions(String username) {
|
||||
return map.getOrDefault(username, ClientPermissions.DEFAULT);
|
||||
}
|
||||
|
||||
public JsonFilePermissionsHandler() {
|
||||
Type type = new TypeToken<Map<String,ClientPermissions>>(){}.getType();
|
||||
Type type = new TypeToken<Map<String, ClientPermissions>>() {
|
||||
}.getType();
|
||||
Path path = Paths.get(filename);
|
||||
if(!IOHelper.exists(path))
|
||||
{
|
||||
if (!IOHelper.exists(path)) {
|
||||
map = new HashMap<>();
|
||||
try(Writer writer = IOHelper.newWriter(path))
|
||||
{
|
||||
try (Writer writer = IOHelper.newWriter(path)) {
|
||||
Launcher.gson.toJson(map, writer);
|
||||
} catch (IOException e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}
|
||||
try(Reader reader = IOHelper.newReader(path))
|
||||
{
|
||||
try (Reader reader = IOHelper.newReader(path)) {
|
||||
map = Launcher.gson.fromJson(reader, type);
|
||||
} catch (IOException e) {
|
||||
LogHelper.error(e);
|
||||
|
|
|
@ -1,32 +1,33 @@
|
|||
package ru.gravit.launchserver.auth.permissions;
|
||||
|
||||
import ru.gravit.launcher.ClientPermissions;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ru.gravit.launcher.ClientPermissions;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public abstract class PermissionsHandler {
|
||||
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<? 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<? extends PermissionsHandler> getHandlerClass(String name)
|
||||
{
|
||||
|
||||
public static Class<? extends PermissionsHandler> getHandlerClass(String name) {
|
||||
return PERMISSIONS_HANDLERS.get(name);
|
||||
}
|
||||
public static String getHandlerName(Class<? extends PermissionsHandler> clazz)
|
||||
{
|
||||
for(Map.Entry<String,Class<? extends PermissionsHandler>> e: PERMISSIONS_HANDLERS.entrySet())
|
||||
{
|
||||
|
||||
public static String getHandlerName(Class<? extends PermissionsHandler> clazz) {
|
||||
for (Map.Entry<String, Class<? extends PermissionsHandler>> e : PERMISSIONS_HANDLERS.entrySet()) {
|
||||
if (e.getValue().equals(clazz)) return e.getKey();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerHandlers() {
|
||||
if (!registredHandl) {
|
||||
registerHandler("json", JsonFilePermissionsHandler.class);
|
||||
|
@ -35,5 +36,6 @@ public static void registerHandlers() {
|
|||
registredHandl = true;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract ClientPermissions getPermissions(String username);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public abstract class AuthProvider implements AutoCloseable {
|
||||
private static final Map<String, Class<? extends AuthProvider>> AUTH_PROVIDERS = new ConcurrentHashMap<>(8);
|
||||
private static boolean registredProv = false;
|
||||
|
@ -49,20 +49,18 @@ public AuthHandler getAccociateHandler(int this_position) {
|
|||
@Override
|
||||
public abstract void close() throws IOException;
|
||||
|
||||
public static Class<? extends AuthProvider> getProviderClass(String name)
|
||||
{
|
||||
public static Class<? extends AuthProvider> getProviderClass(String name) {
|
||||
return AUTH_PROVIDERS.get(name);
|
||||
}
|
||||
public static String getProviderName(Class<? extends AuthProvider> clazz)
|
||||
{
|
||||
for(Map.Entry<String,Class<? extends AuthProvider>> e: AUTH_PROVIDERS.entrySet())
|
||||
{
|
||||
|
||||
public static String getProviderName(Class<? extends AuthProvider> clazz) {
|
||||
for (Map.Entry<String, Class<? extends AuthProvider>> e : AUTH_PROVIDERS.entrySet()) {
|
||||
if (e.getValue().equals(clazz)) return e.getKey();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void init()
|
||||
{
|
||||
|
||||
public void init() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import ru.gravit.launcher.ClientPermissions;
|
||||
import ru.gravit.utils.HTTPRequest;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public final class JsonAuthProvider extends AuthProvider {
|
||||
private static Gson gson = new Gson();
|
||||
private URL url;
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
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,10 +1,5 @@
|
|||
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.launcher.ClientPermissions;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
|
@ -12,6 +7,11 @@
|
|||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
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;
|
||||
private String query;
|
||||
|
|
|
@ -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,12 +1,12 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ru.gravit.launchserver.Reconfigurable;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public final class RejectAuthProvider extends AuthProvider implements Reconfigurable {
|
||||
public RejectAuthProvider() {
|
||||
}
|
||||
|
@ -20,12 +20,9 @@ public RejectAuthProvider(String message) {
|
|||
|
||||
@Override
|
||||
public AuthProviderResult auth(String login, String password, String ip) throws AuthException {
|
||||
if(whitelist != null)
|
||||
{
|
||||
for(String username : whitelist)
|
||||
{
|
||||
if(login.equals(username))
|
||||
{
|
||||
if (whitelist != null) {
|
||||
for (String username : whitelist) {
|
||||
if (login.equals(username)) {
|
||||
return new AuthProviderResult(login, SecurityHelper.randomStringToken());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package ru.gravit.launchserver.auth.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import ru.gravit.launcher.ClientPermissions;
|
||||
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 java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class RequestAuthProvider extends AuthProvider {
|
||||
private String url;
|
||||
private transient Pattern pattern;
|
||||
|
@ -18,8 +18,7 @@ public final class RequestAuthProvider extends AuthProvider {
|
|||
private boolean usePermission;
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
public void init() {
|
||||
if (url == null) LogHelper.error("[Verify][AuthProvider] url cannot be null");
|
||||
if (response == null) LogHelper.error("[Verify][AuthProvider] response cannot be null");
|
||||
pattern = Pattern.compile(response);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
|
@ -8,9 +11,6 @@
|
|||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
public class BuildContext {
|
||||
public final ZipOutputStream output;
|
||||
public final JAConfigurator config;
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
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.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 net.sf.launch4j.config.*;
|
||||
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,16 +1,11 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javassist.CannotCompileException;
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtConstructor;
|
||||
import javassist.CtMethod;
|
||||
import javassist.NotFoundException;
|
||||
import javassist.*;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class JAConfigurator implements AutoCloseable {
|
||||
public ClassPool pool;
|
||||
public CtClass ctClass;
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.binary.tasks.*;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -7,18 +14,6 @@
|
|||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.binary.tasks.AttachJarsTask;
|
||||
import ru.gravit.launchserver.binary.tasks.LauncherBuildTask;
|
||||
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
|
||||
import ru.gravit.launchserver.binary.tasks.ProGuardBuildTask;
|
||||
import ru.gravit.launchserver.binary.tasks.AdditionalFixesApplyTask;
|
||||
import ru.gravit.launchserver.binary.tasks.PrepareBuildTask;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public final class JARLauncherBinary extends LauncherBinary {
|
||||
public final AtomicLong count;
|
||||
public final Path runtimeDir;
|
||||
|
@ -59,8 +54,7 @@ public void build() throws IOException {
|
|||
boolean isNeedDelete = false;
|
||||
long time_start = System.currentTimeMillis();
|
||||
long time_this = time_start;
|
||||
for(LauncherBuildTask task : tasks)
|
||||
{
|
||||
for (LauncherBuildTask task : tasks) {
|
||||
LogHelper.subInfo("Task %s", task.getName());
|
||||
Path oldPath = thisPath;
|
||||
thisPath = task.process(oldPath);
|
||||
|
|
|
@ -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;
|
||||
public Path syncBinaryFile;
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
package ru.gravit.launchserver.binary;
|
||||
|
||||
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 java.util.List;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProguardConf {
|
||||
private static final String charsFirst = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";
|
||||
private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ";
|
||||
|
@ -40,8 +36,8 @@ public ProguardConf(LaunchServer srv) {
|
|||
words = proguard.resolve("random.pro");
|
||||
this.srv = srv;
|
||||
}
|
||||
public String[] buildConfig(Path inputJar, Path outputJar)
|
||||
{
|
||||
|
||||
public String[] buildConfig(Path inputJar, Path outputJar) {
|
||||
List<String> confStrs = new ArrayList<>();
|
||||
prepare(false);
|
||||
if (srv.config.genMappings) confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'");
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
package ru.gravit.launchserver.binary.tasks;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.asm.ClassMetadataReader;
|
||||
import ru.gravit.launchserver.asm.SafeClassWriter;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
@ -8,15 +16,6 @@
|
|||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.asm.ClassMetadataReader;
|
||||
import ru.gravit.launchserver.asm.SafeClassWriter;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
public class AdditionalFixesApplyTask implements LauncherBuildTask {
|
||||
private final LaunchServer server;
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package ru.gravit.launchserver.binary.tasks;
|
||||
|
||||
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;
|
||||
import java.util.ArrayList;
|
||||
|
@ -8,10 +12,6 @@
|
|||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class AttachJarsTask implements LauncherBuildTask {
|
||||
private final LaunchServer srv;
|
||||
private final List<Path> jars;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
public interface LauncherBuildTask {
|
||||
String getName();
|
||||
|
||||
Path process(Path inputFile) throws IOException;
|
||||
|
||||
boolean allowDelete();
|
||||
}
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
package ru.gravit.launchserver.binary.tasks;
|
||||
|
||||
import static ru.gravit.utils.helper.IOHelper.newZipEntry;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import javassist.CannotCompileException;
|
||||
import javassist.NotFoundException;
|
||||
import ru.gravit.launcher.AutogenConfig;
|
||||
|
@ -30,9 +14,26 @@
|
|||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static ru.gravit.utils.helper.IOHelper.newZipEntry;
|
||||
|
||||
public class MainBuildTask implements LauncherBuildTask {
|
||||
private final LaunchServer server;
|
||||
public final ClassMetadataReader reader;
|
||||
|
||||
private final class RuntimeDirVisitor extends SimpleFileVisitor<Path> {
|
||||
private final ZipOutputStream output;
|
||||
private final Map<String, byte[]> runtime;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package ru.gravit.launchserver.binary.tasks;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import proguard.Configuration;
|
||||
import proguard.ConfigurationParser;
|
||||
import proguard.ParseException;
|
||||
|
@ -11,6 +8,9 @@
|
|||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ProGuardBuildTask implements LauncherBuildTask {
|
||||
private final LaunchServer server;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -28,8 +28,7 @@ public void invoke(String... args) {
|
|||
else newTraceValue = newValue;
|
||||
LogHelper.setDebugEnabled(newValue);
|
||||
LogHelper.setStacktraceEnabled(newTraceValue);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
newValue = LogHelper.isDebugEnabled();
|
||||
newTraceValue = LogHelper.isStacktraceEnabled();
|
||||
}
|
||||
|
|
|
@ -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,11 +1,11 @@
|
|||
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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class ProguardCleanCommand extends Command {
|
||||
public ProguardCleanCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -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 java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class RemoveMappingsProguardCommand extends Command {
|
||||
|
||||
public RemoveMappingsProguardCommand(LaunchServer server) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.gravit.launchserver.command.basic;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
@ -9,6 +7,8 @@
|
|||
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);
|
||||
|
@ -36,8 +36,7 @@ public void invoke(String... args) throws Exception {
|
|||
}
|
||||
if (args[0].equals("profile")) {
|
||||
ClientProfile profile = new ClientProfile("1.7.10", "asset1.7.10", 0, "Test1.7.10", "localhost", 25565, true, false, "net.minecraft.launchwrapper.Launch");
|
||||
try(Writer writer = IOHelper.newWriter(server.dir.resolve("profiles").resolve("Test.cfg")))
|
||||
{
|
||||
try (Writer writer = IOHelper.newWriter(server.dir.resolve("profiles").resolve("Test.cfg"))) {
|
||||
LaunchServer.gson.toJson(profile, writer);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package ru.gravit.launchserver.command.dump;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
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;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DumpEntryCacheCommand extends Command {
|
||||
public DumpEntryCacheCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
@ -30,28 +30,25 @@ public String getUsageDescription() {
|
|||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
verifyArgs(args, 2);
|
||||
if(!(server.config.authHandler instanceof CachedAuthHandler)) throw new UnsupportedOperationException("This command used only CachedAuthHandler");
|
||||
if (!(server.config.authHandler instanceof CachedAuthHandler))
|
||||
throw new UnsupportedOperationException("This command used only CachedAuthHandler");
|
||||
CachedAuthHandler authHandler = (CachedAuthHandler) server.config.authHandler;
|
||||
if(args[0].equals("unload"))
|
||||
{
|
||||
if (args[0].equals("unload")) {
|
||||
LogHelper.info("CachedAuthHandler write to %s", args[1]);
|
||||
Map<UUID, CachedAuthHandler.Entry> entryCache = authHandler.getEntryCache();
|
||||
Map<String, UUID> usernamesCache = authHandler.getUsernamesCache();
|
||||
EntryAndUsername serializable = new EntryAndUsername();
|
||||
serializable.entryCache = entryCache;
|
||||
serializable.usernameCache = usernamesCache;
|
||||
try(Writer writer = IOHelper.newWriter(Paths.get(args[1])))
|
||||
{
|
||||
try (Writer writer = IOHelper.newWriter(Paths.get(args[1]))) {
|
||||
LaunchServer.gson.toJson(serializable, writer);
|
||||
}
|
||||
LogHelper.subInfo("Write %d entryCache, %d usernameCache", entryCache.size(), usernamesCache.size());
|
||||
} else if(args[0].equals("load"))
|
||||
{
|
||||
} else if (args[0].equals("load")) {
|
||||
LogHelper.info("CachedAuthHandler read from %s", args[1]);
|
||||
int size_entry = 0;
|
||||
int size_username = 0;
|
||||
try(Reader reader = IOHelper.newReader(Paths.get(args[1])))
|
||||
{
|
||||
try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) {
|
||||
EntryAndUsername entryAndUsername = LaunchServer.gson.fromJson(reader, EntryAndUsername.class);
|
||||
size_entry = entryAndUsername.entryCache.size();
|
||||
size_username = entryAndUsername.usernameCache.size();
|
||||
|
@ -63,8 +60,7 @@ public void invoke(String... args) throws Exception {
|
|||
}
|
||||
}
|
||||
|
||||
public class EntryAndUsername
|
||||
{
|
||||
public class EntryAndUsername {
|
||||
public Map<UUID, CachedAuthHandler.Entry> entryCache;
|
||||
public Map<String, UUID> usernameCache;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package ru.gravit.launchserver.command.dump;
|
||||
|
||||
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;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -7,14 +14,6 @@
|
|||
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);
|
||||
|
@ -33,22 +32,19 @@ public String getUsageDescription() {
|
|||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
verifyArgs(args, 2);
|
||||
if(args[0].equals("unload"))
|
||||
{
|
||||
if (args[0].equals("unload")) {
|
||||
LogHelper.info("Sessions write to %s", args[1]);
|
||||
Set<Client> clientSet = server.sessionManager.getSessions();
|
||||
try(Writer writer = IOHelper.newWriter(Paths.get(args[1])))
|
||||
{
|
||||
try (Writer writer = IOHelper.newWriter(Paths.get(args[1]))) {
|
||||
LaunchServer.gson.toJson(clientSet, writer);
|
||||
}
|
||||
LogHelper.subInfo("Write %d sessions", clientSet.size());
|
||||
} else if(args[0].equals("load"))
|
||||
{
|
||||
} else if (args[0].equals("load")) {
|
||||
LogHelper.info("Sessions read from %s", args[1]);
|
||||
int size = 0;
|
||||
try(Reader reader = IOHelper.newReader(Paths.get(args[1])))
|
||||
{
|
||||
Type setType = new TypeToken<HashSet<Client>>(){}.getType();
|
||||
try (Reader reader = IOHelper.newReader(Paths.get(args[1]))) {
|
||||
Type setType = new TypeToken<HashSet<Client>>() {
|
||||
}.getType();
|
||||
Set<Client> clientSet = LaunchServer.gson.fromJson(reader, setType);
|
||||
size = clientSet.size();
|
||||
server.sessionManager.loadSessions(clientSet);
|
||||
|
|
|
@ -1,53 +1,25 @@
|
|||
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.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.RestartCommand;
|
||||
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.auth.*;
|
||||
import ru.gravit.launchserver.command.basic.*;
|
||||
import ru.gravit.launchserver.command.dump.DumpEntryCacheCommand;
|
||||
import ru.gravit.launchserver.command.dump.DumpSessionsCommand;
|
||||
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.hash.*;
|
||||
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 java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class StdCommandHandler extends CommandHandler {
|
||||
private final BufferedReader reader;
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
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;
|
||||
|
@ -11,6 +7,10 @@
|
|||
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,12 +1,5 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
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;
|
||||
|
@ -16,6 +9,13 @@
|
|||
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,5 +1,15 @@
|
|||
package ru.gravit.launchserver.command.hash;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
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;
|
||||
|
@ -9,17 +19,6 @@
|
|||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
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,21 +1,20 @@
|
|||
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 java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class LoadModuleCommand extends Command {
|
||||
public LoadModuleCommand(LaunchServer server) {
|
||||
super(server);
|
||||
|
|
|
@ -33,8 +33,7 @@ public void invoke(String... args) {
|
|||
LogHelper.info("Uptime: %d days %d hours %d minutes %d seconds", days, hour, min, second);
|
||||
LogHelper.info("Uptime (double): %f", (double) JVMHelper.RUNTIME_MXBEAN.getUptime() / 1000);
|
||||
LogHelper.info("Sessions: %d | Modules: %d | Commands: %d", server.sessionManager.getSessions().size(), server.modulesManager.modules.size(), server.commandHandler.commandsMap().size());
|
||||
if(server.config.authHandler instanceof CachedAuthHandler)
|
||||
{
|
||||
if (server.config.authHandler instanceof CachedAuthHandler) {
|
||||
LogHelper.info("AuthHandler: EntryCache: %d | usernameCache: %d", ((CachedAuthHandler) server.config.authHandler).getEntryCache().size(), ((CachedAuthHandler) server.config.authHandler).getUsernamesCache().size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
public class SwapAuthProviderCommand extends Command {
|
||||
public AuthProvider[] providersCache;
|
||||
|
||||
public SwapAuthProviderCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
import ru.gravit.launchserver.auth.handler.AuthHandler;
|
||||
|
||||
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();
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProvider;
|
||||
|
||||
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();
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
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();
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
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();
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
package ru.gravit.launchserver.config;
|
||||
|
||||
import com.google.gson.*;
|
||||
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();
|
||||
|
|
|
@ -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,16 +1,14 @@
|
|||
package ru.gravit.launchserver.fileserver;
|
||||
|
||||
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 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 javax.activation.MimetypesFileTypeMap;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
@ -18,38 +16,12 @@
|
|||
import java.net.URLDecoder;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
public class FileServerHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
|
||||
|
|
|
@ -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,8 +1,5 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ru.gravit.launcher.managers.ModulesConfigManager;
|
||||
import ru.gravit.launcher.managers.SimpleModuleManager;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
|
@ -10,8 +7,12 @@
|
|||
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 ModulesConfigManager configManager;
|
||||
|
||||
public ModulesManager(LaunchServer lsrv) {
|
||||
modules = new ArrayList<>(1);
|
||||
configManager = new ModulesConfigManager(lsrv.dir.resolve("config"));
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import ru.gravit.launchserver.Reconfigurable;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ReconfigurableManager {
|
||||
private final HashMap<String, Reconfigurable> RECONFIGURABLE = new HashMap<>();
|
||||
public void registerReconfigurable(String name, Reconfigurable reconfigurable)
|
||||
{
|
||||
|
||||
public void registerReconfigurable(String name, Reconfigurable reconfigurable) {
|
||||
VerifyHelper.verifyIDName(name);
|
||||
VerifyHelper.putIfAbsent(RECONFIGURABLE, name, Objects.requireNonNull(reconfigurable, "adapter"),
|
||||
String.format("Reloadable has been already registered: '%s'", name));
|
||||
}
|
||||
public void printHelp(String name)
|
||||
{
|
||||
|
||||
public void printHelp(String name) {
|
||||
RECONFIGURABLE.get(name).printConfigHelp();
|
||||
}
|
||||
|
||||
public void call(String name, String action, String[] args) {
|
||||
RECONFIGURABLE.get(name).reconfig(action, args);
|
||||
}
|
||||
public void printReconfigurables()
|
||||
{
|
||||
|
||||
public void printReconfigurables() {
|
||||
LogHelper.info("Print reconfigurables");
|
||||
RECONFIGURABLE.forEach((k, v) -> LogHelper.subInfo(k));
|
||||
LogHelper.info("Found %d reconfigurables", RECONFIGURABLE.size());
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
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)
|
||||
{
|
||||
|
||||
public void registerReloadable(String name, Reloadable reloadable) {
|
||||
VerifyHelper.verifyIDName(name);
|
||||
VerifyHelper.putIfAbsent(RELOADABLES, name, Objects.requireNonNull(reloadable, "adapter"),
|
||||
String.format("Reloadable has been already registered: '%s'", name));
|
||||
}
|
||||
public void reloadAll()
|
||||
{
|
||||
|
||||
public void reloadAll() {
|
||||
RELOADABLES.forEach((k, v) -> {
|
||||
try {
|
||||
v.reload();
|
||||
|
@ -25,11 +25,12 @@ public void reloadAll()
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reload(String name) throws Exception {
|
||||
RELOADABLES.get(name).reload();
|
||||
}
|
||||
public void printReloadables()
|
||||
{
|
||||
|
||||
public void printReloadables() {
|
||||
LogHelper.info("Print reloadables");
|
||||
RELOADABLES.forEach((k, v) -> LogHelper.subInfo(k));
|
||||
LogHelper.info("Found %d reloadables", RELOADABLES.size());
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SessionManager implements NeedGarbageCollection {
|
||||
|
||||
public static final long SESSION_TIMEOUT = 10 * 60 * 1000; // 10 минут
|
||||
|
@ -51,12 +51,12 @@ public void updateClient(long session) {
|
|||
Client newClient = new Client(session);
|
||||
clientSet.add(newClient);
|
||||
}
|
||||
public Set<Client> getSessions()
|
||||
{
|
||||
|
||||
public Set<Client> getSessions() {
|
||||
return clientSet;
|
||||
}
|
||||
public void loadSessions(Set<Client> set)
|
||||
{
|
||||
|
||||
public void loadSessions(Set<Client> set) {
|
||||
clientSet.addAll(set);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,77 +1,73 @@
|
|||
package ru.gravit.launchserver.manangers.hook;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import ru.gravit.launchserver.response.auth.AuthResponse;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class AuthHookManager {
|
||||
private Set<AuthPreHook> PRE_HOOKS = new HashSet<>();
|
||||
private Set<AuthPostHook> POST_HOOKS = new HashSet<>();
|
||||
private Set<CheckServerHook> CHECKSERVER_HOOKS = new HashSet<>();
|
||||
private Set<JoinServerHook> JOINSERVER_HOOKS = new HashSet<>();
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AuthPreHook
|
||||
{
|
||||
public interface AuthPreHook {
|
||||
void preAuthHook(AuthResponse.AuthContext context, Client client);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AuthPostHook
|
||||
{
|
||||
public interface AuthPostHook {
|
||||
void postAuthHook(AuthResponse.AuthContext context, Client client);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface CheckServerHook
|
||||
{
|
||||
public interface CheckServerHook {
|
||||
void checkServerHook(String username, String serverID);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface JoinServerHook
|
||||
{
|
||||
public interface JoinServerHook {
|
||||
void joinServerHook(String username, String accessToken, String serverID);
|
||||
}
|
||||
public void registerPostHook(AuthPostHook hook)
|
||||
{
|
||||
|
||||
public void registerPostHook(AuthPostHook hook) {
|
||||
POST_HOOKS.add(hook);
|
||||
}
|
||||
public void registerJoinServerHook(JoinServerHook hook)
|
||||
{
|
||||
|
||||
public void registerJoinServerHook(JoinServerHook hook) {
|
||||
JOINSERVER_HOOKS.add(hook);
|
||||
}
|
||||
public void registerCheckServerHook(CheckServerHook hook)
|
||||
{
|
||||
|
||||
public void registerCheckServerHook(CheckServerHook hook) {
|
||||
CHECKSERVER_HOOKS.add(hook);
|
||||
}
|
||||
public void registerPreHook(AuthPreHook hook)
|
||||
{
|
||||
|
||||
public void registerPreHook(AuthPreHook hook) {
|
||||
PRE_HOOKS.add(hook);
|
||||
}
|
||||
public void preHook(AuthResponse.AuthContext context, Client client)
|
||||
{
|
||||
for(AuthPreHook preHook : PRE_HOOKS)
|
||||
{
|
||||
|
||||
public void preHook(AuthResponse.AuthContext context, Client client) {
|
||||
for (AuthPreHook preHook : PRE_HOOKS) {
|
||||
preHook.preAuthHook(context, client);
|
||||
}
|
||||
}
|
||||
public void checkServerHook(String username, String serverID)
|
||||
{
|
||||
for(CheckServerHook hook : CHECKSERVER_HOOKS)
|
||||
{
|
||||
|
||||
public void checkServerHook(String username, String serverID) {
|
||||
for (CheckServerHook hook : CHECKSERVER_HOOKS) {
|
||||
hook.checkServerHook(username, serverID);
|
||||
}
|
||||
}
|
||||
public void joinServerHook(String username, String accessToken, String serverID)
|
||||
{
|
||||
for(JoinServerHook hook : JOINSERVER_HOOKS)
|
||||
{
|
||||
|
||||
public void joinServerHook(String username, String accessToken, String serverID) {
|
||||
for (JoinServerHook hook : JOINSERVER_HOOKS) {
|
||||
hook.joinServerHook(username, accessToken, serverID);
|
||||
}
|
||||
}
|
||||
public void postHook(AuthResponse.AuthContext context, Client client)
|
||||
{
|
||||
for(AuthPostHook postHook : POST_HOOKS)
|
||||
{
|
||||
|
||||
public void postHook(AuthResponse.AuthContext context, Client client) {
|
||||
for (AuthPostHook postHook : POST_HOOKS) {
|
||||
postHook.postAuthHook(context, client);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package ru.gravit.launchserver.manangers.hook;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
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.tasks.MainBuildTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class BuildHookManager {
|
||||
|
||||
@FunctionalInterface
|
||||
|
|
|
@ -1,88 +1,84 @@
|
|||
package ru.gravit.launchserver.manangers.hook;
|
||||
|
||||
import ru.gravit.launcher.request.RequestException;
|
||||
import ru.gravit.launchserver.socket.SocketContext;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import ru.gravit.launcher.request.RequestException;
|
||||
import ru.gravit.launchserver.socket.SocketContext;
|
||||
|
||||
public class SocketHookManager {
|
||||
@FunctionalInterface
|
||||
public interface SocketPreHook
|
||||
{
|
||||
public interface SocketPreHook {
|
||||
boolean preHook(SocketContext context); //Вернуть true если необходимо продолжть обработку, false если остановить обработку
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SocketPostHook
|
||||
{
|
||||
public interface SocketPostHook {
|
||||
void postHook(SocketContext context);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SocketErrorHook
|
||||
{
|
||||
public interface SocketErrorHook {
|
||||
boolean errorHook(SocketContext context, RequestException e); //Вернуть true если необходимо продолжть обработку, false если остановить обработку
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SocketFatalErrorHook
|
||||
{
|
||||
public interface SocketFatalErrorHook {
|
||||
boolean fatalErrorHook(Socket socket, Exception e); //Вернуть true если необходимо продолжть обработку, false если остановить обработку
|
||||
}
|
||||
|
||||
private Set<SocketPostHook> POST_HOOKS;
|
||||
private Set<SocketPreHook> PRE_HOOKS;
|
||||
private Set<SocketErrorHook> ERROR_HOOKS;
|
||||
private Set<SocketFatalErrorHook> FATALERROR_HOOKS;
|
||||
public void registerPostHook(SocketPostHook hook)
|
||||
{
|
||||
|
||||
public void registerPostHook(SocketPostHook hook) {
|
||||
if (POST_HOOKS == null) POST_HOOKS = new HashSet<>();
|
||||
POST_HOOKS.add(hook);
|
||||
}
|
||||
public void registerPreHook(SocketPreHook hook)
|
||||
{
|
||||
|
||||
public void registerPreHook(SocketPreHook hook) {
|
||||
if (PRE_HOOKS == null) PRE_HOOKS = new HashSet<>();
|
||||
PRE_HOOKS.add(hook);
|
||||
}
|
||||
public void registerErrorHook(SocketErrorHook hook)
|
||||
{
|
||||
|
||||
public void registerErrorHook(SocketErrorHook hook) {
|
||||
if (ERROR_HOOKS == null) ERROR_HOOKS = new HashSet<>();
|
||||
ERROR_HOOKS.add(hook);
|
||||
}
|
||||
public void registerFatalErrorHook(SocketFatalErrorHook hook)
|
||||
{
|
||||
|
||||
public void registerFatalErrorHook(SocketFatalErrorHook hook) {
|
||||
if (FATALERROR_HOOKS == null) FATALERROR_HOOKS = new HashSet<>();
|
||||
FATALERROR_HOOKS.add(hook);
|
||||
}
|
||||
public boolean preHook(SocketContext context)
|
||||
{
|
||||
|
||||
public boolean preHook(SocketContext context) {
|
||||
if (PRE_HOOKS == null) return true;
|
||||
for(SocketPreHook preHook : PRE_HOOKS)
|
||||
{
|
||||
for (SocketPreHook preHook : PRE_HOOKS) {
|
||||
if (!preHook.preHook(context)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void postHook(SocketContext context)
|
||||
{
|
||||
|
||||
public void postHook(SocketContext context) {
|
||||
if (POST_HOOKS == null) return;
|
||||
for(SocketPostHook postHook : POST_HOOKS)
|
||||
{
|
||||
for (SocketPostHook postHook : POST_HOOKS) {
|
||||
postHook.postHook(context);
|
||||
}
|
||||
}
|
||||
public boolean errorHook(SocketContext context, RequestException e)
|
||||
{
|
||||
|
||||
public boolean errorHook(SocketContext context, RequestException e) {
|
||||
if (ERROR_HOOKS == null) return true;
|
||||
for(SocketErrorHook errorHook : ERROR_HOOKS)
|
||||
{
|
||||
for (SocketErrorHook errorHook : ERROR_HOOKS) {
|
||||
if (!errorHook.errorHook(context, e)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean fatalErrorHook(Socket socket, Exception e)
|
||||
{
|
||||
|
||||
public boolean fatalErrorHook(Socket socket, Exception e) {
|
||||
if (FATALERROR_HOOKS == null) return true;
|
||||
for(SocketFatalErrorHook errorHook : FATALERROR_HOOKS)
|
||||
{
|
||||
for (SocketFatalErrorHook errorHook : FATALERROR_HOOKS) {
|
||||
if (!errorHook.fatalErrorHook(socket, e)) return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -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,31 +1,22 @@
|
|||
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.admin.ExecCommandResponse;
|
||||
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.auth.*;
|
||||
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.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.launchserver.response.update.*;
|
||||
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> {
|
||||
|
|
|
@ -18,7 +18,8 @@ public ExecCommandResponse(LaunchServer server, long session, HInput input, HOut
|
|||
@Override
|
||||
public void reply() throws Exception {
|
||||
Client clientData = server.sessionManager.getClient(session);
|
||||
if(!clientData.isAuth || !clientData.permissions.canAdmin || !server.config.enableRcon) requestError("Access denied");
|
||||
if (!clientData.isAuth || !clientData.permissions.canAdmin || !server.config.enableRcon)
|
||||
requestError("Access denied");
|
||||
writeNoError(output);
|
||||
String cmd = input.readString(SerializeLimits.MAX_COMMAND);
|
||||
LogHelper.Output loutput = message -> {
|
||||
|
@ -30,8 +31,7 @@ public void reply() throws Exception {
|
|||
}
|
||||
};
|
||||
LogHelper.addOutput(loutput);
|
||||
try
|
||||
{
|
||||
try {
|
||||
server.commandHandler.eval(cmd, false);
|
||||
output.writeBoolean(false);
|
||||
} finally {
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
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;
|
||||
|
@ -25,6 +18,12 @@
|
|||
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];
|
||||
|
@ -35,8 +34,8 @@ private static String echo(int length) {
|
|||
public AuthResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) {
|
||||
super(server, session, input, output, ip);
|
||||
}
|
||||
public static class AuthContext
|
||||
{
|
||||
|
||||
public static class AuthContext {
|
||||
public AuthContext(long session, String login, int password_lenght, String client, String hwid, boolean isServerAuth) {
|
||||
this.session = session;
|
||||
this.login = login;
|
||||
|
@ -53,6 +52,7 @@ public AuthContext(long session, String login, int password_lenght, String clien
|
|||
public String hwid;
|
||||
public boolean isServerAuth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reply() throws Exception {
|
||||
String login = input.readString(SerializeLimits.MAX_LOGIN);
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
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;
|
||||
|
@ -22,6 +16,11 @@
|
|||
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];
|
||||
|
@ -74,8 +73,7 @@ public void reply() throws Exception {
|
|||
throw new AuthException("Your profile is not found");
|
||||
}
|
||||
clientData.permissions = server.config.permissionsHandler.getPermissions(login);
|
||||
if(!clientData.permissions.canServer)
|
||||
{
|
||||
if (!clientData.permissions.canServer) {
|
||||
throw new AuthException("Your account cannot be a server");
|
||||
}
|
||||
clientData.type = Client.Type.SERVER;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
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;
|
||||
|
@ -14,6 +11,9 @@
|
|||
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) {
|
||||
|
@ -27,8 +27,7 @@ public void reply() throws IOException {
|
|||
String client = input.readString(SerializeLimits.MAX_CLIENT);
|
||||
debug("Username: %s, Server ID: %s", username, serverID);
|
||||
Client clientData = server.sessionManager.getClient(session);
|
||||
if(!clientData.isAuth || clientData.type != Client.Type.SERVER)
|
||||
{
|
||||
if (!clientData.isAuth || clientData.type != Client.Type.SERVER) {
|
||||
requestError("Assess denied");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
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;
|
||||
|
@ -13,6 +11,8 @@
|
|||
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) {
|
||||
|
@ -25,8 +25,7 @@ public void reply() throws IOException {
|
|||
String accessToken = SecurityHelper.verifyToken(input.readASCII(-SecurityHelper.TOKEN_STRING_LENGTH));
|
||||
String serverID = VerifyHelper.verifyServerID(input.readASCII(SerializeLimits.MAX_SERVERID)); // With minus sign
|
||||
Client clientData = server.sessionManager.getClient(session);
|
||||
if(!clientData.isAuth || clientData.type != Client.Type.USER)
|
||||
{
|
||||
if (!clientData.isAuth || clientData.type != Client.Type.USER) {
|
||||
requestError("Assess denied");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
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;
|
||||
|
@ -10,6 +8,8 @@
|
|||
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,8 +1,5 @@
|
|||
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;
|
||||
|
@ -10,6 +7,9 @@
|
|||
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,8 +1,5 @@
|
|||
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;
|
||||
|
@ -12,6 +9,9 @@
|
|||
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,8 +1,5 @@
|
|||
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;
|
||||
|
@ -10,6 +7,9 @@
|
|||
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,8 +1,5 @@
|
|||
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.SerializeLimits;
|
||||
|
@ -11,6 +8,9 @@
|
|||
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,7 +1,5 @@
|
|||
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;
|
||||
|
@ -9,6 +7,8 @@
|
|||
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,8 +1,5 @@
|
|||
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;
|
||||
|
@ -12,6 +9,9 @@
|
|||
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,8 +1,5 @@
|
|||
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;
|
||||
|
@ -10,6 +7,9 @@
|
|||
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,13 +1,5 @@
|
|||
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;
|
||||
|
@ -22,6 +14,14 @@
|
|||
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) {
|
||||
|
@ -42,8 +42,7 @@ public void reply() throws IOException {
|
|||
requestError("Assess denied");
|
||||
return;
|
||||
}
|
||||
if(!clientData.permissions.canAdmin)
|
||||
{
|
||||
if (!clientData.permissions.canAdmin) {
|
||||
for (ClientProfile p : server.getProfiles()) {
|
||||
if (!clientData.profile.getTitle().equals(p.getTitle())) continue;
|
||||
if (!p.isWhitelistContains(clientData.username)) {
|
||||
|
|
|
@ -1,34 +1,5 @@
|
|||
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;
|
||||
|
@ -53,6 +24,29 @@
|
|||
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";
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue