[FEATURE] Поддержка requestUUID ля определения к какому запросу принадлежит ответ

This commit is contained in:
Gravit 2019-04-20 03:23:54 +07:00
parent 3a160659d4
commit 58858a0290
40 changed files with 166 additions and 95 deletions

View file

@ -16,6 +16,7 @@
import ru.gravit.launchserver.websocket.json.EchoResponse;
import ru.gravit.launchserver.websocket.json.JsonResponseAdapter;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.launchserver.websocket.json.admin.AddLogListenerResponse;
import ru.gravit.launchserver.websocket.json.admin.ExecCommandResponse;
import ru.gravit.launchserver.websocket.json.auth.*;
@ -54,8 +55,15 @@ public WebSocketService(ChannelGroup channels, LaunchServer server, GsonBuilder
void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client) {
String request = frame.text();
JsonResponseInterface response = gson.fromJson(request, JsonResponseInterface.class);
if(response instanceof SimpleResponse)
{
SimpleResponse simpleResponse = (SimpleResponse) response;
simpleResponse.server = server;
simpleResponse.service = this;
simpleResponse.ctx = ctx;
}
try {
response.execute(this, ctx, client);
response.execute(ctx, client);
} catch (Exception e) {
LogHelper.error(e);
sendObject(ctx, new ExceptionResult(e));

View file

@ -6,7 +6,7 @@
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.utils.helper.LogHelper;
public class EchoResponse implements JsonResponseInterface {
public class EchoResponse extends SimpleResponse {
public final String echo;
public EchoResponse(String echo) {
@ -19,9 +19,8 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) {
LogHelper.info("Echo: %s, isAuth %s", echo, client.isAuth ? "true" : "false");
service.sendObject(ctx, new EchoRequestEvent(echo));
}
}

View file

@ -7,5 +7,5 @@
public interface JsonResponseInterface {
String getType();
void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception;
void execute(ChannelHandlerContext ctx, Client client) throws Exception;
}

View file

@ -1,17 +1,39 @@
package ru.gravit.launchserver.websocket.json;
import io.netty.channel.ChannelHandlerContext;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.events.request.ErrorRequestEvent;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
public class SimpleResponse implements JsonResponseInterface {
@Override
public String getType() {
return null;
import java.util.UUID;
public abstract class SimpleResponse implements JsonResponseInterface {
public UUID requestUUID;
public transient LaunchServer server;
public transient WebSocketService service;
public transient ChannelHandlerContext ctx;
public void sendResult(RequestEvent result)
{
result.requestUUID = requestUUID;
service.sendObject(ctx, result);
}
public void sendResultAndClose(RequestEvent result)
{
result.requestUUID = requestUUID;
service.sendObjectAndClose(ctx, result);
}
public void sendError(String errorMessage)
{
ErrorRequestEvent event = new ErrorRequestEvent(errorMessage);
event.requestUUID = requestUUID;
service.sendObject(ctx, event);
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
}
}

View file

@ -5,10 +5,10 @@
import ru.gravit.launcher.events.request.LogEvent;
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.utils.helper.LogHelper;
public class AddLogListenerResponse implements JsonResponseInterface {
public class AddLogListenerResponse extends SimpleResponse {
public LogHelper.OutputTypes outputType = LogHelper.OutputTypes.PLAIN;
@Override
@ -17,13 +17,13 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
if (!client.isAuth) {
service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
sendError("Access denied");
return;
}
if (!client.permissions.canAdmin) {
service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
sendError("Access denied");
return;
}
if (client.logOutput != null) {

View file

@ -7,8 +7,9 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
public class ExecCommandResponse implements JsonResponseInterface {
public class ExecCommandResponse extends SimpleResponse {
public String cmd;
@Override
@ -17,12 +18,12 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) {
if (!client.isAuth || !client.permissions.canAdmin) {
service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
sendError("Access denied");
return;
}
LaunchServer.server.commandHandler.eval(cmd, false);
service.sendObject(ctx, new ExecCommandRequestEvent(true));
sendResult(new ExecCommandRequestEvent(true));
}
}

View file

@ -14,6 +14,7 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
@ -27,7 +28,7 @@
import java.util.Random;
import java.util.UUID;
public class AuthResponse implements JsonResponseInterface {
public class AuthResponse extends SimpleResponse {
public transient static Random random = new SecureRandom();
public String login;
public String client;
@ -58,7 +59,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client clientData) throws Exception {
public void execute(ChannelHandlerContext ctx, Client clientData) throws Exception {
try {
AuthRequestEvent result = new AuthRequestEvent();
String ip = IOHelper.getIP(ctx.channel().remoteAddress());
@ -126,9 +127,9 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
result.playerProfile = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, aresult.username, client, clientData.auth.textureProvider);
LogHelper.debug("Auth: %s accessToken %s uuid: %s", login, result.accessToken, uuid.toString());
}
service.sendObject(ctx, result);
sendResult(result);
} catch (AuthException | HWIDException e) {
service.sendObject(ctx, new ErrorRequestEvent(e.getMessage()));
sendError(e.getMessage());
}
}
public static class AuthContext {

View file

@ -8,10 +8,11 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse;
import ru.gravit.utils.helper.LogHelper;
public class CheckServerResponse implements JsonResponseInterface {
public class CheckServerResponse extends SimpleResponse {
public String serverID;
public String username;
public String client;
@ -22,7 +23,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client pClient) {
public void execute(ChannelHandlerContext ctx, Client pClient) {
CheckServerRequestEvent result = new CheckServerRequestEvent();
try {
result.uuid = pClient.auth.handler.checkServer(username, serverID);
@ -30,14 +31,14 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
result.playerProfile = ProfileByUUIDResponse.getProfile(LaunchServer.server, result.uuid, username, client, pClient.auth.textureProvider);
LogHelper.debug("checkServer: %s uuid: %s serverID: %s", result.playerProfile.username, result.uuid.toString(), serverID);
} catch (AuthException e) {
service.sendObject(ctx, new ErrorRequestEvent(e.getMessage()));
sendError(e.getMessage());
return;
} catch (Exception e) {
LogHelper.error(e);
service.sendObject(ctx, new ErrorRequestEvent("Internal authHandler error"));
sendError("Internal authHandler error");
return;
}
service.sendObject(ctx, result);
sendResult(result);
}
}

View file

@ -7,23 +7,24 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import java.util.ArrayList;
import java.util.List;
public class GetAvailabilityAuthResponse implements JsonResponseInterface {
public class GetAvailabilityAuthResponse extends SimpleResponse {
@Override
public String getType() {
return "getAvailabilityAuth";
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>();
for(AuthProviderPair pair : LaunchServer.server.config.auth)
{
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName));
}
service.sendObject(ctx, new GetAvailabilityAuthRequestEvent(list));
sendResult(new GetAvailabilityAuthRequestEvent(list));
}
}

View file

@ -8,9 +8,10 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.utils.helper.LogHelper;
public class JoinServerResponse implements JsonResponseInterface {
public class JoinServerResponse extends SimpleResponse {
public String serverID;
public String accessToken;
public String username;
@ -21,7 +22,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) {
boolean success;
try {
if(client.auth == null)
@ -32,14 +33,14 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
else success = client.auth.handler.joinServer(username, accessToken, serverID);
LogHelper.debug("joinServer: %s accessToken: %s serverID: %s", username, accessToken, serverID);
} catch (AuthException e) {
service.sendObject(ctx, new ErrorRequestEvent(e.getMessage()));
sendError(e.getMessage());
return;
} catch (Exception e) {
LogHelper.error(e);
service.sendObject(ctx, new ErrorRequestEvent("Internal authHandler error"));
sendError("Internal authHandler error");
return;
}
service.sendObject(ctx, new JoinServerRequestEvent(success));
sendResult(new JoinServerRequestEvent(success));
}
}

View file

@ -8,21 +8,22 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import java.util.List;
public class ProfilesResponse implements JsonResponseInterface {
public class ProfilesResponse extends SimpleResponse {
@Override
public String getType() {
return "profiles";
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
if (!client.checkSign && !client.isAuth) {
service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
return;
}
service.sendObject(ctx, new ProfilesRequestEvent((List<ClientProfile>) LaunchServer.server.getProfiles()));
sendResult(new ProfilesRequestEvent(LaunchServer.server.getProfiles()));
}
}

View file

@ -9,8 +9,9 @@
import ru.gravit.launchserver.websocket.WebSocketFrameHandler;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
public class RestoreSessionResponse implements JsonResponseInterface {
public class RestoreSessionResponse extends SimpleResponse {
@LauncherNetworkAPI
public long session;
@Override
@ -19,14 +20,14 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
Client rClient = LaunchServer.server.sessionManager.getClient(session);
if(rClient == null)
{
service.sendObject(ctx, new ErrorRequestEvent("Session invalid"));
sendError("Session invalid");
}
WebSocketFrameHandler frameHandler = ctx.pipeline().get(WebSocketFrameHandler.class);
frameHandler.setClient(rClient);
service.sendObject(ctx, new RestoreSessionRequestEvent());
sendResult(new RestoreSessionRequestEvent());
}
}

View file

@ -8,10 +8,11 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import java.util.Collection;
public class SetProfileResponse implements JsonResponseInterface {
public class SetProfileResponse extends SimpleResponse {
public String client;
@Override
@ -20,23 +21,23 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
if (!client.isAuth) {
service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
sendError("Access denied");
return;
}
Collection<ClientProfile> profiles = LaunchServer.server.getProfiles();
for (ClientProfile p : profiles) {
if (p.getTitle().equals(this.client)) {
if (!p.isWhitelistContains(client.username)) {
service.sendObject(ctx, new ErrorRequestEvent(LaunchServer.server.config.whitelistRejectString));
sendError(LaunchServer.server.config.whitelistRejectString);
return;
}
client.profile = p;
service.sendObject(ctx, new SetProfileRequestEvent(p));
sendResult(new SetProfileRequestEvent(p));
return;
}
}
service.sendObject(ctx, new ErrorRequestEvent("Profile not found"));
sendError("Profile not found");
}
}

View file

@ -7,11 +7,12 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.utils.helper.LogHelper;
import java.util.UUID;
public class BatchProfileByUsername implements JsonResponseInterface {
public class BatchProfileByUsername extends SimpleResponse {
class Entry {
String username;
String client;
@ -25,7 +26,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent();
result.playerProfiles = new PlayerProfile[list.length];
for (int i = 0; i < list.length; ++i) {
@ -38,6 +39,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
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);
}
service.sendObject(ctx, result);
sendResult(result);
}
}

View file

@ -9,12 +9,13 @@
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.auth.texture.TextureProvider;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException;
import java.util.UUID;
public class ProfileByUUIDResponse implements JsonResponseInterface {
public class ProfileByUUIDResponse extends SimpleResponse {
public UUID uuid;
public String client;
@ -47,7 +48,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
String username;
if(client.auth == null)
{
@ -55,6 +56,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
username = LaunchServer.server.config.getAuthProviderPair().handler.uuidToUsername(uuid);
}
else username = client.auth.handler.uuidToUsername(uuid);
service.sendObject(ctx, new ProfileByUUIDRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider)));
sendResult(new ProfileByUUIDRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider)));
}
}

View file

@ -6,13 +6,14 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.utils.helper.LogHelper;
import java.util.UUID;
import static ru.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse.getProfile;
public class ProfileByUsername implements JsonResponseInterface {
public class ProfileByUsername extends SimpleResponse {
String username;
String client;
@ -22,7 +23,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
UUID uuid;
if(client.auth == null)
{
@ -30,6 +31,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(username);
}
else uuid = client.auth.handler.usernameToUUID(username);
service.sendObject(ctx, new ProfileByUsernameRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider)));
sendResult(new ProfileByUsernameRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider)));
}
}

View file

@ -6,17 +6,18 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
public class GetSecureTokenResponse implements JsonResponseInterface {
public class GetSecureTokenResponse extends SimpleResponse {
@Override
public String getType() {
return "getSecureToken";
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
String secureToken = LaunchServer.server.config.protectHandler.generateClientSecureToken();
client.verifyToken = secureToken;
service.sendObject(ctx, new GetSecureTokenRequestEvent(secureToken));
sendResult(new GetSecureTokenRequestEvent(secureToken));
}
}

View file

@ -6,8 +6,9 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
public class VerifySecureTokenResponse implements JsonResponseInterface {
public class VerifySecureTokenResponse extends SimpleResponse {
public String secureToken;
@Override
@ -16,9 +17,9 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
boolean success = LaunchServer.server.config.protectHandler.verifyClientSecureToken(secureToken, client.verifyToken);
if(success) client.isSecure = true;
service.sendObject(ctx, new VerifySecureTokenRequestEvent(success));
sendResult(new VerifySecureTokenRequestEvent(success));
}
}

View file

@ -7,12 +7,13 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import ru.gravit.utils.Version;
import java.util.Arrays;
import java.util.Base64;
public class LauncherResponse implements JsonResponseInterface {
public class LauncherResponse extends SimpleResponse {
public Version version;
public String hash;
public byte[] digest;
@ -27,7 +28,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) {
byte[] bytes;
if (hash != null)
bytes = Base64.getDecoder().decode(hash);
@ -49,11 +50,11 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
if (hash == null) service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, EXE_URL));
if (Arrays.equals(bytes, hash)) {
client.checkSign = true;
service.sendObject(ctx, new LauncherRequestEvent(false, EXE_URL));
sendResult(new LauncherRequestEvent(false, EXE_URL));
} else {
service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, EXE_URL));
sendResultAndClose(new LauncherRequestEvent(true, EXE_URL));
}
} else service.sendObject(ctx, new ErrorRequestEvent("Request launcher type error"));
} else sendError("Request launcher type error");
}

View file

@ -9,11 +9,12 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
import java.util.HashSet;
import java.util.Map;
public class UpdateListResponse implements JsonResponseInterface {
public class UpdateListResponse extends SimpleResponse {
@Override
public String getType() {
@ -21,15 +22,15 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
public void execute(ChannelHandlerContext ctx, Client client) {
if (!client.isAuth) {
service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
sendError("Access denied");
return;
}
HashSet<String> set = new HashSet<>();
for (Map.Entry<String, SignedObjectHolder<HashedDir>> entry : LaunchServer.server.updatesDirMap.entrySet())
set.add(entry.getKey());
service.sendObject(ctx, new UpdateListRequestEvent(set));
sendResult(new UpdateListRequestEvent(set));
}
}

View file

@ -10,8 +10,9 @@
import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.websocket.json.SimpleResponse;
public class UpdateResponse implements JsonResponseInterface {
public class UpdateResponse extends SimpleResponse {
public String dirName;
@Override
@ -20,9 +21,9 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
if (!client.isAuth || client.type != Client.Type.USER || client.profile == null) {
service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
sendError("Access denied");
return;
}
if (!client.permissions.canAdmin) {

View file

@ -0,0 +1,9 @@
package ru.gravit.launcher.events;
import ru.gravit.launcher.request.ResultInterface;
import java.util.UUID;
public abstract class RequestEvent implements ResultInterface {
public UUID requestUUID;
}

View file

@ -2,13 +2,14 @@
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.profiles.PlayerProfile;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class AuthRequestEvent implements EventInterface, ResultInterface {
public class AuthRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("77e1bfd7-adf9-4f5d-87d6-a7dd068deb74");
public AuthRequestEvent() {

View file

@ -1,13 +1,14 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.profiles.PlayerProfile;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class BatchProfileByUsernameRequestEvent implements EventInterface, ResultInterface {
public class BatchProfileByUsernameRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("c1d6729e-be2c-48cc-b5ae-af8c012232c3");
@LauncherNetworkAPI
public String error;

View file

@ -1,13 +1,14 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.profiles.PlayerProfile;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class CheckServerRequestEvent implements EventInterface, ResultInterface {
public class CheckServerRequestEvent extends RequestEvent implements EventInterface {
private static final UUID _uuid = UUID.fromString("8801d07c-51ba-4059-b61d-fe1f1510b28a");
@LauncherNetworkAPI
public UUID uuid;

View file

@ -1,12 +1,13 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class EchoRequestEvent implements ResultInterface, EventInterface {
public class EchoRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("0a1f820f-7cd5-47a5-ae0e-17492e0e1fe1");
@LauncherNetworkAPI
public String echo;

View file

@ -1,12 +1,13 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class ErrorRequestEvent implements ResultInterface, EventInterface {
public class ErrorRequestEvent extends RequestEvent implements EventInterface {
public static UUID uuid = UUID.fromString("0af22bc7-aa01-4881-bdbb-dc62b3cdac96");
public ErrorRequestEvent(String error) {

View file

@ -1,9 +1,10 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
public class ExecCommandRequestEvent implements ResultInterface {
public class ExecCommandRequestEvent extends RequestEvent {
@Override
public String getType() {
return "cmdExec";

View file

@ -1,11 +1,12 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
import java.util.List;
public class GetAvailabilityAuthRequestEvent implements ResultInterface {
public class GetAvailabilityAuthRequestEvent extends RequestEvent {
public static class AuthAvailability
{
@LauncherNetworkAPI

View file

@ -1,9 +1,10 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
public class GetSecureTokenRequestEvent implements ResultInterface {
public class GetSecureTokenRequestEvent extends RequestEvent {
@LauncherNetworkAPI
public String secureToken;
@Override

View file

@ -1,12 +1,13 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class JoinServerRequestEvent implements EventInterface, ResultInterface {
public class JoinServerRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("2a12e7b5-3f4a-4891-a2f9-ea141c8e1995");
public JoinServerRequestEvent(boolean allow) {

View file

@ -1,12 +1,13 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class LauncherRequestEvent implements EventInterface, ResultInterface {
public class LauncherRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("d54cc12a-4f59-4f23-9b10-f527fdd2e38f");
@LauncherNetworkAPI
public String url;

View file

@ -1,13 +1,14 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.profiles.PlayerProfile;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class ProfileByUUIDRequestEvent implements EventInterface, ResultInterface {
public class ProfileByUUIDRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("b9014cf3-4b95-4d38-8c5f-867f190a18a0");
@LauncherNetworkAPI
public String error;

View file

@ -1,13 +1,14 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.profiles.PlayerProfile;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class ProfileByUsernameRequestEvent implements EventInterface, ResultInterface {
public class ProfileByUsernameRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("06204302-ff6b-4779-b97d-541e3bc39aa1");
@LauncherNetworkAPI
public String error;

View file

@ -1,6 +1,7 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
@ -8,7 +9,7 @@
import java.util.List;
import java.util.UUID;
public class ProfilesRequestEvent implements EventInterface, ResultInterface {
public class ProfilesRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("2f26fbdf-598a-46dd-92fc-1699c0e173b1");
@LauncherNetworkAPI
public List<ClientProfile> profiles;

View file

@ -1,8 +1,8 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.launcher.events.RequestEvent;
public class RestoreSessionRequestEvent implements ResultInterface {
public class RestoreSessionRequestEvent extends RequestEvent {
@Override
public String getType() {
return "restoreSession";

View file

@ -1,13 +1,14 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.UUID;
public class SetProfileRequestEvent implements ResultInterface, EventInterface {
public class SetProfileRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("08c0de9e-4364-4152-9066-8354a3a48541");
@LauncherNetworkAPI
public ClientProfile newProfile;

View file

@ -1,13 +1,14 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.event.EventInterface;
import java.util.HashSet;
import java.util.UUID;
public class UpdateListRequestEvent implements EventInterface, ResultInterface {
public class UpdateListRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("5fa836ae-6b61-401c-96ac-d8396f07ec6b");
@LauncherNetworkAPI
public final HashSet<String> dirs;

View file

@ -1,10 +1,11 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.hasher.HashedDir;
import ru.gravit.launcher.request.ResultInterface;
public class UpdateRequestEvent implements ResultInterface {
public class UpdateRequestEvent extends RequestEvent {
@LauncherNetworkAPI
public HashedDir hdir;
@LauncherNetworkAPI

View file

@ -1,9 +1,10 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.request.ResultInterface;
public class VerifySecureTokenRequestEvent implements ResultInterface {
public class VerifySecureTokenRequestEvent extends RequestEvent {
@LauncherAPI
public boolean success;
@Override