政治需求:关闭接口功能
This commit is contained in:
@@ -31,6 +31,7 @@ import { errlogger, infologger, loadLogger } from './app/util/logger';
|
||||
import { connectThinkingData, getTire } from './app/services/sdkService';
|
||||
import { loadGmDb } from './app/db';
|
||||
import { loadActivities } from './app/services/activity/activityRemoteService';
|
||||
import { checkAndSetApiIsClose } from './app/services/chatService';
|
||||
|
||||
const filePath = (_pinus as any).FILEPATH;
|
||||
filePath.MASTER = '/config/master';
|
||||
@@ -185,6 +186,7 @@ async function treatStartLogic(app: _pinus.Application) {
|
||||
loadActivities();
|
||||
}
|
||||
treatStartMainten(app);
|
||||
checkAndSetApiIsClose();
|
||||
|
||||
if(app.isMaster()) {
|
||||
redisService.initAllRank();
|
||||
|
||||
@@ -9,6 +9,7 @@ import { errlogger } from '../../../util/logger';
|
||||
import { ActivityGroupModel } from '../../../db/ActivityGroup';
|
||||
import { deleteActivities, loadActivities, saveActivitiesToGroup, updateActivities, _getActivityById, _getActivitiesByType, _getActivities, _getActivitiesByServerId } from '../../../services/activity/activityRemoteService';
|
||||
import { saveActivityMemory } from '../../../services/log/memoryLogService';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -148,4 +149,12 @@ export class ActivityRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass, HandlerService, } from 'pinus';
|
||||
import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||
import { savePvpSeasonMemory } from '../../../services/log/memoryLogService';
|
||||
import { taflush } from '../../../services/sdkService';
|
||||
@@ -149,4 +150,12 @@ export class BattleRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { _checkFilterWords, taflush } from '../../../services/sdkService';
|
||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { addUserToChannel, sendMessageToChannel, sendMessgeToChannelByBatch } from '../../../services/pushService';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -147,4 +148,12 @@ export class ChatRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { isDevelopEnv } from "../../../services/utilService";
|
||||
import { isNumber } from "underscore";
|
||||
import { redisClient } from "../../../services/redisService";
|
||||
import { checkRouteParam } from "../../../services/checkParam";
|
||||
import { isApiClose } from "../../../services/chatService";
|
||||
|
||||
export function globalFilter(app: Application) {
|
||||
return new Filter(app);
|
||||
@@ -52,7 +53,7 @@ class Filter {
|
||||
if(!this.checkFrequency(routeRecord.route, msg, roleId)) {
|
||||
return next(new Error('globalFilter'), resResult(STATUS.ACCESS_BUSY, { route: routeRecord.route }));
|
||||
}
|
||||
if(!this.checkFunction(routeRecord.route)) {
|
||||
if(!this.checkFunction(routeRecord.route, msg)) {
|
||||
return next(new Error('globalFilter'), resResult(STATUS.FUNCTION_CLOSE, { route: routeRecord.route }));
|
||||
}
|
||||
|
||||
@@ -131,11 +132,19 @@ class Filter {
|
||||
}
|
||||
|
||||
// 检查该接口是否关闭
|
||||
private checkFunction (route: string) {
|
||||
if(gameData.serverConst.API_IS_CLOSE == 1) {
|
||||
if(gameData.serverConst.CLOSE_APIS.indexOf(route) != -1) {
|
||||
private checkFunction (route: string, msg: any) {
|
||||
if(isApiClose()) {
|
||||
let isClose = gameData.serverConst.CLOSE_APIS.find(cur => {
|
||||
if(cur.route == route) {
|
||||
if(cur.param == null) return true;
|
||||
for(let key in cur.param) {
|
||||
if(cur.param[key] == true && msg[key] != undefined) return true;
|
||||
if(cur.param[key] && msg[key] == cur.param[key]) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return !isClose
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { taflush } from '../../../services/sdkService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { setWeek } from '../../../pubUtils/timeUtil';
|
||||
import { savePvpSeasonMemory } from '../../../services/log/memoryLogService';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ConnectorRemote(app);
|
||||
@@ -180,4 +181,12 @@ export class ConnectorRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import { nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { createNewServer, sendOpenServerMail } from '../../../services/gmService';
|
||||
import { isNumber } from 'util';
|
||||
import { MarqueeModel } from '../../../db/Marquee';
|
||||
let timer: NodeJS.Timer;
|
||||
import { setApiIsCloseToRemote } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new GmHandler(app);
|
||||
}
|
||||
@@ -169,4 +170,14 @@ export class GmHandler {
|
||||
if (!result) return resResult(STATUS.GM_MARQUEE_CANCEL_ERR);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
async setApiIsClose(msg: { isCloseApi: boolean }, session: BackendSession) {
|
||||
const { isCloseApi } = msg;
|
||||
let region = await RegionModel.findRegionByEnv(pinus.app.get('env'));
|
||||
if(!region) return resResult(STATUS.SERVER_NOT_FOUND);
|
||||
|
||||
region = await RegionModel.updateRegion(region.id, { isCloseApi });
|
||||
setApiIsCloseToRemote(region.isCloseApi);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { reloadResources } from '../../../pubUtils/data';
|
||||
import { taflush, treatGuildName } from '../../../services/sdkService';
|
||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -65,4 +66,12 @@ export class GuildRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { refundOrderFromRedisPub, settleOrderFromRedisPub } from '../../../servi
|
||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||
import { taflush } from '../../../services/sdkService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -77,4 +78,12 @@ export class OrderRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
|
||||
import { treatRoleName, taflush, sendSurveyMail } from '../../../services/sdkService';
|
||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -141,4 +142,11 @@ export class RoleRemote {
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { GroupMailType } from '../../../db/GroupMail';
|
||||
import { ServerMailType } from '../../../db/ServerMail';
|
||||
import { ActivityModelType } from '../../../db/Activity';
|
||||
import { GUILD_ACTIVITY_TYPE, LADDER_STATUS } from '../../../consts';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new SystimerRemote(app);
|
||||
@@ -216,4 +217,12 @@ export class SystimerRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setApiIsClose(isClose: boolean) {
|
||||
try {
|
||||
setApiIsClose(isClose);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { getSimpleRoleInfo, getSimpleRoleInfos } from './roleService';
|
||||
import { sendMessageToAllWithSuc, sendMessageToCityWithSuc, sendMessageToGuildWithSuc, sendMessageToServerWithSuc, sendMessageToTeam, sendMessageToUserWithSuc } from './pushService';
|
||||
import { comBtlLvInvalid } from './comBattleService';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { RegionModel } from '../db/Region';
|
||||
|
||||
export * from './chatChannelService';
|
||||
export * from './sysChatService';
|
||||
@@ -427,3 +428,27 @@ export async function checkFilterWords(word: string) {
|
||||
return hasBlock;
|
||||
}
|
||||
*/
|
||||
|
||||
export function isApiClose() {
|
||||
return pinus.app.get('apiIsClose');
|
||||
}
|
||||
|
||||
export async function checkAndSetApiIsClose() {
|
||||
let region = await RegionModel.findRegionByEnv(pinus.app.get('env'));
|
||||
setApiIsClose(region?.isCloseApi??false);
|
||||
}
|
||||
|
||||
export function setApiIsClose(isClose: boolean) {
|
||||
pinus.app.set('apiIsClose', isClose);
|
||||
}
|
||||
|
||||
export async function setApiIsCloseToRemote(isClose: boolean) {
|
||||
await pinus.app.rpc.activity.activityRemote.setApiIsClose.broadcast(isClose);
|
||||
await pinus.app.rpc.battle.battleRemote.setApiIsClose.broadcast(isClose);
|
||||
await pinus.app.rpc.chat.chatRemote.setApiIsClose.broadcast(isClose);
|
||||
await pinus.app.rpc.connector.connectorRemote.setApiIsClose.broadcast(isClose);
|
||||
await pinus.app.rpc.guild.guildRemote.setApiIsClose.broadcast(isClose);
|
||||
await pinus.app.rpc.order.orderRemote.setApiIsClose.broadcast(isClose);
|
||||
await pinus.app.rpc.role.roleRemote.setApiIsClose.broadcast(isClose);
|
||||
await pinus.app.rpc.systimer.systimerRemote.setApiIsClose.broadcast(isClose);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"API_IS_CLOSE": 1,
|
||||
"CLOSE_APIS": [
|
||||
],
|
||||
"CLOSE_APIS": [],
|
||||
"CLOSE_LOGIN": 0,
|
||||
"CLOSE_LOGIN_WHEN_ONLINE_MAX": 1,
|
||||
"MAX_ONLINE_USER_COUNT": 5000,
|
||||
|
||||
@@ -12,9 +12,10 @@ export const STATUS = {
|
||||
BLOCK_WORDS: { code: 9, simStr: '内容含有敏感字符' },
|
||||
BLOCKED: { code: 10, simStr: '您已被封禁' },
|
||||
BANNED: { code: 11, simStr: '您已被禁言' },
|
||||
CLOSE_FROM_BACKEND: { code: 18, simStr: '功能暂未开启' },
|
||||
ACCESS_BUSY: { code: 12, simStr: '您的点击过于频繁,服务器受不了了' },
|
||||
ONLINE_USER_MAX: { code: 13, simStr: '服务器繁忙,请稍后再试' },
|
||||
FUNCTION_CLOSE: { code: 14, simStr: '抱歉,该功能暂时关闭' },
|
||||
FUNCTION_CLOSE: { code: 14, simStr: '该功能暂时无法使用' },
|
||||
TIMESTAMP_ERR: { code: 15, simStr: '请求时间参数错误' },
|
||||
DUPLICATE_ACCESS: { code: 16, simStr: '随机请求参数重复' },
|
||||
ADDRESS_ERR: { code: 17, simStr: '您的版本已停止支持,请前往应用商店下载最新安装包' },
|
||||
|
||||
@@ -10,6 +10,7 @@ import { ServerlistType } from './Serverlist';
|
||||
* 大区数据
|
||||
*/
|
||||
@index({ id: 1 })
|
||||
@index({ env: 1 })
|
||||
|
||||
export default class Region extends BaseModel {
|
||||
@prop({ required: true })
|
||||
@@ -69,6 +70,9 @@ export default class Region extends BaseModel {
|
||||
@prop({ required: true })
|
||||
reviewVersion: string; // 大于这个版本的都是审核服
|
||||
|
||||
@prop({ required: true })
|
||||
isCloseApi: boolean; // 大于这个版本的都是审核服
|
||||
|
||||
public static async createNewRegion(params: RegionUpdate, uid = 1) {
|
||||
let id = await CounterAllModal.getNewCounter(COUNTER.REGION);
|
||||
|
||||
|
||||
@@ -14,13 +14,23 @@ interface ProtectApi {
|
||||
// 频率 毫秒
|
||||
readonly interval: number;
|
||||
}
|
||||
interface CloseApi {
|
||||
// id
|
||||
readonly id: number;
|
||||
// 描述
|
||||
readonly desc: string;
|
||||
// 接口
|
||||
readonly route: string;
|
||||
// 参数
|
||||
readonly param: any;
|
||||
}
|
||||
export interface DicServerConst {
|
||||
// 保护的接口
|
||||
readonly PROTECT_API: ProtectApi[];
|
||||
// 某些api功能关闭
|
||||
readonly API_IS_CLOSE: number;
|
||||
// 关闭的接口
|
||||
readonly CLOSE_APIS: string[];
|
||||
readonly CLOSE_APIS: CloseApi[];
|
||||
// 是否直接关掉登录
|
||||
readonly CLOSE_LOGIN: number;
|
||||
// 是否当检测在线玩家过多是关掉登录
|
||||
|
||||
@@ -887,5 +887,12 @@
|
||||
"name": "保存内存",
|
||||
"module": "sys",
|
||||
"type": "update"
|
||||
},
|
||||
{
|
||||
"id": 128,
|
||||
"api": "gm.gmServerHandler.setApiIsClose",
|
||||
"name": "开关接口",
|
||||
"module": "sys",
|
||||
"type": "update"
|
||||
}
|
||||
]
|
||||
@@ -1,6 +1,17 @@
|
||||
{
|
||||
"API_IS_CLOSE": 1,
|
||||
"CLOSE_APIS": [
|
||||
{ "id": 1, "desc": "世界聊天", "route": "chat.chatHandler.sendGroupMessage", "param": { "channel": "world" } },
|
||||
{ "id": 2, "desc": "军团聊天", "route": "chat.chatHandler.sendGroupMessage", "param": { "channel": "guild" } },
|
||||
{ "id": 3, "desc": "组团聊天", "route": "battle.comBattleHandler.sendTeamMsg", "param": null },
|
||||
{ "id": 4, "desc": "私聊", "route": "chat.chatHandler.sendPrivateMessage", "param": null },
|
||||
{ "id": 5, "desc": "发送弹幕", "route": "battle.barrageHandler.sendBarrage", "param": null },
|
||||
{ "id": 6, "desc": "改名", "route": "role.roleHandler.rename", "param": null },
|
||||
{ "id": 7, "desc": "改军团名", "route": "guild.guildHandler.setGuildInfo", "param": { "name": true } },
|
||||
{ "id": 8, "desc": "改军团公告", "route": "guild.guildHandler.setGuildInfo", "param": { "notice": true } },
|
||||
{ "id": 9, "desc": "改军团简介", "route": "guild.guildHandler.setGuildInfo", "param": { "introduce": true } },
|
||||
{ "id": 10, "desc": "发军团邮件", "route": "guild.guildHandler.sendMail", "param": null },
|
||||
{ "id": 11, "desc": "军团招募", "route": "guild.guildHandler.recruit", "param": null}
|
||||
],
|
||||
"CLOSE_LOGIN": 0,
|
||||
"CLOSE_LOGIN_WHEN_ONLINE_MAX": 1,
|
||||
|
||||
Reference in New Issue
Block a user