[FIX] Фиксы AddLogListener/ExecCommand/Auth

This commit is contained in:
Gravit 2019-02-17 15:30:03 +07:00
parent b3d007c6d1
commit ef1f7b0e76
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
5 changed files with 21 additions and 14 deletions

View file

@ -17,6 +17,7 @@
import ru.gravit.launchserver.socket.websocket.json.JsonResponseAdapter; import ru.gravit.launchserver.socket.websocket.json.JsonResponseAdapter;
import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface;
import ru.gravit.launchserver.socket.websocket.json.admin.AddLogListenerResponse; import ru.gravit.launchserver.socket.websocket.json.admin.AddLogListenerResponse;
import ru.gravit.launchserver.socket.websocket.json.admin.ExecCommandResponse;
import ru.gravit.launchserver.socket.websocket.json.auth.*; import ru.gravit.launchserver.socket.websocket.json.auth.*;
import ru.gravit.launchserver.socket.websocket.json.update.LauncherResponse; import ru.gravit.launchserver.socket.websocket.json.update.LauncherResponse;
import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse; import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse;
@ -75,7 +76,7 @@ public void registerResponses() {
registerResponse("profiles", ProfilesResponse.class); registerResponse("profiles", ProfilesResponse.class);
registerResponse("launcher", LauncherResponse.class); registerResponse("launcher", LauncherResponse.class);
registerResponse("updateList", UpdateListResponse.class); registerResponse("updateList", UpdateListResponse.class);
registerResponse("cmdExec", UpdateListResponse.class); registerResponse("cmdExec", ExecCommandResponse.class);
registerResponse("setProfile", SetProfileResponse.class); registerResponse("setProfile", SetProfileResponse.class);
registerResponse("addLogListener", AddLogListenerResponse.class); registerResponse("addLogListener", AddLogListenerResponse.class);
} }
@ -99,16 +100,6 @@ public void sendEvent(EventResult obj) {
channels.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj))); channels.writeAndFlush(new TextWebSocketFrame(gson.toJson(obj)));
} }
public static class SuccessResult {
public SuccessResult(String requesttype) {
this.requesttype = requesttype;
this.type = "success";
}
public final String requesttype;
public final String type;
}
public static class EventResult implements ResultInterface { public static class EventResult implements ResultInterface {
public EventResult() { public EventResult() {

View file

@ -38,8 +38,8 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
service.sendObject(ctx,new LogEvent(str)); service.sendObject(ctx,new LogEvent(str));
} }
else { else {
LogHelper.info("Client %s remove log listener", client.username);
LogHelper.removeOutput(client.logOutput); LogHelper.removeOutput(client.logOutput);
LogHelper.info("Client %s remove log listener", client.username);
} }
}; };
client.logOutput = output; client.logOutput = output;

View file

@ -2,6 +2,7 @@
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import ru.gravit.launcher.events.request.ErrorRequestEvent; import ru.gravit.launcher.events.request.ErrorRequestEvent;
import ru.gravit.launcher.events.request.ExecCommandRequestEvent;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.socket.websocket.WebSocketService; import ru.gravit.launchserver.socket.websocket.WebSocketService;
@ -26,6 +27,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
return; return;
} }
LaunchServer.server.commandHandler.eval(cmd, false); LaunchServer.server.commandHandler.eval(cmd, false);
service.sendObject(ctx, new WebSocketService.SuccessResult("cmdExec")); service.sendObject(ctx, new ExecCommandRequestEvent(true));
} }
} }

View file

@ -60,7 +60,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
AuthProvider.authError(LaunchServer.server.config.authRejectString); AuthProvider.authError(LaunchServer.server.config.authRejectString);
return; return;
} }
if (authType != ConnectTypes.CLIENT &&!clientData.checkSign) { if ((authType == null || authType == ConnectTypes.CLIENT) &&!clientData.checkSign) {
AuthProvider.authError("Don't skip Launcher Update"); AuthProvider.authError("Don't skip Launcher Update");
return; return;
} }

View file

@ -0,0 +1,15 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.request.ResultInterface;
public class ExecCommandRequestEvent implements ResultInterface {
@Override
public String getType() {
return "execCmd";
}
boolean success;
public ExecCommandRequestEvent(boolean success) {
this.success = success;
}
}