Ver Fonte

Merge branch 'dev' of GameCenter/game-center into master

zhimo há 1 ano atrás
pai
commit
1fb970773b

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -23,7 +23,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 < (自动回复增加图片02´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 < (处理Websocket导致的token入侵问题02´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 1 - 7
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/AgentController.java

@@ -2,7 +2,6 @@ package com.zanxiang.game.module.manage.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zanxiang.erp.security.annotation.PreAuthorize;
-import com.zanxiang.erp.security.util.SecurityUtil;
 import com.zanxiang.game.module.base.pojo.enums.AccountTypeEnum;
 import com.zanxiang.game.module.manage.pojo.params.AgentAddParam;
 import com.zanxiang.game.module.manage.pojo.params.AgentListParam;
@@ -11,14 +10,12 @@ import com.zanxiang.game.module.manage.service.IAgentService;
 import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.module.util.exception.BaseException;
 import com.zanxiang.module.util.pojo.ResultVO;
-import com.zanxiang.module.web.util.IpUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 @Slf4j
@@ -31,10 +28,7 @@ public class AgentController {
 
     @PreAuthorize(permissionKey = "manage:agent:list")
     @PostMapping("/list")
-    public ResultVO<IPage<AgentVO>> listOfPage(@Validated @RequestBody AgentListParam dto, HttpServletRequest request) {
-        log.error("userId : {}, ip : {}, ua : {}, name : {}, token : {}",
-                SecurityUtil.getUserId(), IpUtil.getRealIp(request), request.getHeader("user-agent"),
-                SecurityUtil.getTokenInfo().getNickname(), SecurityUtil.getToken());
+    public ResultVO<IPage<AgentVO>> listOfPage(@Validated @RequestBody AgentListParam dto) {
         return ResultVO.ok(agentService.listOfPage(dto));
     }
 

+ 54 - 48
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/websocket/KfMsgWebsocketHandler.java

@@ -84,54 +84,60 @@ public class KfMsgWebsocketHandler implements WebSocketHandler {
      */
     @Override
     public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
-        String msgStr = message.getPayload().toString();
-        //消息解析
-        KfWebSocketMsgParam param = JsonUtil.toObj(msgStr, KfWebSocketMsgParam.class);
-        //消息类型
-        KfWebSocketMsgEnum webSocketMsgType = param.getWebSocketMsgType();
-        //游戏id
-        Long gameId = param.getGameId();
-        //参数验证不通过, 直接结束
-        if (!this.paramCheck(session, webSocketMsgType, param.getToken(), gameId)) {
-            return;
-        }
-        //处理不同类型的消息
-        switch (webSocketMsgType) {
-            case WEBSOCKET_MSG_KF_HAND_SHAKE:
-                kfHandShake(session, webSocketMsgType);
-                break;
-            case WEBSOCKET_MSG_KF_CREATE_CONNECT:
-                kfCreateConnect(session, webSocketMsgType, gameId);
-                break;
-            case WEBSOCKET_MSG_USER_CONNECT_JOIN:
-                userConnectJoin(session, param);
-                break;
-            case WEBSOCKET_MSG_ROOM_HISTORY:
-                msgRoomHistory(session, param);
-                break;
-            case WEBSOCKET_MSG_KF_SEND:
-                kfSendMsg(session, param);
-                break;
-            case WEBSOCKET_MSG_FINISH_ROOM_LIST:
-                finishRoomList(session, param);
-                break;
-            case WEBSOCKET_MSG_FINISH_SESSION:
-                kfFinishSession(session, webSocketMsgType, gameId, param.getRoomId());
-                break;
-            case WEBSOCKET_MSG_GET_USER:
-                getUser(session, param);
-                break;
-            case WEBSOCKET_MSG_GET_ROLE_LIST:
-                getRoleList(session, param);
-                break;
-            case WEBSOCKET_MSG_GET_ORDER_LIST:
-                getOrderList(session, param);
-                break;
-            case WEBSOCKET_MSG_QUICK_REPLY:
-                quickReply(session, param);
-                break;
-            default:
-                this.sendMessage(session, KfWebSocketMsgDTO.fail(webSocketMsgType, "参数错误, 未知的消息类型"));
+        try {
+            String msgStr = message.getPayload().toString();
+            //消息解析
+            KfWebSocketMsgParam param = JsonUtil.toObj(msgStr, KfWebSocketMsgParam.class);
+            //消息类型
+            KfWebSocketMsgEnum webSocketMsgType = param.getWebSocketMsgType();
+            //游戏id
+            Long gameId = param.getGameId();
+            //参数验证不通过, 直接结束
+            if (!this.paramCheck(session, webSocketMsgType, param.getToken(), gameId)) {
+                return;
+            }
+            //处理不同类型的消息
+            switch (webSocketMsgType) {
+                case WEBSOCKET_MSG_KF_HAND_SHAKE:
+                    kfHandShake(session, webSocketMsgType);
+                    break;
+                case WEBSOCKET_MSG_KF_CREATE_CONNECT:
+                    kfCreateConnect(session, webSocketMsgType, gameId);
+                    break;
+                case WEBSOCKET_MSG_USER_CONNECT_JOIN:
+                    userConnectJoin(session, param);
+                    break;
+                case WEBSOCKET_MSG_ROOM_HISTORY:
+                    msgRoomHistory(session, param);
+                    break;
+                case WEBSOCKET_MSG_KF_SEND:
+                    kfSendMsg(session, param);
+                    break;
+                case WEBSOCKET_MSG_FINISH_ROOM_LIST:
+                    finishRoomList(session, param);
+                    break;
+                case WEBSOCKET_MSG_FINISH_SESSION:
+                    kfFinishSession(session, webSocketMsgType, gameId, param.getRoomId());
+                    break;
+                case WEBSOCKET_MSG_GET_USER:
+                    getUser(session, param);
+                    break;
+                case WEBSOCKET_MSG_GET_ROLE_LIST:
+                    getRoleList(session, param);
+                    break;
+                case WEBSOCKET_MSG_GET_ORDER_LIST:
+                    getOrderList(session, param);
+                    break;
+                case WEBSOCKET_MSG_QUICK_REPLY:
+                    quickReply(session, param);
+                    break;
+                default:
+                    this.sendMessage(session, KfWebSocketMsgDTO.fail(webSocketMsgType, "参数错误, 未知的消息类型"));
+            }
+        } catch (Exception e) {
+            log.error("Websocket消息处理出现异常, e : {}", e.getMessage());
+        } finally {
+            SecurityUtil.destroy();
         }
     }