diff --git a/game-server/app.ts b/game-server/app.ts index 7bc707ec3..8d8f2adc5 100644 --- a/game-server/app.ts +++ b/game-server/app.ts @@ -170,8 +170,11 @@ app.configure(ALL_ENVS, 'activity', function () { function errorHandler(err: Error, msg: any, resp: any, session: FrontendOrBackendSession, cb: HandlerCallback) { const errCode = genCode(10); - if(err.message != 'globalFilter') + if(err.message == 'globalFilter') { + infologger.debug('global after ', msg && JSON.stringify(msg), resp && JSON.stringify(resp), session && session.get('roleId')); + } else { errlogger.error(`${pinus.app.serverId} error handler \n msg[${JSON.stringify(msg)}] \n resp[${JSON.stringify(resp)}] \n sessionId:${JSON.stringify(session.export())} \n error 【${errCode}】 stack: ${err.stack}`); + } if (!resp) { resp = resResult(STATUS.GLOBAL_ERR, { errCode, stack: err.stack }); diff --git a/game-server/app/servers/connector/filter/global.ts b/game-server/app/servers/connector/filter/global.ts index 5f5db6bb3..b8ed3b920 100644 --- a/game-server/app/servers/connector/filter/global.ts +++ b/game-server/app/servers/connector/filter/global.ts @@ -40,35 +40,35 @@ class Filter { if(!this.checkPassEncrypt(routeRecord.route)) { msg = this.decryptMsg(msg, session); - if(!msg) return next(new Error('globalFilter'), resResult(STATUS.WRONG_PARMS)); + if(!msg) return next(new Error('globalFilter'), resResult(STATUS.WRONG_PARMS, { route: routeRecord.route })); - if(!this.checkTimeStamp(msg)) return next(new Error('globalFilter'), resResult(STATUS.TIMESTAMP_ERR)); - if(!this.checkDuplicateAccess(msg)) return next(new Error('globalFilter'), resResult(STATUS.DUPLICATE_ACCESS)) + if(!this.checkTimeStamp(msg)) return next(new Error('globalFilter'), resResult(STATUS.TIMESTAMP_ERR, { route: routeRecord.route })); + if(!this.checkDuplicateAccess(msg)) return next(new Error('globalFilter'), resResult(STATUS.DUPLICATE_ACCESS, { route: routeRecord.route })) } // 访问频率控制 if(!this.checkFrequency(routeRecord.route, msg, roleId)) { - return next(new Error('globalFilter'), resResult(STATUS.ACCESS_BUSY)); + return next(new Error('globalFilter'), resResult(STATUS.ACCESS_BUSY, { route: routeRecord.route })); } if(!this.checkFunction(routeRecord.route)) { - return next(new Error('globalFilter'), resResult(STATUS.FUNCTION_CLOSE)); + return next(new Error('globalFilter'), resResult(STATUS.FUNCTION_CLOSE, { route: routeRecord.route })); } if(!checkRouteParam(routeRecord.route, msg)) { - return next(new Error('globalFilter'), resResult(STATUS.WRONG_PARMS)); + return next(new Error('globalFilter'), resResult(STATUS.WRONG_PARMS, { route: routeRecord.route })); } // 玩家屏蔽 - if(blockType == BLOCK_TYPE.BLOCK) return next(new Error('globalFilter'), resResult(STATUS.BLOCKED)); + if(blockType == BLOCK_TYPE.BLOCK) return next(new Error('globalFilter'), resResult(STATUS.BLOCKED, { route: routeRecord.route })); if(blockType == BLOCK_TYPE.BAN && this.checkBanRoute(routeRecord.route)) { - return next(new Error('globalFilter'), resResult(STATUS.BANNED)); + return next(new Error('globalFilter'), resResult(STATUS.BANNED, { route: routeRecord.route })); } session.push('teamCode', () => {}); if(isCheckWord(isDevelopEnv())) { let hasNoBlockWords = this.checkHasBlockWord(routeRecord.route, msg, roleId, serverId, guildCode); - if(!hasNoBlockWords) return next(new Error('globalFilter'), resResult(STATUS.BLOCK_WORDS)); + if(!hasNoBlockWords) return next(new Error('globalFilter'), resResult(STATUS.BLOCK_WORDS, { route: routeRecord.route })); } if(routeRecord.route == 'guild.guildHandler.createGuild') { @@ -78,7 +78,7 @@ class Filter { if(await this.checkMainten(serverId, sid, ip, uid)) { sendMessageToUser(roleId, PUSH_ROUTE.SERVER_MAINTENANCE, resResult(STATUS.SERVER_MAINTENANCE), sid); - return next(new Error('globalFilter'), resResult(STATUS.SERVER_MAINTENANCE)); + return next(new Error('globalFilter'), resResult(STATUS.SERVER_MAINTENANCE, { route: routeRecord.route })); } next(null); diff --git a/game-server/app/services/checkParam.ts b/game-server/app/services/checkParam.ts index b1140cda4..969e129ef 100644 --- a/game-server/app/services/checkParam.ts +++ b/game-server/app/services/checkParam.ts @@ -467,9 +467,11 @@ export function checkRouteParam(route: string, msg: any) { if(!checkNaturalStrings(teamCode)) return false; if(!checkNumberArray(killed)) return false; if(!checkNaturalNumbers(curRnd)) return false; - if(!checkNaturalArray(bossHurts)) return false; + if(!checkArrayCanEmpty(bossHurts)) return false; for(let { hid, dataId, hurtHp } of bossHurts) { - if(!checkNaturalNumbers(hid, dataId, hurtHp)) return false; + if(hid && !checkNaturalNumbers(hid)) return false; + if(!checkNaturalNumbers(dataId)) return false; + if(!isNumber(hurtHp)) return false } break; } @@ -713,8 +715,8 @@ export function checkRouteParam(route: string, msg: any) { { if(!checkNaturalNumbers(msg.warId)) return false; if(!checkArrayCanEmpty(msg.heroes)) return false; - for(let { actorId, ai, dataId, order } of msg.heroes) { - if(!checkNaturalNumbers(actorId, ai, dataId, order)) return false; + for(let { actorId, dataId, order } of msg.heroes) { + if(!checkNaturalNumbers(actorId, dataId, order)) return false; } break; } diff --git a/game-server/app/services/pushService.ts b/game-server/app/services/pushService.ts index 7734b7adf..59714634f 100644 --- a/game-server/app/services/pushService.ts +++ b/game-server/app/services/pushService.ts @@ -92,7 +92,7 @@ export async function sendMessageToUsers(route: string, data: any, uids: { uid: export async function sendMessageToTeam(teamCode: string, route: string, data: any) { const channel = pinus.app.get('channelService').getChannel(teamCode); - sendMessageToChannel(channel, route, resResult(STATUS.SUCCESS, encryptMsg(route, data))); + sendMessageToChannel(channel, route, resResult(STATUS.SUCCESS, data)); } /**