服务器:修复白名单bug

This commit is contained in:
luying
2022-01-10 18:13:27 +08:00
parent 002ca4f8db
commit 5641d8fdfa
8 changed files with 34 additions and 24 deletions

View File

@@ -11,14 +11,14 @@ module.exports = () => {
if (server && server.maintenance && server.maintenance.isOpen && server.maintenance.startTime < nowSeconds() && server.maintenance.endTime > nowSeconds()) {
let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid, serverId);
if (isWhiteList) {
await next();
return await next();
} else {
ctx.body = ctx.service.utils.resResult(STATUS.SERVER_MAINTENANCE);
return;
}
}
}
await next();
return await next();
};
};

View File

@@ -289,7 +289,6 @@ export default class Auth extends Service {
public async checkRole(serverId: number) {
const ctx = this.ctx;
const { uid } = ctx;
let canLogin = await this.ctx.service.utils.validateCanLogin();
if(!canLogin) return this.ctx.service.utils.resResult(STATUS.ONLINE_USER_MAX);

View File

@@ -65,14 +65,12 @@ export default class Utils extends Service {
// 检测是否可以登录
public async validateCanLogin() {
console.log('********* serverConst', gameData.serverConst)
if(gameData.serverConst.CLOSE_LOGIN == 1) return false;
if(gameData.serverConst.CLOSE_LOGIN_WHEN_ONLINE_MAX) {
let redisClient: RedisClient = this.ctx.app.context.redisClient;
let count = await redisClient.hlenAsync(REDIS_KEY.ONLINE_USERS);
console.log('********* count', count)
if(count >= gameData.serverConst.MAX_ONLINE_USER_COUNT) {
return false
}

View File

@@ -27,7 +27,8 @@
"lylocal": "cross-env EGG_SERVER_ENV=lylocal npm run dev",
"alpha": "cross-env EGG_SERVER_ENV=alpha npm run dev",
"stable": "cross-env EGG_SERVER_ENV=stable npm run dev",
"deve": "cross-env EGG_SERVER_ENV=dev npm run dev"
"deve": "cross-env EGG_SERVER_ENV=dev npm run dev",
"sq1": "cross-env EGG_SERVER_ENV=sq1 npm run dev"
},
"dependencies": {
"@types/underscore": "^1.11.3",