Merge branch 'release/5.0.3'

This commit is contained in:
Gravit 2019-06-07 13:17:14 +07:00
commit 1e2d3ba1bd
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
389 changed files with 3515 additions and 2241 deletions

View file

@ -1,5 +1,5 @@
def mainClassName = "ru.gravit.launchserver.LaunchServer"
def mainAgentName = "ru.gravit.launchserver.StarterAgent"
def mainClassName = "pro.gravit.launchserver.LaunchServer"
def mainAgentName = "pro.gravit.launchserver.StarterAgent"
evaluationDependsOn(':Launcher')
@ -53,6 +53,7 @@ bundle project(':Radon')
bundle 'commons-codec:commons-codec:1.12'
bundle 'org.javassist:javassist:3.25.0-GA'
bundle 'io.netty:netty-all:4.1.36.Final'
bundle 'org.hibernate:hibernate-core:5.4.3.Final'
bundle 'org.slf4j:slf4j-simple:1.7.25'
bundle 'org.slf4j:slf4j-api:1.7.25'

View file

@ -1,62 +1,95 @@
package ru.gravit.launchserver;
package pro.gravit.launchserver;
import io.netty.handler.logging.LogLevel;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launcher.NeedGarbageCollection;
import ru.gravit.launcher.config.JsonConfigurable;
import ru.gravit.launcher.hasher.HashedDir;
import ru.gravit.launcher.managers.ConfigManager;
import ru.gravit.launcher.managers.GarbageManager;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
import ru.gravit.launchserver.auth.AuthProviderPair;
import ru.gravit.launchserver.auth.handler.AuthHandler;
import ru.gravit.launchserver.auth.handler.MemoryAuthHandler;
import ru.gravit.launchserver.auth.hwid.AcceptHWIDHandler;
import ru.gravit.launchserver.auth.hwid.HWIDHandler;
import ru.gravit.launchserver.auth.permissions.DefaultPermissionsHandler;
import ru.gravit.launchserver.auth.permissions.JsonFilePermissionsHandler;
import ru.gravit.launchserver.auth.permissions.PermissionsHandler;
import ru.gravit.launchserver.auth.protect.NoProtectHandler;
import ru.gravit.launchserver.auth.protect.ProtectHandler;
import ru.gravit.launchserver.auth.provider.AuthProvider;
import ru.gravit.launchserver.auth.provider.RejectAuthProvider;
import ru.gravit.launchserver.auth.texture.RequestTextureProvider;
import ru.gravit.launchserver.auth.texture.TextureProvider;
import ru.gravit.launchserver.binary.*;
import ru.gravit.launchserver.components.AuthLimiterComponent;
import ru.gravit.launchserver.components.Component;
import ru.gravit.launchserver.config.LaunchServerRuntimeConfig;
import ru.gravit.launchserver.legacy.Response;
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;
import ru.gravit.launchserver.socket.ServerSocketHandler;
import ru.gravit.launchserver.websocket.NettyServerSocketHandler;
import ru.gravit.utils.Version;
import ru.gravit.utils.command.CommandHandler;
import ru.gravit.utils.command.JLineCommandHandler;
import ru.gravit.utils.command.StdCommandHandler;
import ru.gravit.utils.helper.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.lang.ProcessBuilder.Redirect;
import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.file.*;
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.util.*;
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.Timer;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.CRC32;
import io.netty.handler.logging.LogLevel;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherConfig;
import pro.gravit.launcher.NeedGarbageCollection;
import pro.gravit.launcher.config.JsonConfigurable;
import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.launcher.managers.ConfigManager;
import pro.gravit.launcher.managers.GarbageManager;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launcher.serialize.signed.SignedObjectHolder;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.auth.handler.AuthHandler;
import pro.gravit.launchserver.auth.handler.MemoryAuthHandler;
import pro.gravit.launchserver.auth.hwid.AcceptHWIDHandler;
import pro.gravit.launchserver.auth.hwid.HWIDHandler;
import pro.gravit.launchserver.auth.permissions.DefaultPermissionsHandler;
import pro.gravit.launchserver.auth.permissions.JsonFilePermissionsHandler;
import pro.gravit.launchserver.auth.permissions.PermissionsHandler;
import pro.gravit.launchserver.auth.protect.ProtectHandler;
import pro.gravit.launchserver.auth.protect.StdProtectHandler;
import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.provider.RejectAuthProvider;
import pro.gravit.launchserver.auth.texture.RequestTextureProvider;
import pro.gravit.launchserver.auth.texture.TextureProvider;
import pro.gravit.launchserver.binary.EXEL4JLauncherBinary;
import pro.gravit.launchserver.binary.EXELauncherBinary;
import pro.gravit.launchserver.binary.JARLauncherBinary;
import pro.gravit.launchserver.binary.LauncherBinary;
import pro.gravit.launchserver.binary.ProguardConf;
import pro.gravit.launchserver.components.AuthLimiterComponent;
import pro.gravit.launchserver.components.Component;
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
import pro.gravit.launchserver.dao.UserService;
import pro.gravit.launchserver.legacy.Response;
import pro.gravit.launchserver.manangers.LaunchServerGsonManager;
import pro.gravit.launchserver.manangers.MirrorManager;
import pro.gravit.launchserver.manangers.ModulesManager;
import pro.gravit.launchserver.manangers.ReconfigurableManager;
import pro.gravit.launchserver.manangers.ReloadManager;
import pro.gravit.launchserver.manangers.SessionManager;
import pro.gravit.launchserver.manangers.hook.AuthHookManager;
import pro.gravit.launchserver.manangers.hook.BuildHookManager;
import pro.gravit.launchserver.manangers.hook.SocketHookManager;
import pro.gravit.launchserver.socket.ServerSocketHandler;
import pro.gravit.launchserver.websocket.NettyServerSocketHandler;
import pro.gravit.utils.Version;
import pro.gravit.utils.command.CommandHandler;
import pro.gravit.utils.command.JLineCommandHandler;
import pro.gravit.utils.command.StdCommandHandler;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.VerifyHelper;
public final class LaunchServer implements Runnable, AutoCloseable, Reloadable {
@Override
public void reload() throws Exception {
@ -65,11 +98,13 @@ public void reload() throws Exception {
try (BufferedReader reader = IOHelper.newReader(configFile)) {
config = Launcher.gsonManager.gson.fromJson(reader, Config.class);
}
config.server = this;
config.verify();
config.init();
}
public static final class Config {
private transient LaunchServer server = null;
public int legacyPort;
private String legacyAddress;
@ -204,30 +239,30 @@ public void verify() {
public void init() {
Launcher.applyLauncherEnv(env);
for (AuthProviderPair provider : auth) {
provider.init();
provider.init(server);
}
permissionsHandler.init();
permissionsHandler.init(server);
hwidHandler.init();
if (protectHandler != null) {
protectHandler.checkLaunchServerLicense();
}
LaunchServer.server.registerObject("permissionsHandler", permissionsHandler);
server.registerObject("permissionsHandler", permissionsHandler);
for (AuthProviderPair pair : auth) {
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
}
Arrays.stream(mirrors).forEach(LaunchServer.server.mirrorManager::addMirror);
Arrays.stream(mirrors).forEach(server.mirrorManager::addMirror);
}
public void close() {
try {
LaunchServer.server.unregisterObject("permissionsHandler", permissionsHandler);
server.unregisterObject("permissionsHandler", permissionsHandler);
for (AuthProviderPair pair : auth) {
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
}
} catch (Exception e) {
LogHelper.error(e);
@ -394,7 +429,7 @@ public static void main(String... args) throws Throwable {
public final Path updatesDir;
public static LaunchServer server = null;
//public static LaunchServer server = null;
public final Path profilesDir;
// Server config
@ -424,6 +459,8 @@ public static void main(String... args) throws Throwable {
public final ModulesManager modulesManager;
public final UserService userService;
public final MirrorManager mirrorManager;
public final ReloadManager reloadManager;
@ -477,7 +514,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
Response.registerResponses();
Component.registerComponents();
ProtectHandler.registerHandlers();
LaunchServer.server = this;
//LaunchServer.server = this;
// Set command handler
CommandHandler localCommandHandler;
@ -494,7 +531,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
localCommandHandler = new StdCommandHandler(true);
LogHelper.warning("JLine2 isn't in classpath, using std");
}
ru.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler);
pro.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler, this);
commandHandler = localCommandHandler;
// Set key pair
@ -536,6 +573,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
try (BufferedReader reader = IOHelper.newReader(configFile)) {
config = Launcher.gsonManager.gson.fromJson(reader, Config.class);
}
config.server = this;
if (!Files.exists(runtimeConfigFile)) {
LogHelper.info("Reset LaunchServer runtime config file");
runtime = new LaunchServerRuntimeConfig();
@ -550,9 +588,9 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
config.verify();
Launcher.applyLauncherEnv(config.env);
for (AuthProviderPair provider : config.auth) {
provider.init();
provider.init(this);
}
config.permissionsHandler.init();
config.permissionsHandler.init(this);
config.hwidHandler.init();
if (config.protectHandler != null) {
config.protectHandler.checkLaunchServerLicense();
@ -576,6 +614,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
socketHookManager = new SocketHookManager();
authHookManager = new AuthHookManager();
configManager = new ConfigManager();
userService = new UserService(this);
GarbageManager.registerNeedGC(sessionManager);
reloadManager.registerReloadable("launchServer", this);
registerObject("permissionsHandler", config.permissionsHandler);
@ -716,7 +755,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
new RequestTextureProvider("http://example.com/skins/%username%.png", "http://example.com/cloaks/%username%.png")
, "std")};
newConfig.auth[0].displayName = "Default";
newConfig.protectHandler = new NoProtectHandler();
newConfig.protectHandler = new StdProtectHandler();
if (testEnv) newConfig.permissionsHandler = new DefaultPermissionsHandler();
else newConfig.permissionsHandler = new JsonFilePermissionsHandler();
newConfig.legacyPort = 7240;

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver;
package pro.gravit.launchserver;
public interface Reconfigurable {
void reconfig(String action, String[] args);

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver;
package pro.gravit.launchserver;
@FunctionalInterface
public interface Reloadable {

View file

@ -1,8 +1,13 @@
package ru.gravit.launchserver;
package pro.gravit.launchserver;
import java.io.IOException;
import java.lang.instrument.Instrumentation;
import java.nio.file.*;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;

View file

@ -1,9 +1,4 @@
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;
package pro.gravit.launchserver.asm;
import java.io.Closeable;
import java.io.IOException;
@ -13,6 +8,12 @@
import java.util.List;
import java.util.jar.JarFile;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
import pro.gravit.utils.helper.IOHelper;
/**
* Позволяет искать методы внутри незагруженных классов и общие суперклассы для
* чего угодно. Работает через поиск class-файлов в classpath.

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.asm;
package pro.gravit.launchserver.asm;
import java.util.ArrayList;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import java.util.ArrayList;
/**
* ClassWriter с другой реализацией метода getCommonSuperClass: при его
* использовании не происходит загрузки классов.

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver.auth;
package pro.gravit.launchserver.auth;
import java.io.IOException;

View file

@ -1,11 +1,12 @@
package ru.gravit.launchserver.auth;
import ru.gravit.launchserver.auth.handler.AuthHandler;
import ru.gravit.launchserver.auth.provider.AuthProvider;
import ru.gravit.launchserver.auth.texture.TextureProvider;
package pro.gravit.launchserver.auth;
import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.handler.AuthHandler;
import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.texture.TextureProvider;
public class AuthProviderPair {
public AuthProvider provider;
public AuthHandler handler;
@ -21,9 +22,9 @@ public AuthProviderPair(AuthProvider provider, AuthHandler handler, TextureProvi
this.name = name;
}
public void init() {
provider.init();
handler.init();
public void init(LaunchServer srv) {
provider.init(srv);
handler.init(srv);
}
public void close() throws IOException {

View file

@ -1,14 +1,16 @@
package ru.gravit.launchserver.auth;
package pro.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;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.VerifyHelper;
public final class MySQLSourceConfig implements AutoCloseable {

View file

@ -1,12 +1,14 @@
package ru.gravit.launchserver.auth.handler;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
import ru.gravit.utils.ProviderMap;
package pro.gravit.launchserver.auth.handler;
import java.io.IOException;
import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.utils.ProviderMap;
public abstract class AuthHandler implements AutoCloseable {
public static ProviderMap<AuthHandler> providers = new ProviderMap<>("AuthHandler");
private static boolean registredHandl = false;
@ -23,10 +25,13 @@ public static void registerHandlers() {
providers.register("memory", MemoryAuthHandler.class);
providers.register("mysql", MySQLAuthHandler.class);
providers.register("request", RequestAuthHandler.class);
providers.register("hibernate", HibernateAuthHandler.class);
registredHandl = true;
}
}
protected transient LaunchServer srv;
public abstract UUID auth(AuthProviderResult authResult) throws IOException;
public abstract UUID checkServer(String username, String serverID) throws IOException;
@ -43,7 +48,7 @@ public static void registerHandlers() {
public abstract String uuidToUsername(UUID uuid) throws IOException;
public void init() {
public void init(LaunchServer srv) {
this.srv = srv;
}
}

View file

@ -1,10 +1,4 @@
package ru.gravit.launchserver.auth.handler;
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;
package pro.gravit.launchserver.auth.handler;
import java.io.IOException;
import java.util.HashMap;
@ -12,6 +6,12 @@
import java.util.Objects;
import java.util.UUID;
import pro.gravit.launcher.NeedGarbageCollection;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.VerifyHelper;
public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection {
public static final class Entry {

View file

@ -0,0 +1,43 @@
package pro.gravit.launchserver.auth.handler;
import java.io.IOException;
import java.util.UUID;
import pro.gravit.launchserver.dao.User;
public class HibernateAuthHandler extends CachedAuthHandler {
@Override
protected Entry fetchEntry(String username) throws IOException {
User user = srv.userService.findUserByUsername(username);
if(user == null) return null;
return new Entry(user.uuid, username, user.getAccessToken(), user.serverID);
}
@Override
protected Entry fetchEntry(UUID uuid) throws IOException {
User user = srv.userService.findUserByUUID(uuid);
if(user == null) return null;
return new Entry(user.uuid, user.username, user.getAccessToken(), user.serverID);
}
@Override
protected boolean updateAuth(UUID uuid, String username, String accessToken) throws IOException {
User user = srv.userService.findUserByUUID(uuid);
user.setAccessToken(accessToken);
srv.userService.updateUser(user);
return true;
}
@Override
protected boolean updateServerID(UUID uuid, String serverID) throws IOException {
User user = srv.userService.findUserByUUID(uuid);
user.serverID = serverID;
srv.userService.updateUser(user);
return true;
}
@Override
public void close() throws IOException {
}
}

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.handler;
import ru.gravit.launcher.Launcher;
import ru.gravit.utils.HTTPRequest;
package pro.gravit.launchserver.auth.handler;
import java.io.IOException;
import java.net.URL;
import java.util.UUID;
import pro.gravit.launcher.Launcher;
import pro.gravit.utils.HTTPRequest;
public class JsonAuthHandler extends CachedAuthHandler {
public URL getUrl;
public URL updateAuthUrl;

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.handler;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.VerifyHelper;
package pro.gravit.launchserver.auth.handler;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.UUID;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.VerifyHelper;
public final class MemoryAuthHandler extends CachedAuthHandler {
private static String toUsername(UUID uuid) {
byte[] bytes = ByteBuffer.allocate(16).

View file

@ -1,7 +1,4 @@
package ru.gravit.launchserver.auth.handler;
import ru.gravit.launchserver.auth.MySQLSourceConfig;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.auth.handler;
import java.io.IOException;
import java.sql.Connection;
@ -10,6 +7,10 @@
import java.sql.SQLException;
import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.MySQLSourceConfig;
import pro.gravit.utils.helper.LogHelper;
public final class MySQLAuthHandler extends CachedAuthHandler {
private MySQLSourceConfig mySQLHolder;
private String uuidColumn;
@ -25,7 +26,8 @@ public final class MySQLAuthHandler extends CachedAuthHandler {
private transient String updateServerIDSQL;
@Override
public void init() {
public void init(LaunchServer srv) {
super.init(srv);
//Verify
if (mySQLHolder == null) LogHelper.error("[Verify][AuthHandler] mySQLHolder cannot be null");
if (uuidColumn == null) LogHelper.error("[Verify][AuthHandler] uuidColumn cannot be null");

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.handler;
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
import ru.gravit.utils.helper.VerifyHelper;
package pro.gravit.launchserver.auth.handler;
import java.io.IOException;
import java.util.Objects;
import java.util.UUID;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.utils.helper.VerifyHelper;
public final class NullAuthHandler extends AuthHandler {
private volatile AuthHandler handler;

View file

@ -1,13 +1,14 @@
package ru.gravit.launchserver.auth.handler;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.auth.handler;
import java.io.IOException;
import java.net.URL;
import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class RequestAuthHandler extends CachedAuthHandler {
private String usernameFetch;
private String uuidFetch;
@ -19,7 +20,8 @@ public final class RequestAuthHandler extends CachedAuthHandler {
private String goodResponse = "OK";
@Override
public void init() {
public void init(LaunchServer srv) {
super.init(srv);
if (usernameFetch == null)
LogHelper.error("[Verify][AuthHandler] usernameFetch cannot be null");
if (uuidFetch == null)

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.auth.hwid;
import ru.gravit.launcher.HWID;
package pro.gravit.launchserver.auth.hwid;
import java.util.ArrayList;
import java.util.List;
import pro.gravit.launcher.HWID;
public class AcceptHWIDHandler extends HWIDHandler {
@Override

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver.auth.hwid;
package pro.gravit.launchserver.auth.hwid;
public class HWIDException extends Exception {
/**

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.auth.hwid;
import ru.gravit.launcher.HWID;
import ru.gravit.utils.ProviderMap;
package pro.gravit.launchserver.auth.hwid;
import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.utils.ProviderMap;
public abstract class HWIDHandler implements AutoCloseable {
public static ProviderMap<HWIDHandler> providers = new ProviderMap<>("HWIDHandler");
private static boolean registredHandl = false;
@ -15,6 +15,7 @@ public static void registerHandlers() {
providers.register("accept", AcceptHWIDHandler.class);
providers.register("mysql", MysqlHWIDHandler.class);
providers.register("json", JsonHWIDHandler.class);
providers.register("jsonfile", JsonFileHWIDHandler.class);
providers.register("memory", MemoryHWIDHandler.class);
registredHandl = true;
}

View file

@ -1,10 +1,4 @@
package ru.gravit.launchserver.auth.hwid;
import com.google.gson.reflect.TypeToken;
import ru.gravit.launcher.HWID;
import ru.gravit.launcher.Launcher;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.auth.hwid;
import java.io.IOException;
import java.io.Reader;
@ -16,6 +10,13 @@
import java.util.List;
import java.util.Objects;
import com.google.gson.reflect.TypeToken;
import pro.gravit.launcher.HWID;
import pro.gravit.launcher.Launcher;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class JsonFileHWIDHandler extends HWIDHandler {
public class Entry {
public HWID hwid;

View file

@ -1,11 +1,4 @@
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;
package pro.gravit.launchserver.auth.hwid;
import java.io.IOException;
import java.net.URL;
@ -13,6 +6,14 @@
import java.util.Arrays;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import pro.gravit.launcher.HWID;
import pro.gravit.launcher.OshiHWID;
import pro.gravit.utils.HTTPRequest;
import pro.gravit.utils.helper.LogHelper;
public final class JsonHWIDHandler extends HWIDHandler {
private static final Gson gson = new Gson();

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.auth.hwid;
import ru.gravit.launcher.HWID;
package pro.gravit.launchserver.auth.hwid;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import pro.gravit.launcher.HWID;
public class MemoryHWIDHandler extends HWIDHandler {
public class Entry {
public HWID hwid;

View file

@ -1,10 +1,4 @@
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;
package pro.gravit.launchserver.auth.hwid;
import java.sql.Connection;
import java.sql.PreparedStatement;
@ -13,6 +7,12 @@
import java.util.ArrayList;
import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.launcher.OshiHWID;
import pro.gravit.launchserver.auth.MySQLSourceConfig;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.LogHelper;
public class MysqlHWIDHandler extends HWIDHandler {
private MySQLSourceConfig mySQLHolder;

View file

@ -1,16 +1,11 @@
package ru.gravit.launchserver.auth.permissions;
package pro.gravit.launchserver.auth.permissions;
import ru.gravit.launcher.ClientPermissions;
import pro.gravit.launcher.ClientPermissions;
public class ConfigPermissionsHandler extends PermissionsHandler {
public boolean isAdmin = false;
public boolean isServer = false;
@Override
public void init() {
}
@Override
public ClientPermissions getPermissions(String username) {
ClientPermissions permissions = new ClientPermissions();

View file

@ -1,12 +1,8 @@
package ru.gravit.launchserver.auth.permissions;
package pro.gravit.launchserver.auth.permissions;
import ru.gravit.launcher.ClientPermissions;
import pro.gravit.launcher.ClientPermissions;
public class DefaultPermissionsHandler extends PermissionsHandler {
@Override
public void init() {
}
@Override
public ClientPermissions getPermissions(String username) {

View file

@ -0,0 +1,27 @@
package pro.gravit.launchserver.auth.permissions;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.dao.User;
public class HibernatePermissionsHandler extends PermissionsHandler {
@Override
public ClientPermissions getPermissions(String username) {
User user = srv.userService.findUserByUsername(username);
if(user == null) return ClientPermissions.DEFAULT;
return user.getPermissions();
}
@Override
public void setPermissions(String username, ClientPermissions permissions) {
User user = srv.userService.findUserByUsername(username);
if(user == null) return;
user.setPermissions(permissions);
srv.userService.updateUser(user);
}
@Override
public void close() throws Exception {
}
}

View file

@ -1,11 +1,4 @@
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;
package pro.gravit.launchserver.auth.permissions;
import java.io.IOException;
import java.io.Reader;
@ -16,6 +9,15 @@
import java.util.HashMap;
import java.util.Map;
import com.google.gson.reflect.TypeToken;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.Reloadable;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable {
public String filename = "permissions.json";
public static Map<String, ClientPermissions> map;
@ -44,7 +46,8 @@ public static class Enity {
}
@Override
public void init() {
public void init(LaunchServer server) {
super.init(server);
Type type = new TypeToken<Map<String, ClientPermissions>>() {
}.getType();
Path path = Paths.get(filename);

View file

@ -1,11 +1,4 @@
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;
package pro.gravit.launchserver.auth.permissions;
import java.io.IOException;
import java.io.Reader;
@ -16,6 +9,15 @@
import java.util.HashMap;
import java.util.Map;
import com.google.gson.reflect.TypeToken;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.Reloadable;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class JsonLongFilePermissionsHandler extends PermissionsHandler implements Reloadable {
public String filename = "permissions.json";
public long defaultPerms = 0L;
@ -45,7 +47,8 @@ public static class Enity {
}
@Override
public void init() {
public void init(LaunchServer server) {
super.init(server);
Type type = new TypeToken<Map<String, ClientPermissions>>() {
}.getType();
Path path = Paths.get(filename);

View file

@ -1,10 +1,12 @@
package ru.gravit.launchserver.auth.permissions;
package pro.gravit.launchserver.auth.permissions;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.utils.ProviderMap;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.ProviderMap;
public abstract class PermissionsHandler implements AutoCloseable {
public static ProviderMap<PermissionsHandler> providers = new ProviderMap<>("PermissionsHandler");
protected transient LaunchServer srv;
private static boolean registredHandl = false;
public static void registerHandlers() {
@ -13,11 +15,15 @@ public static void registerHandlers() {
providers.register("json-long", JsonLongFilePermissionsHandler.class);
providers.register("config", ConfigPermissionsHandler.class);
providers.register("default", DefaultPermissionsHandler.class);
providers.register("hibernate", HibernatePermissionsHandler.class);
registredHandl = true;
}
}
public abstract void init();
public void init(LaunchServer server)
{
this.srv = server;
}
public abstract ClientPermissions getPermissions(String username);

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.auth.protect;
package pro.gravit.launchserver.auth.protect;
import ru.gravit.launchserver.websocket.json.auth.AuthResponse;
import ru.gravit.utils.helper.SecurityHelper;
import pro.gravit.launchserver.websocket.json.auth.AuthResponse;
import pro.gravit.utils.helper.SecurityHelper;
public class NoProtectHandler extends ProtectHandler {
@Override

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.auth.protect;
package pro.gravit.launchserver.auth.protect;
import ru.gravit.launchserver.websocket.json.auth.AuthResponse;
import ru.gravit.utils.ProviderMap;
import pro.gravit.launchserver.websocket.json.auth.AuthResponse;
import pro.gravit.utils.ProviderMap;
public abstract class ProtectHandler {
public static ProviderMap<ProtectHandler> providers = new ProviderMap<>("ProtectHandler");
@ -11,6 +11,7 @@ public abstract class ProtectHandler {
public static void registerHandlers() {
if (!registredHandl) {
providers.register("none", NoProtectHandler.class);
providers.register("std", StdProtectHandler.class);
registredHandl = true;
}
}

View file

@ -0,0 +1,31 @@
package pro.gravit.launchserver.auth.protect;
import pro.gravit.launchserver.websocket.json.auth.AuthResponse;
import pro.gravit.utils.helper.SecurityHelper;
public class StdProtectHandler extends ProtectHandler {
@Override
public String generateSecureToken(AuthResponse.AuthContext context) {
return SecurityHelper.randomStringToken();
}
@Override
public String generateClientSecureToken() {
return SecurityHelper.randomStringToken();
}
@Override
public boolean verifyClientSecureToken(String token, String secureKey) {
return true;
}
@Override
public boolean allowGetAccessToken(AuthResponse.AuthContext context) {
return !(context.authType == AuthResponse.ConnectTypes.CLIENT);
}
@Override
public void checkLaunchServerLicense() {
}
}

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.provider;
package pro.gravit.launchserver.auth.provider;
import ru.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.SecurityHelper;
public final class AcceptAuthProvider extends AuthProvider {
@Override
public AuthProviderResult auth(String login, String password, String ip) {
return new AuthProviderResult(login, SecurityHelper.randomStringToken()); // Same as login
return new AuthProviderResult(login, SecurityHelper.randomStringToken(), srv); // Same as login
}
@Override

View file

@ -1,14 +1,15 @@
package ru.gravit.launchserver.auth.provider;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.utils.ProviderMap;
package pro.gravit.launchserver.auth.provider;
import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.utils.ProviderMap;
public abstract class AuthProvider implements AutoCloseable {
public static ProviderMap<AuthProvider> providers = new ProviderMap<>("AuthProvider");
private static boolean registredProv = false;
protected transient LaunchServer srv = null;
public static AuthProviderResult authError(String message) throws AuthException {
throw new AuthException(message);
}
@ -21,6 +22,7 @@ public static void registerProviders() {
providers.register("mysql", MySQLAuthProvider.class);
providers.register("request", RequestAuthProvider.class);
providers.register("json", JsonAuthProvider.class);
providers.register("hibernate", HibernateAuthProvider.class);
registredProv = true;
}
}
@ -34,7 +36,7 @@ public void preAuth(String login, String password, String customText, String ip)
@Override
public abstract void close() throws IOException;
public void init() {
public void init(LaunchServer srv) {
this.srv = srv;
}
}

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.auth.provider;
package pro.gravit.launchserver.auth.provider;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launchserver.LaunchServer;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.LaunchServer;
public class AuthProviderResult {
@ -9,10 +9,10 @@ public class AuthProviderResult {
public final String accessToken;
public final ClientPermissions permissions;
public AuthProviderResult(String username, String accessToken) {
public AuthProviderResult(String username, String accessToken, LaunchServer server) {
this.username = username;
this.accessToken = accessToken;
permissions = LaunchServer.server.config.permissionsHandler.getPermissions(username);
permissions = server.config.permissionsHandler.getPermissions(username);
}
public AuthProviderResult(String username, String accessToken, ClientPermissions permissions) {

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver.auth.provider;
package pro.gravit.launchserver.auth.provider;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.utils.helper.SecurityHelper;
import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
public abstract class DigestAuthProvider extends AuthProvider {
private DigestAlgorithm digest;

View file

@ -0,0 +1,25 @@
package pro.gravit.launchserver.auth.provider;
import java.io.IOException;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.SecurityHelper;
public class HibernateAuthProvider extends AuthProvider {
@Override
public AuthProviderResult auth(String login, String password, String ip) throws Exception {
User user = srv.userService.findUserByUsername(login);
if(user == null || !user.verifyPassword(password))
{
if(user ==null) throw new AuthException("Username incorrect");
else throw new AuthException("Username or password incorrect");
}
return new AuthProviderResult(login, SecurityHelper.randomStringToken(), srv);
}
@Override
public void close() throws IOException {
}
}

View file

@ -1,14 +1,15 @@
package ru.gravit.launchserver.auth.provider;
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;
package pro.gravit.launchserver.auth.provider;
import java.io.IOException;
import java.net.URL;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.utils.HTTPRequest;
import pro.gravit.utils.helper.SecurityHelper;
public final class JsonAuthProvider extends AuthProvider {
private static Gson gson = new Gson();
private URL url;

View file

@ -1,18 +1,18 @@
package ru.gravit.launchserver.auth.provider;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.launchserver.auth.MySQLSourceConfig;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
package pro.gravit.launchserver.auth.provider;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.auth.MySQLSourceConfig;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
public final class MySQLAuthProvider extends AuthProvider {
private MySQLSourceConfig mySQLHolder;
private String query;
@ -21,7 +21,8 @@ public final class MySQLAuthProvider extends AuthProvider {
private boolean usePermission;
@Override
public void init() {
public void init(LaunchServer srv) {
super.init(srv);
if (query == null) LogHelper.error("[Verify][AuthProvider] query cannot be null");
if (message == null) LogHelper.error("[Verify][AuthProvider] message cannot be null");
if (mySQLHolder == null) LogHelper.error("[Verify][AuthProvider] mySQLHolder cannot be null");
@ -38,7 +39,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
// Execute SQL query
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
try (ResultSet set = s.executeQuery()) {
return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : LaunchServer.server.config.permissionsHandler.getPermissions(set.getString(1))) : authError(message);
return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : srv.config.permissionsHandler.getPermissions(set.getString(1))) : authError(message);
}
}

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.auth.provider;
import ru.gravit.utils.helper.VerifyHelper;
package pro.gravit.launchserver.auth.provider;
import java.io.IOException;
import java.util.Objects;
import pro.gravit.utils.helper.VerifyHelper;
public final class NullAuthProvider extends AuthProvider {
private volatile AuthProvider provider;

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.provider;
import ru.gravit.launchserver.Reconfigurable;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
package pro.gravit.launchserver.auth.provider;
import java.util.ArrayList;
import pro.gravit.launchserver.Reconfigurable;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
public final class RejectAuthProvider extends AuthProvider implements Reconfigurable {
public RejectAuthProvider() {
}
@ -23,7 +23,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
if (whitelist != null) {
for (String username : whitelist) {
if (login.equals(username)) {
return new AuthProviderResult(login, SecurityHelper.randomStringToken());
return new AuthProviderResult(login, SecurityHelper.randomStringToken(), srv);
}
}
}

View file

@ -1,17 +1,17 @@
package ru.gravit.launchserver.auth.provider;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
package pro.gravit.launchserver.auth.provider;
import java.io.IOException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
public final class RequestAuthProvider extends AuthProvider {
private String url;
private transient Pattern pattern;
@ -19,7 +19,8 @@ public final class RequestAuthProvider extends AuthProvider {
private boolean usePermission;
@Override
public void init() {
public void init(LaunchServer srv) {
super.init(srv);
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);
@ -32,7 +33,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
// Match username
Matcher matcher = pattern.matcher(currentResponse);
return matcher.matches() && matcher.groupCount() >= 1 ?
new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.getLong(matcher.group("permission"))) : LaunchServer.server.config.permissionsHandler.getPermissions(login)) :
new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.getLong(matcher.group("permission"))) : srv.config.permissionsHandler.getPermissions(login)) :
authError(currentResponse);
}

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.texture;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.utils.helper.VerifyHelper;
package pro.gravit.launchserver.auth.texture;
import java.io.IOException;
import java.util.Objects;
import java.util.UUID;
import pro.gravit.launcher.profiles.Texture;
import pro.gravit.utils.helper.VerifyHelper;
public final class NullTextureProvider extends TextureProvider {
private volatile TextureProvider provider;

View file

@ -1,15 +1,15 @@
package ru.gravit.launchserver.auth.texture;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.auth.texture;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.UUID;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.profiles.Texture;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class RequestTextureProvider extends TextureProvider {
public RequestTextureProvider() {
}

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.auth.texture;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.utils.ProviderMap;
package pro.gravit.launchserver.auth.texture;
import java.io.IOException;
import java.util.UUID;
import pro.gravit.launcher.profiles.Texture;
import pro.gravit.utils.ProviderMap;
public abstract class TextureProvider implements AutoCloseable {
public static ProviderMap<TextureProvider> providers = new ProviderMap<>("TextureProvider");
private static boolean registredProv = false;

View file

@ -1,9 +1,9 @@
package ru.gravit.launchserver.auth.texture;
import ru.gravit.launcher.profiles.Texture;
package pro.gravit.launchserver.auth.texture;
import java.util.UUID;
import pro.gravit.launcher.profiles.Texture;
public final class VoidTextureProvider extends TextureProvider {
@Override

View file

@ -1,7 +1,4 @@
package ru.gravit.launchserver.binary;
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
import ru.gravit.utils.helper.IOHelper;
package pro.gravit.launchserver.binary;
import java.io.IOException;
import java.io.InputStream;
@ -11,6 +8,9 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
import pro.gravit.utils.helper.IOHelper;
public class BuildContext {
public final ZipOutputStream output;
public final JAConfigurator config;

View file

@ -1,16 +1,20 @@
package ru.gravit.launchserver.binary;
import net.sf.launch4j.Builder;
import net.sf.launch4j.Log;
import net.sf.launch4j.config.*;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.Version;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.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 pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.Version;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class EXEL4JLauncherBinary extends LauncherBinary {
private final static class Launch4JLog extends Log {
private static final Launch4JLog INSTANCE = new Launch4JLog();

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.binary;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.binary;
import java.io.IOException;
import java.nio.file.Files;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class EXELauncherBinary extends LauncherBinary {
public EXELauncherBinary(LaunchServer server) {

View file

@ -1,11 +1,16 @@
package ru.gravit.launchserver.binary;
import javassist.*;
import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
package pro.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 pro.gravit.launcher.LauncherConfig;
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
public class JAConfigurator implements AutoCloseable {
public ClassPool pool;
public CtClass ctClass;
@ -29,12 +34,12 @@ public JAConfigurator(String configclass, MainBuildTask jarLauncherBinary) throw
}
public void addModuleClass(String fullName) {
moduleBody.append("ru.gravit.launcher.modules.Module mod");
moduleBody.append("pro.gravit.launcher.modules.Module mod");
moduleBody.append(autoincrement);
moduleBody.append(" = new ");
moduleBody.append(fullName);
moduleBody.append("();");
moduleBody.append("ru.gravit.launcher.Launcher.modulesManager.registerModule( mod");
moduleBody.append("pro.gravit.launcher.Launcher.modulesManager.registerModule( mod");
moduleBody.append(autoincrement);
moduleBody.append(");");
autoincrement++;

View file

@ -1,11 +1,4 @@
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;
package pro.gravit.launchserver.binary;
import java.io.IOException;
import java.nio.file.Files;
@ -14,6 +7,19 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.binary.tasks.AdditionalFixesApplyTask;
import pro.gravit.launchserver.binary.tasks.AttachJarsTask;
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
import pro.gravit.launchserver.binary.tasks.PrepareBuildTask;
import pro.gravit.launchserver.binary.tasks.ProGuardBuildTask;
import pro.gravit.launchserver.binary.tasks.RadonBuildTask;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class JARLauncherBinary extends LauncherBinary {
public final AtomicLong count;
public final Path runtimeDir;
@ -24,7 +30,7 @@ public final class JARLauncherBinary extends LauncherBinary {
public List<Path> addonLibs;
public JARLauncherBinary(LaunchServer server) throws IOException {
super(server, LauncherBinary.resolve(server, ".jar"));
super(server, resolve(server, ".jar"));
count = new AtomicLong(0);
runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
guardDir = server.dir.resolve(Launcher.GUARD_DIR);

View file

@ -1,13 +1,13 @@
package ru.gravit.launchserver.binary;
import ru.gravit.launcher.serialize.signed.DigestBytesHolder;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.SecurityHelper;
package pro.gravit.launchserver.binary;
import java.io.IOException;
import java.nio.file.Path;
import pro.gravit.launcher.serialize.signed.DigestBytesHolder;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.SecurityHelper;
public abstract class LauncherBinary {
public final LaunchServer server;
public final Path syncBinaryFile;

View file

@ -1,10 +1,4 @@
package ru.gravit.launchserver.binary;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
import ru.gravit.utils.helper.UnpackHelper;
package pro.gravit.launchserver.binary;
import java.io.IOException;
import java.io.OutputStreamWriter;
@ -15,6 +9,12 @@
import java.util.ArrayList;
import java.util.List;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.UnpackHelper;
public class ProguardConf {
private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ";
@ -62,7 +62,7 @@ public String[] buildConfig(Path inputJar, Path outputJar) {
private void genConfig(boolean force) throws IOException {
if (IOHelper.exists(config) && !force) return;
Files.deleteIfExists(config);
UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"), config);
UnpackHelper.unpack(IOHelper.getResourceURL("pro/gravit/launchserver/defaults/proguard.cfg"), config);
}
public void genWords(boolean force) throws IOException {
@ -71,7 +71,7 @@ public void genWords(boolean force) throws IOException {
SecureRandom rand = SecurityHelper.newRandom();
rand.setSeed(SecureRandom.getSeed(32));
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(IOHelper.newOutput(words), IOHelper.UNICODE_CHARSET))) {
String projectName = LaunchServer.server.config.projectName.replaceAll("\\W", "");
String projectName = srv.config.projectName.replaceAll("\\W", "");
String lowName = projectName.toLowerCase();
String upName = projectName.toUpperCase();
for (int i = 0; i < Short.MAX_VALUE; i++) out.println(generateString(rand, lowName, upName, 3));

View file

@ -1,12 +1,4 @@
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;
package pro.gravit.launchserver.binary.tasks;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -19,6 +11,15 @@
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 pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.asm.ClassMetadataReader;
import pro.gravit.launchserver.asm.SafeClassWriter;
import pro.gravit.utils.helper.IOHelper;
public class AdditionalFixesApplyTask implements LauncherBuildTask {
private final LaunchServer server;

View file

@ -1,8 +1,4 @@
package ru.gravit.launchserver.binary.tasks;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.binary.tasks;
import java.io.IOException;
import java.nio.file.Path;
@ -12,6 +8,10 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class AttachJarsTask implements LauncherBuildTask {
private final LaunchServer srv;
private final List<Path> jars;
@ -22,6 +22,9 @@ public AttachJarsTask(LaunchServer srv) {
jars = new ArrayList<>();
exclusions = new ArrayList<>();
exclusions.add("META-INF");
exclusions.add("module-info.class");
exclusions.add("LICENSE");
exclusions.add("LICENSE.txt");
}
@Override

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver.binary.tasks;
package pro.gravit.launchserver.binary.tasks;
import java.io.IOException;
import java.nio.file.Path;

View file

@ -1,18 +1,6 @@
package ru.gravit.launchserver.binary.tasks;
package pro.gravit.launchserver.binary.tasks;
import javassist.CannotCompileException;
import javassist.NotFoundException;
import ru.gravit.launcher.AutogenConfig;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launcher.serialize.HOutput;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.asm.ClassMetadataReader;
import ru.gravit.launchserver.binary.BuildContext;
import ru.gravit.launchserver.binary.JAConfigurator;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
import static pro.gravit.utils.helper.IOHelper.newZipEntry;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -28,7 +16,19 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import static ru.gravit.utils.helper.IOHelper.newZipEntry;
import javassist.CannotCompileException;
import javassist.NotFoundException;
import pro.gravit.launcher.AutogenConfig;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherConfig;
import pro.gravit.launcher.serialize.HOutput;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.asm.ClassMetadataReader;
import pro.gravit.launchserver.binary.BuildContext;
import pro.gravit.launchserver.binary.JAConfigurator;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
public class MainBuildTask implements LauncherBuildTask {
private final LaunchServer server;

View file

@ -1,9 +1,4 @@
package ru.gravit.launchserver.binary.tasks;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.UnpackHelper;
package pro.gravit.launchserver.binary.tasks;
import java.io.IOException;
import java.nio.file.FileVisitResult;
@ -13,6 +8,11 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.UnpackHelper;
public class PrepareBuildTask implements LauncherBuildTask {
private final LaunchServer server;
private final Path result;

View file

@ -1,15 +1,15 @@
package ru.gravit.launchserver.binary.tasks;
package pro.gravit.launchserver.binary.tasks;
import java.io.IOException;
import java.nio.file.Path;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import proguard.Configuration;
import proguard.ConfigurationParser;
import proguard.ParseException;
import proguard.ProGuard;
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 class ProGuardBuildTask implements LauncherBuildTask {
private final LaunchServer server;

View file

@ -1,11 +1,4 @@
package ru.gravit.launchserver.binary.tasks;
import me.itzsomebody.radon.Radon;
import me.itzsomebody.radon.SessionInfo;
import me.itzsomebody.radon.config.ConfigurationParser;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.UnpackHelper;
package pro.gravit.launchserver.binary.tasks;
import java.io.File;
import java.io.IOException;
@ -14,6 +7,13 @@
import java.util.List;
import java.util.stream.Collectors;
import me.itzsomebody.radon.Radon;
import me.itzsomebody.radon.SessionInfo;
import me.itzsomebody.radon.config.ConfigurationParser;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.UnpackHelper;
public class RadonBuildTask implements LauncherBuildTask {
private final LaunchServer srv;
public final Path config;
@ -35,7 +35,7 @@ public Path process(Path inputFile) throws IOException {
Files.deleteIfExists(outputFile);
if (srv.config.enabledRadon) {
if (!IOHelper.isFile(config))
UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config);
UnpackHelper.unpack(IOHelper.getResourceURL("pro/gravit/launchserver/defaults/radon.cfg"), config);
ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config));
SessionInfo info = p.createSessionFromConfig();
info.setInput(inputFile.toFile());

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver.binary.tasks;
package pro.gravit.launchserver.binary.tasks;
import java.util.ArrayList;
import java.util.List;

View file

@ -0,0 +1,14 @@
package pro.gravit.launchserver.command;
import pro.gravit.launchserver.LaunchServer;
public abstract class Command extends pro.gravit.utils.command.Command {
protected final LaunchServer server;
protected Command(LaunchServer server) {
this.server = server;
}
}

View file

@ -1,14 +1,14 @@
package ru.gravit.launchserver.command.auth;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
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;
package pro.gravit.launchserver.command.auth;
import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class AuthCommand extends Command {
public AuthCommand(LaunchServer server) {
super(server);

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.auth;
import ru.gravit.launcher.HWID;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
package pro.gravit.launchserver.command.auth;
import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class BanCommand extends Command {
public BanCommand(LaunchServer server) {
super(server);

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.command.auth;
import ru.gravit.launcher.HWID;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.auth;
import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public class GetHWIDCommand extends Command {
public GetHWIDCommand(LaunchServer server) {
super(server);

View file

@ -1,14 +1,14 @@
package ru.gravit.launchserver.command.auth;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.command.CommandException;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.auth;
import java.io.IOException;
import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.LogHelper;
public final class UUIDToUsernameCommand extends Command {
public UUIDToUsernameCommand(LaunchServer server) {
super(server);

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.auth;
import ru.gravit.launcher.HWID;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
package pro.gravit.launchserver.command.auth;
import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class UnbanCommand extends Command {
public UnbanCommand(LaunchServer server) {
super(server);

View file

@ -1,14 +1,14 @@
package ru.gravit.launchserver.command.auth;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.command.CommandException;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.auth;
import java.io.IOException;
import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.LogHelper;
public final class UsernameToUUIDCommand extends Command {
public UsernameToUUIDCommand(LaunchServer server) {
super(server);

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.basic;
package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public final class BuildCommand extends Command {
public BuildCommand(LaunchServer server) {

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver.command.basic;
package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class LogConnectionsCommand extends Command {
public LogConnectionsCommand(LaunchServer server) {

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
package pro.gravit.launchserver.command.basic;
import java.io.IOException;
import java.nio.file.Files;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class ProguardCleanCommand extends Command {
public ProguardCleanCommand(LaunchServer server) {
super(server);

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.basic;
package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public final class RebindCommand extends Command {
public RebindCommand(LaunchServer server) {

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
package pro.gravit.launchserver.command.basic;
import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class RegenProguardDictCommand extends Command {
public RegenProguardDictCommand(LaunchServer server) {

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
package pro.gravit.launchserver.command.basic;
import java.io.IOException;
import java.nio.file.Files;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class RemoveMappingsProguardCommand extends Command {
public RemoveMappingsProguardCommand(LaunchServer server) {

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.basic;
package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public final class RestartCommand extends Command {
public RestartCommand(LaunchServer server) {

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver.command.basic;
package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.JVMHelper;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.JVMHelper;
public final class StopCommand extends Command {
public StopCommand(LaunchServer server) {

View file

@ -1,11 +1,10 @@
package ru.gravit.launchserver.command.basic;
package pro.gravit.launchserver.command.basic;
import ru.gravit.launcher.events.PingEvent;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.launchserver.websocket.NettyServerSocketHandler;
import ru.gravit.launchserver.websocket.WebSocketFrameHandler;
import ru.gravit.utils.helper.CommonHelper;
import pro.gravit.launcher.events.PingEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.websocket.NettyServerSocketHandler;
import pro.gravit.utils.helper.CommonHelper;
public class TestCommand extends Command {
public TestCommand(LaunchServer server) {
@ -36,7 +35,7 @@ public void invoke(String... args) throws Exception {
handler.close();
}
if (args[0].equals("eventAll")) {
WebSocketFrameHandler.service.sendObjectAll(new PingEvent());
handler.nettyServer.frameHandler.service.sendObjectAll(new PingEvent());
}
}
}

View file

@ -1,9 +1,9 @@
package ru.gravit.launchserver.command.basic;
package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.Version;
import ru.gravit.utils.helper.LogHelper;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.Version;
import pro.gravit.utils.helper.LogHelper;
public final class VersionCommand extends Command {
public VersionCommand(LaunchServer server) {

View file

@ -0,0 +1,33 @@
package pro.gravit.launchserver.command.dao;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.LogHelper;
public class GetAllUsersCommand extends Command {
public GetAllUsersCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "";
}
@Override
public String getUsageDescription() {
return "get all users information";
}
@Override
public void invoke(String... args) throws Exception {
int count = 0;
for(User user : server.userService.findAllUsers())
{
LogHelper.subInfo("[%s] UUID: %s", user.username, user.uuid.toString());
count++;
}
LogHelper.info("Print %d users", count);
}
}

View file

@ -0,0 +1,39 @@
package pro.gravit.launchserver.command.dao;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.dao.User;
import pro.gravit.launchserver.dao.UserHWID;
import pro.gravit.utils.helper.LogHelper;
public class GetUserCommand extends Command {
public GetUserCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "[username]";
}
@Override
public String getUsageDescription() {
return "get user information";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 1);
User user = server.userService.findUserByUsername(args[0]);
if(user == null)
{
LogHelper.error("User %s not found", args[0]);
return;
}
LogHelper.info("[%s] UUID: %s", user.username, user.uuid.toString());
for(UserHWID hwid : user.hwids)
{
LogHelper.info("[%s] HWID: memory: %d | serial %s | hwdiskserial: %s | processorID %s | macAddr %s", user.username, hwid.totalMemory, hwid.serialNumber, hwid.HWDiskSerial, hwid.processorID, hwid.macAddr);
}
}
}

View file

@ -0,0 +1,35 @@
package pro.gravit.launchserver.command.dao;
import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.LogHelper;
public class RegisterCommand extends Command {
public RegisterCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "[login] [password]";
}
@Override
public String getUsageDescription() {
return "Register new user";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 2);
User user = new User();
user.username = args[0];
user.setPassword(args[1]);
user.uuid = UUID.randomUUID();
server.userService.saveUser(user);
LogHelper.info("User %s registered. UUID: %s", user.username, user.uuid.toString());
}
}

View file

@ -0,0 +1,37 @@
package pro.gravit.launchserver.command.dao;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.LogHelper;
public class SetUserPasswordCommand extends Command {
public SetUserPasswordCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "[username] [new password]";
}
@Override
public String getUsageDescription() {
return "Set user password";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 2);
User user = server.userService.findUserByUsername(args[0]);
if(user == null)
{
LogHelper.error("User %s not found", args[1]);
return;
}
user.setPassword(args[1]);
server.userService.updateUser(user);
LogHelper.info("[%s] UUID: %s | New Password: %s", user.username, user.uuid.toString(), args[1]);
}
}

View file

@ -1,12 +1,4 @@
package ru.gravit.launchserver.command.dump;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
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;
package pro.gravit.launchserver.command.dump;
import java.io.Reader;
import java.io.Writer;
@ -14,6 +6,14 @@
import java.util.Map;
import java.util.UUID;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.auth.handler.CachedAuthHandler;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class DumpEntryCacheCommand extends Command {
public DumpEntryCacheCommand(LaunchServer server) {
super(server);

View file

@ -1,12 +1,4 @@
package ru.gravit.launchserver.command.dump;
import com.google.gson.reflect.TypeToken;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.launchserver.socket.Client;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.dump;
import java.io.Reader;
import java.io.Writer;
@ -15,6 +7,15 @@
import java.util.HashSet;
import java.util.Set;
import com.google.gson.reflect.TypeToken;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class DumpSessionsCommand extends Command {
public DumpSessionsCommand(LaunchServer server) {
super(server);

View file

@ -1,25 +1,58 @@
package ru.gravit.launchserver.command.handler;
package pro.gravit.launchserver.command.handler;
import ru.gravit.launchserver.LaunchServer;
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.*;
import ru.gravit.launchserver.command.install.CheckInstallCommand;
import ru.gravit.launchserver.command.install.MultiCommand;
import ru.gravit.launchserver.command.modules.LoadModuleCommand;
import ru.gravit.launchserver.command.modules.ModulesCommand;
import ru.gravit.launchserver.command.service.*;
import ru.gravit.utils.command.BaseCommandCategory;
import ru.gravit.utils.command.basic.ClearCommand;
import ru.gravit.utils.command.basic.DebugCommand;
import ru.gravit.utils.command.basic.GCCommand;
import ru.gravit.utils.command.basic.HelpCommand;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.auth.AuthCommand;
import pro.gravit.launchserver.command.auth.BanCommand;
import pro.gravit.launchserver.command.auth.GetHWIDCommand;
import pro.gravit.launchserver.command.auth.UUIDToUsernameCommand;
import pro.gravit.launchserver.command.auth.UnbanCommand;
import pro.gravit.launchserver.command.auth.UsernameToUUIDCommand;
import pro.gravit.launchserver.command.basic.BuildCommand;
import pro.gravit.launchserver.command.basic.LogConnectionsCommand;
import pro.gravit.launchserver.command.basic.ProguardCleanCommand;
import pro.gravit.launchserver.command.basic.RebindCommand;
import pro.gravit.launchserver.command.basic.RegenProguardDictCommand;
import pro.gravit.launchserver.command.basic.RemoveMappingsProguardCommand;
import pro.gravit.launchserver.command.basic.RestartCommand;
import pro.gravit.launchserver.command.basic.StopCommand;
import pro.gravit.launchserver.command.basic.TestCommand;
import pro.gravit.launchserver.command.basic.VersionCommand;
import pro.gravit.launchserver.command.dao.GetAllUsersCommand;
import pro.gravit.launchserver.command.dao.GetUserCommand;
import pro.gravit.launchserver.command.dao.RegisterCommand;
import pro.gravit.launchserver.command.dao.SetUserPasswordCommand;
import pro.gravit.launchserver.command.dump.DumpEntryCacheCommand;
import pro.gravit.launchserver.command.dump.DumpSessionsCommand;
import pro.gravit.launchserver.command.hash.DownloadAssetCommand;
import pro.gravit.launchserver.command.hash.DownloadClientCommand;
import pro.gravit.launchserver.command.hash.IndexAssetCommand;
import pro.gravit.launchserver.command.hash.SyncBinariesCommand;
import pro.gravit.launchserver.command.hash.SyncProfilesCommand;
import pro.gravit.launchserver.command.hash.SyncUpdatesCommand;
import pro.gravit.launchserver.command.hash.UnindexAssetCommand;
import pro.gravit.launchserver.command.install.CheckInstallCommand;
import pro.gravit.launchserver.command.install.MultiCommand;
import pro.gravit.launchserver.command.modules.LoadModuleCommand;
import pro.gravit.launchserver.command.modules.ModulesCommand;
import pro.gravit.launchserver.command.service.ComponentCommand;
import pro.gravit.launchserver.command.service.ConfigCommand;
import pro.gravit.launchserver.command.service.ConfigHelpCommand;
import pro.gravit.launchserver.command.service.ConfigListCommand;
import pro.gravit.launchserver.command.service.GetModulusCommand;
import pro.gravit.launchserver.command.service.GetPermissionsCommand;
import pro.gravit.launchserver.command.service.GivePermissionsCommand;
import pro.gravit.launchserver.command.service.ReloadAllCommand;
import pro.gravit.launchserver.command.service.ReloadCommand;
import pro.gravit.launchserver.command.service.ReloadListCommand;
import pro.gravit.launchserver.command.service.ServerStatusCommand;
import pro.gravit.utils.command.BaseCommandCategory;
import pro.gravit.utils.command.basic.ClearCommand;
import pro.gravit.utils.command.basic.DebugCommand;
import pro.gravit.utils.command.basic.GCCommand;
import pro.gravit.utils.command.basic.HelpCommand;
public abstract class CommandHandler extends ru.gravit.utils.command.CommandHandler {
public static void registerCommands(ru.gravit.utils.command.CommandHandler handler) {
LaunchServer server = LaunchServer.server;
public abstract class CommandHandler extends pro.gravit.utils.command.CommandHandler {
public static void registerCommands(pro.gravit.utils.command.CommandHandler handler, LaunchServer server) {
BaseCommandCategory basic = new BaseCommandCategory();
// Register basic commands
basic.registerCommand("help", new HelpCommand(handler));
@ -53,6 +86,15 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl
Category updatesCategory = new Category(updates, "updates", "Update and Sync Management");
handler.registerCategory(updatesCategory);
//Register dao commands
BaseCommandCategory dao = new BaseCommandCategory();
dao.registerCommand("register", new RegisterCommand(server));
dao.registerCommand("setUserPassword", new SetUserPasswordCommand(server));
dao.registerCommand("getUser", new GetUserCommand(server));
dao.registerCommand("getAllUsers", new GetAllUsersCommand(server));
Category daoCategory = new Category(dao, "DAO", "Data Management");
handler.registerCategory(daoCategory);
// Register auth commands
BaseCommandCategory auth = new BaseCommandCategory();
auth.registerCommand("auth", new AuthCommand(server));

View file

@ -1,16 +1,16 @@
package ru.gravit.launchserver.command.hash;
import ru.gravit.launcher.profiles.ClientProfile.Version;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.HttpDownloader;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.hash;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import pro.gravit.launcher.profiles.ClientProfile.Version;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.HttpDownloader;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class DownloadAssetCommand extends Command {
public DownloadAssetCommand(LaunchServer server) {

View file

@ -1,14 +1,4 @@
package ru.gravit.launchserver.command.hash;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.profiles.ClientProfile.Version;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.HttpDownloader;
import ru.gravit.utils.command.CommandException;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.hash;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@ -17,6 +7,16 @@
import java.nio.file.Path;
import java.util.Collections;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launcher.profiles.ClientProfile.Version;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.HttpDownloader;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class DownloadClientCommand extends Command {
public DownloadClientCommand(LaunchServer server) {
@ -51,7 +51,7 @@ public void invoke(String... args) throws IOException, CommandException {
// Create profile file
LogHelper.subInfo("Creaing profile file: '%s'", dirName);
ClientProfile client;
String profilePath = String.format("ru/gravit/launchserver/defaults/profile%s.cfg", version.name);
String profilePath = String.format("pro/gravit/launchserver/defaults/profile%s.cfg", version.name);
try (BufferedReader reader = IOHelper.newReader(IOHelper.getResourceURL(profilePath))) {
client = Launcher.gsonManager.configGson.fromJson(reader, ClientProfile.class);
}

View file

@ -1,14 +1,4 @@
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.utils.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;
package pro.gravit.launchserver.command.hash;
import java.io.BufferedWriter;
import java.io.IOException;
@ -19,6 +9,17 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collections;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
public final class IndexAssetCommand extends Command {
private static Gson gson = new Gson();

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.hash;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.hash;
import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class SyncBinariesCommand extends Command {
public SyncBinariesCommand(LaunchServer server) {
super(server);

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.hash;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.hash;
import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class SyncProfilesCommand extends Command {
public SyncProfilesCommand(LaunchServer server) {
super(server);

View file

@ -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;
package pro.gravit.launchserver.command.hash;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class SyncUpdatesCommand extends Command {
public SyncUpdatesCommand(LaunchServer server) {
super(server);

View file

@ -1,13 +1,4 @@
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.utils.command.CommandException;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.hash;
import java.io.BufferedReader;
import java.nio.file.Files;
@ -15,6 +6,16 @@
import java.util.Collections;
import java.util.Map;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class UnindexAssetCommand extends Command {
private static JsonParser parser = new JsonParser();

View file

@ -1,9 +1,9 @@
package ru.gravit.launchserver.command.install;
package pro.gravit.launchserver.command.install;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.LogHelper;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.LogHelper;
public class CheckInstallCommand extends Command {
public CheckInstallCommand(LaunchServer server) {

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.install;
package pro.gravit.launchserver.command.install;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class MultiCommand extends Command {
public MultiCommand(LaunchServer server) {

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.modules;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
package pro.gravit.launchserver.command.modules;
import java.net.URI;
import java.nio.file.Paths;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class LoadModuleCommand extends Command {
public LoadModuleCommand(LaunchServer server) {
super(server);

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.modules;
package pro.gravit.launchserver.command.modules;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class ModulesCommand extends Command {
public ModulesCommand(LaunchServer server) {

View file

@ -1,16 +1,16 @@
package ru.gravit.launchserver.command.service;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.NeedGarbageCollection;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.launchserver.components.Component;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
package pro.gravit.launchserver.command.service;
import java.io.Reader;
import java.nio.file.Paths;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.NeedGarbageCollection;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.components.Component;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class ComponentCommand extends Command {
public ComponentCommand(LaunchServer server) {
super(server);

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver.command.service;
package pro.gravit.launchserver.command.service;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public class ConfigCommand extends Command {
public ConfigCommand(LaunchServer server) {

Some files were not shown because too many files have changed in this diff Show more