[FEATURE][EXP][NEEDS TEST] Отказ от статического поля инстанции в LaunchServer.

This commit is contained in:
Zaxar163 2019-06-03 11:50:28 +03:00
parent a4d4aa834d
commit b21b6c2362
33 changed files with 106 additions and 113 deletions

View file

@ -97,11 +97,13 @@ public void reload() throws Exception {
try (BufferedReader reader = IOHelper.newReader(configFile)) { try (BufferedReader reader = IOHelper.newReader(configFile)) {
config = Launcher.gsonManager.gson.fromJson(reader, Config.class); config = Launcher.gsonManager.gson.fromJson(reader, Config.class);
} }
config.server = this;
config.verify(); config.verify();
config.init(); config.init();
} }
public static final class Config { public static final class Config {
private transient LaunchServer server = null;
public int legacyPort; public int legacyPort;
private String legacyAddress; private String legacyAddress;
@ -236,30 +238,30 @@ public void verify() {
public void init() { public void init() {
Launcher.applyLauncherEnv(env); Launcher.applyLauncherEnv(env);
for (AuthProviderPair provider : auth) { for (AuthProviderPair provider : auth) {
provider.init(); provider.init(server);
} }
permissionsHandler.init(); permissionsHandler.init();
hwidHandler.init(); hwidHandler.init();
if (protectHandler != null) { if (protectHandler != null) {
protectHandler.checkLaunchServerLicense(); protectHandler.checkLaunchServerLicense();
} }
LaunchServer.server.registerObject("permissionsHandler", permissionsHandler); server.registerObject("permissionsHandler", permissionsHandler);
for (AuthProviderPair pair : auth) { for (AuthProviderPair pair : auth) {
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider); server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler); 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(".texture"), pair.textureProvider);
} }
Arrays.stream(mirrors).forEach(LaunchServer.server.mirrorManager::addMirror); Arrays.stream(mirrors).forEach(server.mirrorManager::addMirror);
} }
public void close() { public void close() {
try { try {
LaunchServer.server.unregisterObject("permissionsHandler", permissionsHandler); server.unregisterObject("permissionsHandler", permissionsHandler);
for (AuthProviderPair pair : auth) { for (AuthProviderPair pair : auth) {
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider); server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler); 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(".texture"), pair.textureProvider);
} }
} catch (Exception e) { } catch (Exception e) {
LogHelper.error(e); LogHelper.error(e);
@ -426,7 +428,7 @@ public static void main(String... args) throws Throwable {
public final Path updatesDir; public final Path updatesDir;
public static LaunchServer server = null; //public static LaunchServer server = null;
public final Path profilesDir; public final Path profilesDir;
// Server config // Server config
@ -509,7 +511,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
Response.registerResponses(); Response.registerResponses();
Component.registerComponents(); Component.registerComponents();
ProtectHandler.registerHandlers(); ProtectHandler.registerHandlers();
LaunchServer.server = this; //LaunchServer.server = this;
// Set command handler // Set command handler
CommandHandler localCommandHandler; CommandHandler localCommandHandler;
@ -526,7 +528,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
localCommandHandler = new StdCommandHandler(true); localCommandHandler = new StdCommandHandler(true);
LogHelper.warning("JLine2 isn't in classpath, using std"); LogHelper.warning("JLine2 isn't in classpath, using std");
} }
pro.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler); pro.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler, this);
commandHandler = localCommandHandler; commandHandler = localCommandHandler;
// Set key pair // Set key pair
@ -568,6 +570,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
try (BufferedReader reader = IOHelper.newReader(configFile)) { try (BufferedReader reader = IOHelper.newReader(configFile)) {
config = Launcher.gsonManager.gson.fromJson(reader, Config.class); config = Launcher.gsonManager.gson.fromJson(reader, Config.class);
} }
config.server = this;
if (!Files.exists(runtimeConfigFile)) { if (!Files.exists(runtimeConfigFile)) {
LogHelper.info("Reset LaunchServer runtime config file"); LogHelper.info("Reset LaunchServer runtime config file");
runtime = new LaunchServerRuntimeConfig(); runtime = new LaunchServerRuntimeConfig();
@ -582,7 +585,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
config.verify(); config.verify();
Launcher.applyLauncherEnv(config.env); Launcher.applyLauncherEnv(config.env);
for (AuthProviderPair provider : config.auth) { for (AuthProviderPair provider : config.auth) {
provider.init(); provider.init(this);
} }
config.permissionsHandler.init(); config.permissionsHandler.init();
config.hwidHandler.init(); config.hwidHandler.init();

View file

@ -2,6 +2,7 @@
import java.io.IOException; import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.handler.AuthHandler; import pro.gravit.launchserver.auth.handler.AuthHandler;
import pro.gravit.launchserver.auth.provider.AuthProvider; import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.texture.TextureProvider; import pro.gravit.launchserver.auth.texture.TextureProvider;
@ -21,8 +22,8 @@ public AuthProviderPair(AuthProvider provider, AuthHandler handler, TextureProvi
this.name = name; this.name = name;
} }
public void init() { public void init(LaunchServer srv) {
provider.init(); provider.init(srv);
handler.init(); handler.init();
} }

View file

@ -6,7 +6,7 @@ public final class AcceptAuthProvider extends AuthProvider {
@Override @Override
public AuthProviderResult auth(String login, String password, String ip) { 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 @Override

View file

@ -2,13 +2,14 @@
import java.io.IOException; import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.utils.ProviderMap; import pro.gravit.utils.ProviderMap;
public abstract class AuthProvider implements AutoCloseable { public abstract class AuthProvider implements AutoCloseable {
public static ProviderMap<AuthProvider> providers = new ProviderMap<>("AuthProvider"); public static ProviderMap<AuthProvider> providers = new ProviderMap<>("AuthProvider");
private static boolean registredProv = false; private static boolean registredProv = false;
protected transient LaunchServer srv = null;
public static AuthProviderResult authError(String message) throws AuthException { public static AuthProviderResult authError(String message) throws AuthException {
throw new AuthException(message); throw new AuthException(message);
} }
@ -34,7 +35,7 @@ public void preAuth(String login, String password, String customText, String ip)
@Override @Override
public abstract void close() throws IOException; public abstract void close() throws IOException;
public void init() { public void init(LaunchServer srv) {
this.srv = srv;
} }
} }

View file

@ -9,10 +9,10 @@ public class AuthProviderResult {
public final String accessToken; public final String accessToken;
public final ClientPermissions permissions; public final ClientPermissions permissions;
public AuthProviderResult(String username, String accessToken) { public AuthProviderResult(String username, String accessToken, LaunchServer server) {
this.username = username; this.username = username;
this.accessToken = accessToken; this.accessToken = accessToken;
permissions = LaunchServer.server.config.permissionsHandler.getPermissions(username); permissions = server.config.permissionsHandler.getPermissions(username);
} }
public AuthProviderResult(String username, String accessToken, ClientPermissions permissions) { public AuthProviderResult(String username, String accessToken, ClientPermissions permissions) {

View file

@ -21,7 +21,8 @@ public final class MySQLAuthProvider extends AuthProvider {
private boolean usePermission; private boolean usePermission;
@Override @Override
public void init() { public void init(LaunchServer srv) {
super.init(srv);
if (query == null) LogHelper.error("[Verify][AuthProvider] query cannot be null"); if (query == null) LogHelper.error("[Verify][AuthProvider] query cannot be null");
if (message == null) LogHelper.error("[Verify][AuthProvider] message 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"); 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 // Execute SQL query
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT); s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
try (ResultSet set = s.executeQuery()) { 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

@ -23,7 +23,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
if (whitelist != null) { if (whitelist != null) {
for (String username : whitelist) { for (String username : whitelist) {
if (login.equals(username)) { if (login.equals(username)) {
return new AuthProviderResult(login, SecurityHelper.randomStringToken()); return new AuthProviderResult(login, SecurityHelper.randomStringToken(), srv);
} }
} }
} }

View file

@ -19,7 +19,8 @@ public final class RequestAuthProvider extends AuthProvider {
private boolean usePermission; private boolean usePermission;
@Override @Override
public void init() { public void init(LaunchServer srv) {
super.init(srv);
if (url == null) LogHelper.error("[Verify][AuthProvider] url cannot be null"); if (url == null) LogHelper.error("[Verify][AuthProvider] url cannot be null");
if (response == null) LogHelper.error("[Verify][AuthProvider] response cannot be null"); if (response == null) LogHelper.error("[Verify][AuthProvider] response cannot be null");
pattern = Pattern.compile(response); pattern = Pattern.compile(response);
@ -32,7 +33,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
// Match username // Match username
Matcher matcher = pattern.matcher(currentResponse); Matcher matcher = pattern.matcher(currentResponse);
return matcher.matches() && matcher.groupCount() >= 1 ? 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); authError(currentResponse);
} }

View file

@ -71,7 +71,7 @@ public void genWords(boolean force) throws IOException {
SecureRandom rand = SecurityHelper.newRandom(); SecureRandom rand = SecurityHelper.newRandom();
rand.setSeed(SecureRandom.getSeed(32)); rand.setSeed(SecureRandom.getSeed(32));
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(IOHelper.newOutput(words), IOHelper.UNICODE_CHARSET))) { 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 lowName = projectName.toLowerCase();
String upName = projectName.toUpperCase(); String upName = projectName.toUpperCase();
for (int i = 0; i < Short.MAX_VALUE; i++) out.println(generateString(rand, lowName, upName, 3)); for (int i = 0; i < Short.MAX_VALUE; i++) out.println(generateString(rand, lowName, upName, 3));

View file

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

View file

@ -48,8 +48,7 @@
import pro.gravit.utils.command.basic.HelpCommand; import pro.gravit.utils.command.basic.HelpCommand;
public abstract class CommandHandler extends pro.gravit.utils.command.CommandHandler { public abstract class CommandHandler extends pro.gravit.utils.command.CommandHandler {
public static void registerCommands(pro.gravit.utils.command.CommandHandler handler) { public static void registerCommands(pro.gravit.utils.command.CommandHandler handler, LaunchServer server) {
LaunchServer server = LaunchServer.server;
BaseCommandCategory basic = new BaseCommandCategory(); BaseCommandCategory basic = new BaseCommandCategory();
// Register basic commands // Register basic commands
basic.registerCommand("help", new HelpCommand(handler)); basic.registerCommand("help", new HelpCommand(handler));

View file

@ -21,6 +21,6 @@ public String getUsageDescription() {
@Override @Override
public void invoke(String... args) throws Exception { public void invoke(String... args) throws Exception {
LogHelper.info("You publickey modulus: %s", LaunchServer.server.publicKey.getModulus().toString(16)); LogHelper.info("You publickey modulus: %s", server.publicKey.getModulus().toString(16));
} }
} }

View file

@ -9,10 +9,11 @@
public class CommandRemoverComponent extends Component implements AutoCloseable { public class CommandRemoverComponent extends Component implements AutoCloseable {
public String[] removeList = new String[]{}; public String[] removeList = new String[]{};
public transient Map<String, Command> commandsList = new HashMap<>(); public transient Map<String, Command> commandsList = new HashMap<>();
private transient LaunchServer server = null;
@Override @Override
public void preInit(LaunchServer launchServer) { public void preInit(LaunchServer launchServer) {
server = launchServer;
} }
@Override @Override
@ -32,7 +33,7 @@ public void postInit(LaunchServer launchServer) {
@Override @Override
public void close() { public void close() {
for (Map.Entry<String, Command> e : commandsList.entrySet()) { for (Map.Entry<String, Command> e : commandsList.entrySet()) {
LaunchServer.server.commandHandler.registerCommand(e.getKey(), e.getValue()); server.commandHandler.registerCommand(e.getKey(), e.getValue());
} }
} }
} }

View file

@ -38,10 +38,10 @@ public void up() {
timestamp = System.currentTimeMillis(); timestamp = System.currentTimeMillis();
} }
public void updateAuth() { public void updateAuth(LaunchServer server) {
if (!isAuth) return; if (!isAuth) return;
if (auth_id.isEmpty()) auth = LaunchServer.server.config.getAuthProviderPair(); if (auth_id.isEmpty()) auth = server.config.getAuthProviderPair();
else auth = LaunchServer.server.config.getAuthProviderPair(auth_id); else auth = server.config.getAuthProviderPair(auth_id);
} }
public enum Type { public enum Type {

View file

@ -26,10 +26,11 @@ public class LauncherNettyServer implements AutoCloseable {
public final ServerBootstrap serverBootstrap; public final ServerBootstrap serverBootstrap;
public final EventLoopGroup bossGroup; public final EventLoopGroup bossGroup;
public final EventLoopGroup workerGroup; public final EventLoopGroup workerGroup;
public WebSocketFrameHandler frameHandler = null;
private static final String WEBSOCKET_PATH = "/api"; private static final String WEBSOCKET_PATH = "/api";
public LauncherNettyServer() { public LauncherNettyServer(LaunchServer server) {
LaunchServer.NettyConfig config = LaunchServer.server.config.netty; LaunchServer.NettyConfig config = server.config.netty;
bossGroup = new NioEventLoopGroup(config.performance.bossThread); bossGroup = new NioEventLoopGroup(config.performance.bossThread);
workerGroup = new NioEventLoopGroup(config.performance.workerThread); workerGroup = new NioEventLoopGroup(config.performance.workerThread);
serverBootstrap = new ServerBootstrap(); serverBootstrap = new ServerBootstrap();
@ -44,13 +45,14 @@ public void initChannel(NioSocketChannel ch) {
//p.addLast(new LoggingHandler(LogLevel.INFO)); //p.addLast(new LoggingHandler(LogLevel.INFO));
pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(65536)); pipeline.addLast(new HttpObjectAggregator(65536));
if (LaunchServer.server.config.netty.ipForwarding) if (server.config.netty.ipForwarding)
pipeline.addLast(new NettyIpForwardHandler(context)); pipeline.addLast(new NettyIpForwardHandler(context));
pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerCompressionHandler());
pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true)); pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true));
if (LaunchServer.server.config.netty.fileServerEnabled) if (server.config.netty.fileServerEnabled)
pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true)); pipeline.addLast(new FileServerHandler(server.updatesDir, true));
pipeline.addLast(new WebSocketFrameHandler(context)); frameHandler = new WebSocketFrameHandler(context, server);
pipeline.addLast(frameHandler);
} }
}); });
if (config.proxy != null && config.proxy.enabled) { if (config.proxy != null && config.proxy.enabled) {

View file

@ -33,11 +33,11 @@
@SuppressWarnings({"unused", "rawtypes"}) @SuppressWarnings({"unused", "rawtypes"})
public final class NettyServerSocketHandler implements Runnable, AutoCloseable { public final class NettyServerSocketHandler implements Runnable, AutoCloseable {
private static SSLServerSocketFactory ssf; private SSLServerSocketFactory ssf;
public volatile boolean logConnections = Boolean.getBoolean("launcher.logConnections"); public volatile boolean logConnections = Boolean.getBoolean("launcher.logConnections");
public static LauncherNettyServer nettyServer; public LauncherNettyServer nettyServer;
private final AtomicReference<ServerSocket> serverSocket = new AtomicReference<>(); private final AtomicReference<ServerSocket> serverSocket = new AtomicReference<>();
@ -47,9 +47,10 @@ public final class NettyServerSocketHandler implements Runnable, AutoCloseable {
private Set<Socket> sockets; private Set<Socket> sockets;
private volatile Listener listener; private volatile Listener listener;
private transient final LaunchServer server;
public NettyServerSocketHandler(LaunchServer server) { public NettyServerSocketHandler(LaunchServer server) {
// Instance this.server = server;
LaunchServer server1 = server;
} }
@Override @Override
@ -109,9 +110,8 @@ public void run() {
LogHelper.info("Starting netty server socket thread"); LogHelper.info("Starting netty server socket thread");
//SSLEngine engine = sc.createSSLEngine(); //SSLEngine engine = sc.createSSLEngine();
//engine.setUseClientMode(false); //engine.setUseClientMode(false);
WebSocketFrameHandler.server = LaunchServer.server; nettyServer = new LauncherNettyServer(server);
nettyServer = new LauncherNettyServer(); for (LaunchServer.NettyBindAddress address : server.config.netty.binds) {
for (LaunchServer.NettyBindAddress address : LaunchServer.server.config.netty.binds) {
nettyServer.bind(new InetSocketAddress(address.address, address.port)); nettyServer.bind(new InetSocketAddress(address.address, address.port));
} }
/* /*

View file

@ -20,19 +20,21 @@
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocketFrame> { public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocketFrame> {
public static LaunchServer server; public final LaunchServer srv;
public static GsonBuilder builder = CommonHelper.newBuilder(); public static GsonBuilder builder = CommonHelper.newBuilder();
public static WebSocketService service = new WebSocketService(new DefaultChannelGroup(GlobalEventExecutor.INSTANCE), LaunchServer.server, builder); public final WebSocketService service;
public NettyConnectContext context; public NettyConnectContext context;
public WebSocketFrameHandler(NettyConnectContext context) { public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv) {
this.context = context; this.context = context;
this.srv = srv;
service = new WebSocketService(new DefaultChannelGroup(GlobalEventExecutor.INSTANCE), srv, builder);
service.registerResponses();
} }
private Client client; private Client client;
static { static {
service.registerResponses();
} }
public void setClient(Client client) { public void setClient(Client client) {

View file

@ -2,7 +2,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.ExecCommandRequestEvent; import pro.gravit.launcher.events.request.ExecCommandRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -20,7 +19,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
sendError("Access denied"); sendError("Access denied");
return; return;
} }
LaunchServer.server.commandHandler.eval(cmd, false); server.commandHandler.eval(cmd, false);
sendResult(new ExecCommandRequestEvent(true)); sendResult(new ExecCommandRequestEvent(true));
} }
} }

View file

@ -12,7 +12,6 @@
import pro.gravit.launcher.OshiHWID; import pro.gravit.launcher.OshiHWID;
import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.events.request.AuthRequestEvent;
import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.auth.hwid.HWIDException; import pro.gravit.launchserver.auth.hwid.HWIDException;
@ -68,13 +67,13 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
} }
if (password == null) { if (password == null) {
try { try {
password = IOHelper.decode(SecurityHelper.newRSADecryptCipher(LaunchServer.server.privateKey). password = IOHelper.decode(SecurityHelper.newRSADecryptCipher(server.privateKey).
doFinal(encryptedPassword)); doFinal(encryptedPassword));
} catch (IllegalBlockSizeException | BadPaddingException ignored) { } catch (IllegalBlockSizeException | BadPaddingException ignored) {
throw new AuthException("Password decryption error"); throw new AuthException("Password decryption error");
} }
} }
clientData.permissions = LaunchServer.server.config.permissionsHandler.getPermissions(login); clientData.permissions = server.config.permissionsHandler.getPermissions(login);
if (authType == ConnectTypes.BOT && !clientData.permissions.canBot) { if (authType == ConnectTypes.BOT && !clientData.permissions.canBot) {
AuthProvider.authError("authType: BOT not allowed for this account"); AuthProvider.authError("authType: BOT not allowed for this account");
} }
@ -82,22 +81,22 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
AuthProvider.authError("authType: SERVER not allowed for this account"); AuthProvider.authError("authType: SERVER not allowed for this account");
} }
AuthProviderPair pair; AuthProviderPair pair;
if (auth_id.isEmpty()) pair = LaunchServer.server.config.getAuthProviderPair(); if (auth_id.isEmpty()) pair = server.config.getAuthProviderPair();
else pair = LaunchServer.server.config.getAuthProviderPair(auth_id); else pair = server.config.getAuthProviderPair(auth_id);
AuthContext context = new AuthContext(0, login, password.length(), customText, client, ip, null, false); AuthContext context = new AuthContext(0, login, password.length(), customText, client, ip, null, false);
AuthProvider provider = pair.provider; AuthProvider provider = pair.provider;
LaunchServer.server.authHookManager.preHook.hook(context, clientData); server.authHookManager.preHook.hook(context, clientData);
provider.preAuth(login, password, customText, ip); provider.preAuth(login, password, customText, ip);
AuthProviderResult aresult = provider.auth(login, password, ip); AuthProviderResult aresult = provider.auth(login, password, ip);
if (!VerifyHelper.isValidUsername(aresult.username)) { if (!VerifyHelper.isValidUsername(aresult.username)) {
AuthProvider.authError(String.format("Illegal result: '%s'", aresult.username)); AuthProvider.authError(String.format("Illegal result: '%s'", aresult.username));
return; return;
} }
Collection<ClientProfile> profiles = LaunchServer.server.getProfiles(); Collection<ClientProfile> profiles = server.getProfiles();
for (ClientProfile p : profiles) { for (ClientProfile p : profiles) {
if (p.getTitle().equals(client)) { if (p.getTitle().equals(client)) {
if (!p.isWhitelistContains(login)) { if (!p.isWhitelistContains(login)) {
throw new AuthException(LaunchServer.server.config.whitelistRejectString); throw new AuthException(server.config.whitelistRejectString);
} }
clientData.profile = p; clientData.profile = p;
} }
@ -106,18 +105,18 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
// throw new AuthException("You profile not found"); // throw new AuthException("You profile not found");
//} //}
if (authType == ConnectTypes.CLIENT) if (authType == ConnectTypes.CLIENT)
LaunchServer.server.config.hwidHandler.check(hwid, aresult.username); server.config.hwidHandler.check(hwid, aresult.username);
LaunchServer.server.authHookManager.postHook.hook(context, clientData); server.authHookManager.postHook.hook(context, clientData);
clientData.isAuth = true; clientData.isAuth = true;
clientData.permissions = aresult.permissions; clientData.permissions = aresult.permissions;
clientData.auth_id = auth_id; clientData.auth_id = auth_id;
clientData.updateAuth(); clientData.updateAuth(server);
result.accessToken = aresult.accessToken; result.accessToken = aresult.accessToken;
result.permissions = clientData.permissions; result.permissions = clientData.permissions;
if (getSession) { if (getSession) {
if (clientData.session == 0) { if (clientData.session == 0) {
clientData.session = random.nextLong(); clientData.session = random.nextLong();
LaunchServer.server.sessionManager.addClient(clientData); server.sessionManager.addClient(clientData);
} }
result.session = clientData.session; result.session = clientData.session;
} }
@ -125,9 +124,9 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
if (!clientData.permissions.canProxy) throw new AuthException("initProxy not allow"); if (!clientData.permissions.canProxy) throw new AuthException("initProxy not allow");
clientData.proxy = true; clientData.proxy = true;
} }
if (LaunchServer.server.config.protectHandler.allowGetAccessToken(context)) { if (server.config.protectHandler.allowGetAccessToken(context)) {
UUID uuid = pair.handler.auth(aresult); UUID uuid = pair.handler.auth(aresult);
result.playerProfile = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, aresult.username, client, clientData.auth.textureProvider); result.playerProfile = ProfileByUUIDResponse.getProfile(server, uuid, aresult.username, client, clientData.auth.textureProvider);
LogHelper.debug("Auth: %s accessToken %s uuid: %s", login, result.accessToken, uuid.toString()); LogHelper.debug("Auth: %s accessToken %s uuid: %s", login, result.accessToken, uuid.toString());
} }
sendResult(result); sendResult(result);

View file

@ -2,7 +2,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.CheckServerRequestEvent; import pro.gravit.launcher.events.request.CheckServerRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -27,7 +26,7 @@ public void execute(ChannelHandlerContext ctx, Client pClient) {
server.authHookManager.checkServerHook.hook(this, pClient); server.authHookManager.checkServerHook.hook(this, pClient);
result.uuid = pClient.auth.handler.checkServer(username, serverID); result.uuid = pClient.auth.handler.checkServer(username, serverID);
if (result.uuid != null) if (result.uuid != null)
result.playerProfile = ProfileByUUIDResponse.getProfile(LaunchServer.server, result.uuid, username, client, pClient.auth.textureProvider); result.playerProfile = ProfileByUUIDResponse.getProfile(server, result.uuid, username, client, pClient.auth.textureProvider);
LogHelper.debug("checkServer: %s uuid: %s serverID: %s", result.playerProfile.username, result.uuid.toString(), serverID); LogHelper.debug("checkServer: %s uuid: %s serverID: %s", result.playerProfile.username, result.uuid.toString(), serverID);
} catch (AuthException | HookException e) { } catch (AuthException | HookException e) {
sendError(e.getMessage()); sendError(e.getMessage());

View file

@ -5,7 +5,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent; import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -19,7 +18,7 @@ public String getType() {
@Override @Override
public void execute(ChannelHandlerContext ctx, Client client) { public void execute(ChannelHandlerContext ctx, Client client) {
List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>(); List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>();
for (AuthProviderPair pair : LaunchServer.server.config.auth) { for (AuthProviderPair pair : server.config.auth) {
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName)); list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName));
} }
sendResult(new GetAvailabilityAuthRequestEvent(list)); sendResult(new GetAvailabilityAuthRequestEvent(list));

View file

@ -2,7 +2,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.JoinServerRequestEvent; import pro.gravit.launcher.events.request.JoinServerRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -26,7 +25,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
server.authHookManager.joinServerHook.hook(this, client); server.authHookManager.joinServerHook.hook(this, client);
if (client.auth == null) { if (client.auth == null) {
LogHelper.warning("Client auth is null. Using default."); LogHelper.warning("Client auth is null. Using default.");
success = LaunchServer.server.config.getAuthProviderPair().handler.joinServer(username, accessToken, serverID); success = server.config.getAuthProviderPair().handler.joinServer(username, accessToken, serverID);
} else success = client.auth.handler.joinServer(username, accessToken, serverID); } else success = client.auth.handler.joinServer(username, accessToken, serverID);
LogHelper.debug("joinServer: %s accessToken: %s serverID: %s", username, accessToken, serverID); LogHelper.debug("joinServer: %s accessToken: %s serverID: %s", username, accessToken, serverID);
} catch (AuthException | HookException e) { } catch (AuthException | HookException e) {

View file

@ -3,7 +3,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.events.request.ErrorRequestEvent;
import pro.gravit.launcher.events.request.ProfilesRequestEvent; import pro.gravit.launcher.events.request.ProfilesRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -19,6 +18,6 @@ public void execute(ChannelHandlerContext ctx, Client client) {
service.sendObject(ctx, new ErrorRequestEvent("Access denied")); service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
return; return;
} }
sendResult(new ProfilesRequestEvent(LaunchServer.server.getProfiles())); sendResult(new ProfilesRequestEvent(server.getProfiles()));
} }
} }

View file

@ -3,7 +3,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.LauncherNetworkAPI; import pro.gravit.launcher.LauncherNetworkAPI;
import pro.gravit.launcher.events.request.RestoreSessionRequestEvent; import pro.gravit.launcher.events.request.RestoreSessionRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.WebSocketFrameHandler; import pro.gravit.launchserver.websocket.WebSocketFrameHandler;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -19,7 +18,7 @@ public String getType() {
@Override @Override
public void execute(ChannelHandlerContext ctx, Client client) { public void execute(ChannelHandlerContext ctx, Client client) {
Client rClient = LaunchServer.server.sessionManager.getClient(session); Client rClient = server.sessionManager.getClient(session);
if (rClient == null) { if (rClient == null) {
sendError("Session invalid"); sendError("Session invalid");
} }

View file

@ -5,7 +5,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.SetProfileRequestEvent; import pro.gravit.launcher.events.request.SetProfileRequestEvent;
import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
import pro.gravit.utils.HookException; import pro.gravit.utils.HookException;
@ -29,11 +28,11 @@ public void execute(ChannelHandlerContext ctx, Client client) {
} catch (HookException e) { } catch (HookException e) {
sendError(e.getMessage()); sendError(e.getMessage());
} }
Collection<ClientProfile> profiles = LaunchServer.server.getProfiles(); Collection<ClientProfile> profiles = server.getProfiles();
for (ClientProfile p : profiles) { for (ClientProfile p : profiles) {
if (p.getTitle().equals(this.client)) { if (p.getTitle().equals(this.client)) {
if (!p.isWhitelistContains(client.username)) { if (!p.isWhitelistContains(client.username)) {
sendError(LaunchServer.server.config.whitelistRejectString); sendError(server.config.whitelistRejectString);
return; return;
} }
client.profile = p; client.profile = p;

View file

@ -5,7 +5,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent; import pro.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent;
import pro.gravit.launcher.profiles.PlayerProfile; import pro.gravit.launcher.profiles.PlayerProfile;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
@ -31,9 +30,9 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
UUID uuid; UUID uuid;
if (client.auth == null) { if (client.auth == null) {
LogHelper.warning("Client auth is null. Using default."); LogHelper.warning("Client auth is null. Using default.");
uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(list[i].username); uuid = server.config.getAuthProviderPair().handler.usernameToUUID(list[i].username);
} else uuid = client.auth.handler.usernameToUUID(list[i].username); } else uuid = client.auth.handler.usernameToUUID(list[i].username);
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, list[i].username, list[i].client, client.auth.textureProvider); result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(server, uuid, list[i].username, list[i].client, client.auth.textureProvider);
} }
sendResult(result); sendResult(result);
} }

View file

@ -50,8 +50,8 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
String username; String username;
if (client.auth == null) { if (client.auth == null) {
LogHelper.warning("Client auth is null. Using default."); LogHelper.warning("Client auth is null. Using default.");
username = LaunchServer.server.config.getAuthProviderPair().handler.uuidToUsername(uuid); username = server.config.getAuthProviderPair().handler.uuidToUsername(uuid);
} else username = client.auth.handler.uuidToUsername(uuid); } else username = client.auth.handler.uuidToUsername(uuid);
sendResult(new ProfileByUUIDRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider))); sendResult(new ProfileByUUIDRequestEvent(getProfile(server, uuid, username, this.client, client.auth.textureProvider)));
} }
} }

View file

@ -4,7 +4,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent; import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
@ -23,8 +22,8 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
UUID uuid; UUID uuid;
if (client.auth == null) { if (client.auth == null) {
LogHelper.warning("Client auth is null. Using default."); LogHelper.warning("Client auth is null. Using default.");
uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(username); uuid = server.config.getAuthProviderPair().handler.usernameToUUID(username);
} else uuid = client.auth.handler.usernameToUUID(username); } else uuid = client.auth.handler.usernameToUUID(username);
sendResult(new ProfileByUsernameRequestEvent(ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider))); sendResult(new ProfileByUsernameRequestEvent(ProfileByUUIDResponse.getProfile(server, uuid, username, this.client, client.auth.textureProvider)));
} }
} }

View file

@ -2,7 +2,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.GetSecureTokenRequestEvent; import pro.gravit.launcher.events.request.GetSecureTokenRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -14,7 +13,7 @@ public String getType() {
@Override @Override
public void execute(ChannelHandlerContext ctx, Client client) { public void execute(ChannelHandlerContext ctx, Client client) {
String secureToken = LaunchServer.server.config.protectHandler.generateClientSecureToken(); String secureToken = server.config.protectHandler.generateClientSecureToken();
client.verifyToken = secureToken; client.verifyToken = secureToken;
sendResult(new GetSecureTokenRequestEvent(secureToken)); sendResult(new GetSecureTokenRequestEvent(secureToken));
} }

View file

@ -2,7 +2,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.VerifySecureTokenRequestEvent; import pro.gravit.launcher.events.request.VerifySecureTokenRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -16,7 +15,7 @@ public String getType() {
@Override @Override
public void execute(ChannelHandlerContext ctx, Client client) { public void execute(ChannelHandlerContext ctx, Client client) {
boolean success = LaunchServer.server.config.protectHandler.verifyClientSecureToken(secureToken, client.verifyToken); boolean success = server.config.protectHandler.verifyClientSecureToken(secureToken, client.verifyToken);
if (success) client.isSecure = true; if (success) client.isSecure = true;
sendResult(new VerifySecureTokenRequestEvent(success)); sendResult(new VerifySecureTokenRequestEvent(success));
} }

View file

@ -5,7 +5,6 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import pro.gravit.launcher.events.request.LauncherRequestEvent; import pro.gravit.launcher.events.request.LauncherRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
import pro.gravit.utils.Version; import pro.gravit.utils.Version;
@ -15,9 +14,6 @@ public class LauncherResponse extends SimpleResponse {
public String hash; public String hash;
public byte[] digest; public byte[] digest;
public int launcher_type; public int launcher_type;
//REPLACED TO REAL URL
public static final String JAR_URL = LaunchServer.server.config.netty.launcherURL;
public static final String EXE_URL = LaunchServer.server.config.netty.launcherEXEURL;
@Override @Override
public String getType() { public String getType() {
@ -33,23 +29,23 @@ public void execute(ChannelHandlerContext ctx, Client client) {
bytes = digest; bytes = digest;
if (launcher_type == 1) // JAR if (launcher_type == 1) // JAR
{ {
byte[] hash = LaunchServer.server.launcherBinary.getBytes().getDigest(); byte[] hash = server.launcherBinary.getBytes().getDigest();
if (hash == null) service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, JAR_URL)); if (hash == null) service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, server.config.netty.launcherURL));
if (Arrays.equals(bytes, hash)) { if (Arrays.equals(bytes, hash)) {
client.checkSign = true; client.checkSign = true;
sendResult(new LauncherRequestEvent(false, JAR_URL)); sendResult(new LauncherRequestEvent(false, server.config.netty.launcherURL));
} else { } else {
sendResultAndClose(new LauncherRequestEvent(true, JAR_URL)); sendResultAndClose(new LauncherRequestEvent(true, server.config.netty.launcherURL));
} }
} else if (launcher_type == 2) //EXE } else if (launcher_type == 2) //EXE
{ {
byte[] hash = LaunchServer.server.launcherEXEBinary.getBytes().getDigest(); byte[] hash = server.launcherEXEBinary.getBytes().getDigest();
if (hash == null) sendResultAndClose(new LauncherRequestEvent(true, EXE_URL)); if (hash == null) sendResultAndClose(new LauncherRequestEvent(true, server.config.netty.launcherEXEURL));
if (Arrays.equals(bytes, hash)) { if (Arrays.equals(bytes, hash)) {
client.checkSign = true; client.checkSign = true;
sendResult(new LauncherRequestEvent(false, EXE_URL)); sendResult(new LauncherRequestEvent(false, server.config.netty.launcherEXEURL));
} else { } else {
sendResultAndClose(new LauncherRequestEvent(true, EXE_URL)); sendResultAndClose(new LauncherRequestEvent(true, server.config.netty.launcherEXEURL));
} }
} else sendError("Request launcher type error"); } else sendError("Request launcher type error");

View file

@ -7,7 +7,6 @@
import pro.gravit.launcher.events.request.UpdateListRequestEvent; import pro.gravit.launcher.events.request.UpdateListRequestEvent;
import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.launcher.serialize.signed.SignedObjectHolder; import pro.gravit.launcher.serialize.signed.SignedObjectHolder;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.websocket.json.SimpleResponse; import pro.gravit.launchserver.websocket.json.SimpleResponse;
@ -25,7 +24,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
return; return;
} }
HashSet<String> set = new HashSet<>(); HashSet<String> set = new HashSet<>();
for (Map.Entry<String, SignedObjectHolder<HashedDir>> entry : LaunchServer.server.updatesDirMap.entrySet()) for (Map.Entry<String, SignedObjectHolder<HashedDir>> entry : server.updatesDirMap.entrySet())
set.add(entry.getKey()); set.add(entry.getKey());
sendResult(new UpdateListRequestEvent(set)); sendResult(new UpdateListRequestEvent(set));
} }

View file

@ -25,7 +25,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
return; return;
} }
if (!client.permissions.canAdmin) { if (!client.permissions.canAdmin) {
for (ClientProfile p : LaunchServer.server.getProfiles()) { for (ClientProfile p : server.getProfiles()) {
if (!client.profile.getTitle().equals(p.getTitle())) continue; if (!client.profile.getTitle().equals(p.getTitle())) continue;
if (!p.isWhitelistContains(client.username)) { if (!p.isWhitelistContains(client.username)) {
service.sendObject(ctx, new ErrorRequestEvent("You don't download this folder")); service.sendObject(ctx, new ErrorRequestEvent("You don't download this folder"));
@ -33,12 +33,12 @@ public void execute(ChannelHandlerContext ctx, Client client) {
} }
} }
} }
SignedObjectHolder<HashedDir> dir = LaunchServer.server.updatesDirMap.get(dirName); SignedObjectHolder<HashedDir> dir = server.updatesDirMap.get(dirName);
if (dir == null) { if (dir == null) {
service.sendObject(ctx, new ErrorRequestEvent(String.format("Directory %s not found", dirName))); service.sendObject(ctx, new ErrorRequestEvent(String.format("Directory %s not found", dirName)));
return; return;
} }
String url = LaunchServer.server.config.netty.downloadURL.replace("%dirname%", dirName); String url = server.config.netty.downloadURL.replace("%dirname%", dirName);
boolean zip = false; boolean zip = false;
if (server.config.netty.bindings.get(dirName) != null) { if (server.config.netty.bindings.get(dirName) != null) {
LaunchServer.NettyUpdatesBind bind = server.config.netty.bindings.get(dirName); LaunchServer.NettyUpdatesBind bind = server.config.netty.bindings.get(dirName);