防护:添加人数过多防护措施

This commit is contained in:
luying
2022-01-08 17:13:31 +08:00
parent f2c4be6443
commit 0f8a4a946e
18 changed files with 287 additions and 25 deletions
+1
View File
@@ -486,6 +486,7 @@ export const FILENAME = {
FILTER_WORDS: 'filterWords',
DIC_GUILD_WISH_REWARD: 'dic_army_wishReward',
DIC_API: 'dic_api',
DIC_SERVER_CONST: 'server_const',
}
export const WAR_RELATE_TABLES = [
+1
View File
@@ -13,6 +13,7 @@ export const STATUS = {
BLOCKED: { code: 10, simStr: '您已被封禁' },
BANNED: { code: 11, simStr: '您已被禁言' },
ACCESS_BUSY: { code: 12, simStr: '您的操作过于繁忙' },
ONLINE_USER_MAX: { code: 13, simStr: '服务器繁忙,请稍后再试' },
GLOBAL_ERR: { code: 1003, simStr: '服务器内部错误' },
// http请求
REQUEST_TIME_OUT: { code: 2000, simStr: '请求超时' },
+3
View File
@@ -97,6 +97,7 @@ import { dicPvpDifficultRatio, loadPvpDifficultRatio } from './dictionary/DicPvp
import { dicWhiteIp, loadWhiteIp } from './dictionary/DicWhiteIp';
import { dicGuildWishReward, loadGuildWishReward } from './dictionary/DicGuildWishReward';
import { dicApiById, dicApiByUrl, loadApi } from './dictionary/DicApi';
import { dicServerConst, loadServerConst } from './dictionary/DicServerConst';
import { pick } from "underscore";
import _ = require("underscore");
@@ -246,6 +247,7 @@ export const gameData = {
guildWishReward: dicGuildWishReward,
apiById: dicApiById,
apiByUrl: dicApiByUrl,
serverConst: dicServerConst,
};
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
@@ -995,6 +997,7 @@ function loadDatas() {
treatTaskGroup();
loadGuildWishReward();
loadApi();
loadServerConst();
}
// 重载dicParam
@@ -0,0 +1,29 @@
// 服务器名
import { readFileAndParse } from '../util'
import { FILENAME } from '../../consts'
export interface DicServerConst {
// 保护接口,间隔时间
readonly PROTECT_API_INTERVAL: number;
// 保护的接口
readonly PROTECT_API: string[];
// 这些api功能关闭
readonly API_IS_CLOSE: number;
// 关闭的接口
readonly CLOSE_APIS: string[];
// 是否直接关掉登录
readonly CLOSE_LOGIN: number;
// 是否当检测在线玩家过多是关掉登录
readonly CLOSE_LOGIN_WHEN_ONLINE_MAX: number;
// 最大在线人数
readonly MAX_ONLINE_USER_COUNT: number;
}
export const dicServerConst: DicServerConst = {} as DicServerConst;
export function loadServerConst() {
let json = readFileAndParse(FILENAME.DIC_SERVER_CONST);
for(let key in json) {
dicServerConst[key] = json[key];
}
json = undefined;
}
+2
View File
@@ -74,6 +74,8 @@ declare module 'redis' {
publishAsync(channel: string, message: string): Promise<number>;
// 订阅给定的一个或多个频道的信息
subscribeAsync(...channels: string[]): Promise<number>;
// 返回hash字段数量
hlenAsync(key: string): Promise<number>;
}
export interface Multi extends Commands<Multi> {
execAsync(...args: any[]): Promise<any>;
+15
View File
@@ -0,0 +1,15 @@
{
"PROTECT_API_INTERVAL": 500,
"PROTECT_API": [
"chat.chatHandler.sendGroupMessage",
"chat.chatHandler.sendPrivateMessage",
"battle.barrageHandler.sendBarrage"
],
"API_IS_CLOSE": 1,
"CLOSE_APIS": [
"chat.chatHandler.sendGroupMessage"
],
"CLOSE_LOGIN": 0,
"CLOSE_LOGIN_WHEN_ONLINE_MAX": 1,
"MAX_ONLINE_USER_COUNT": 5000
}