🎈 perf(热更新): 添加白名单热更新地址
This commit is contained in:
@@ -282,7 +282,7 @@ class Filter {
|
|||||||
if(!mainten) return false // 该服务器维护
|
if(!mainten) return false // 该服务器维护
|
||||||
if(mainten.startTime > nowSeconds() || mainten.endTime < nowSeconds()) return false;
|
if(mainten.startTime > nowSeconds() || mainten.endTime < nowSeconds()) return false;
|
||||||
|
|
||||||
let isWhiteList = await checkWhiteList(this.app.get('env'), ip, uid, serverId);
|
let isWhiteList = await checkWhiteList(this.app.get('env'), ip, uid);
|
||||||
if(isWhiteList) return false;
|
if(isWhiteList) return false;
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ export async function getIpLocation(ip: string) {
|
|||||||
|
|
||||||
// 服务器是否开启
|
// 服务器是否开启
|
||||||
export async function checkServerIsOpen(serverId: number, ip: string, uid: number) {
|
export async function checkServerIsOpen(serverId: number, ip: string, uid: number) {
|
||||||
let isWhiteList = await checkWhiteList(pinus.app.get('env'), ip, uid, serverId);
|
let isWhiteList = await checkWhiteList(pinus.app.get('env'), ip, uid);
|
||||||
if(isWhiteList) return true;
|
if(isWhiteList) return true;
|
||||||
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
let serverTime = await getServerCreateTime(serverId);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { RegionModel } from '@db/Region';
|
|||||||
import { ActivityGroupModel } from '@db/ActivityGroup';
|
import { ActivityGroupModel } from '@db/ActivityGroup';
|
||||||
import { nowSeconds } from '@pubUtils/timeUtil';
|
import { nowSeconds } from '@pubUtils/timeUtil';
|
||||||
import { WhiteListModel } from '@db/RegionWhiteList';
|
import { WhiteListModel } from '@db/RegionWhiteList';
|
||||||
import { RoleModel } from '@db/Role';
|
|
||||||
import { SearchMarqueeParam, SearchOrderParam, SearchSurveyParam } from '@domain/backEndField/search';
|
import { SearchMarqueeParam, SearchOrderParam, SearchSurveyParam } from '@domain/backEndField/search';
|
||||||
import { DicServerName } from '@pubUtils/dictionary/DicServerName';
|
import { DicServerName } from '@pubUtils/dictionary/DicServerName';
|
||||||
import { CreateRegionParam, UpdateChannelParam } from '@domain/backEndField/params';
|
import { CreateRegionParam, UpdateChannelParam } from '@domain/backEndField/params';
|
||||||
@@ -23,6 +22,7 @@ import { RedisClient } from 'redis';
|
|||||||
import { ChannelInfoModel } from '@db/ChannelInfo';
|
import { ChannelInfoModel } from '@db/ChannelInfo';
|
||||||
import { PVPConfigModel } from '@db/PvpConfig';
|
import { PVPConfigModel } from '@db/PvpConfig';
|
||||||
import { HiddenDataByIdModel } from '@db/HiddenDataById';
|
import { HiddenDataByIdModel } from '@db/HiddenDataById';
|
||||||
|
import { isNumber } from 'util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Service
|
* Test Service
|
||||||
@@ -160,8 +160,8 @@ export default class Game extends Service {
|
|||||||
let whitelist = await WhiteListModel.updateWhiteList(code, { type, regionId: region.id, env: region.env, ip: content });
|
let whitelist = await WhiteListModel.updateWhiteList(code, { type, regionId: region.id, env: region.env, ip: content });
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist });
|
||||||
} else if(type == 2) {
|
} else if(type == 2) {
|
||||||
let role = await RoleModel.findByRoleId(content, 'roleId userInfo serverId roleName');
|
if(!isNumber(content)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
let whitelist = await WhiteListModel.updateWhiteList(code, { type, regionId: region.id, env: region.env, uid: role.userInfo.uid, serverId: role.serverId, roleId: role.roleId, roleName: role.roleName });
|
let whitelist = await WhiteListModel.updateWhiteList(code, { type, regionId: region.id, env: region.env, uid: parseInt(content) });
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist });
|
||||||
} else {
|
} else {
|
||||||
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
|
|||||||
@@ -1,155 +0,0 @@
|
|||||||
import { APP_ID } from './../consts';
|
|
||||||
import BaseModel from './BaseModel';
|
|
||||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
|
||||||
|
|
||||||
export class ServerInfo {
|
|
||||||
@prop({ required: true })
|
|
||||||
id: number; // 小区id
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
name: string; // 小区区名
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
groupId: number; // 大区id
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
groupName: string; // 大区区名
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
host: string; // pinus连接地址
|
|
||||||
|
|
||||||
@prop({ required: false })
|
|
||||||
port: number; // pinus端口
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
serverStatus: number; // 服务器状态
|
|
||||||
|
|
||||||
public get status() {
|
|
||||||
let now = new Date();
|
|
||||||
if( now > this.openTime) {
|
|
||||||
return this.serverStatus;
|
|
||||||
} else {
|
|
||||||
return 3; // 未开服
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
openTime: Date;
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
createTime: Date;
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
serverType: string;
|
|
||||||
|
|
||||||
constructor(id: number, name: string, groupId: number, groupName: string, host: string, port: number, serverStatus: number, serverType: string, openTime?: Date) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.groupId = groupId;
|
|
||||||
this.groupName = groupName;
|
|
||||||
this.host = host;
|
|
||||||
this.port = port;
|
|
||||||
this.serverStatus = serverStatus;
|
|
||||||
this.serverType = serverType;
|
|
||||||
this.openTime = openTime||new Date();
|
|
||||||
this.createTime = new Date();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ServerEnv {
|
|
||||||
@prop({ required: true })
|
|
||||||
env: string; // 服务器环境,一台物理机一个
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
envName: string; // 环境名 正式服 开发服 测试服 等
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
serverType: string; // serverlist表中的serverType
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
gmHost: string; // 后台地址
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
webHost: string; // web服地址
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
gameHost: string; // pinus长链接地址
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 游戏字段接口
|
|
||||||
*/
|
|
||||||
@index({ id: 1 })
|
|
||||||
@modelOptions({schemaOptions: {id: false}})
|
|
||||||
export default class Game extends BaseModel {
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
nameEn: string;
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
des: string;
|
|
||||||
|
|
||||||
@prop({ required: true, type: ServerInfo, default: [], _id: false })
|
|
||||||
serverList: Array<ServerInfo>;
|
|
||||||
|
|
||||||
@prop({ required: true, type: ServerEnv, default: [], _id: false })
|
|
||||||
serverEnv: Array<ServerEnv>;
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
iconUrl: string;
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
version: string;
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
versionCode: number;
|
|
||||||
|
|
||||||
public static async getAllServerList() {
|
|
||||||
let game: GameType = await GameModel.findOne().lean();
|
|
||||||
if(game) {
|
|
||||||
return game.serverList;
|
|
||||||
} else {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async getServerList() {
|
|
||||||
let game: GameType = await GameModel.findOne().lean({ getter: true, virtuals: true });
|
|
||||||
if (!game) {
|
|
||||||
const serverInfo = new ServerInfo(1, '常山少年', 1, '逍遥津', 'pinus_test.trgame.cn', 3014, 1, 'official');
|
|
||||||
const iconUrl = `https://download.tgamebox.cn/avatar/${APP_ID}/1.png`;
|
|
||||||
game = await GameModel.findOneAndUpdate(
|
|
||||||
{},
|
|
||||||
{ id: 1, name: '赵云传', nameEn: 'zyz', des: '牛逼的战棋', iconUrl, version: '0.0.1', versionCode: 1, $push: { serverList: serverInfo } },
|
|
||||||
{ upsert: true, new: true },
|
|
||||||
).lean({ getter: true, virtuals: true });
|
|
||||||
}
|
|
||||||
let serverList: Array<ServerInfo> = game ? game.serverList : [];
|
|
||||||
return serverList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static async getServerEnvList() {
|
|
||||||
let game: GameType = await GameModel.findOne().lean({ getter: true, virtuals: true });
|
|
||||||
let serverList: ServerEnv[] = game ? game.serverEnv : [];
|
|
||||||
return serverList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async newServer(serverId: number, serverType: string, name: string, host: string, port: number, status: number, lean = true) {
|
|
||||||
let serverInfo = new ServerInfo(serverId, name, 1, '逍遥津', host, port, status, serverType);
|
|
||||||
let game: GameType = await GameModel.findOneAndUpdate({}, {$push: {serverList: serverInfo}}, {new: true}).lean(lean);
|
|
||||||
return game;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const GameModel = getModelForClass(Game);
|
|
||||||
|
|
||||||
export interface GameType extends Pick<DocumentType<Game>, keyof Game>{
|
|
||||||
id: number;
|
|
||||||
};
|
|
||||||
@@ -41,11 +41,14 @@ export default class Region extends BaseModel {
|
|||||||
latestServer: number; // 最新服
|
latestServer: number; // 最新服
|
||||||
|
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
versionCode: string; // 支持的最小版本号
|
minVersion: string; // 支持的最小版本号
|
||||||
|
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
curVersion: string; // 当前版本号,格式 x.x.x.x
|
curVersion: string; // 当前版本号,格式 x.x.x.x
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
whitelistVersion: string; // 白名单版本号
|
||||||
|
|
||||||
@prop({ required: true }) // 热更新资源根目录
|
@prop({ required: true }) // 热更新资源根目录
|
||||||
updateResUrl: string;
|
updateResUrl: string;
|
||||||
|
|
||||||
|
|||||||
@@ -19,25 +19,16 @@ export default class RegionWhiteList extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
ip: string; // ip
|
ip: string; // ip
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
serverId: number; // 小区id
|
|
||||||
|
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
uid: number; // 玩家uid
|
uid: number; // 玩家uid
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
roleId: string; // 玩家角色id
|
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
roleName: string; // 玩家角色名
|
|
||||||
|
|
||||||
public static async checkIp(env: string, ip: string) {
|
public static async checkIp(env: string, ip: string) {
|
||||||
const rec = await WhiteListModel.exists({ env, ip });
|
const rec = await WhiteListModel.exists({ env, ip });
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async checkUid(env: string, serverId: number, uid: number) {
|
public static async checkUid(env: string, uid: number) {
|
||||||
const rec = await WhiteListModel.exists({ env, serverId, uid });
|
const rec = await WhiteListModel.exists({ env, uid });
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ export class UpdateRegionParams {
|
|||||||
name: string = ''; // 大区名
|
name: string = ''; // 大区名
|
||||||
prefix: string = ''; // 区名前缀
|
prefix: string = ''; // 区名前缀
|
||||||
remark: string = '';
|
remark: string = '';
|
||||||
versionCode: string = '';
|
minVersion: string = '';
|
||||||
|
whitelistVersion: string = '';
|
||||||
curVersion: string = '';
|
curVersion: string = '';
|
||||||
updateResUrl: string = '';
|
updateResUrl: string = '';
|
||||||
reviewVersion: string = '';
|
reviewVersion: string = '';
|
||||||
@@ -100,8 +101,8 @@ export class UpdateRegionParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkParams() {
|
checkParams() {
|
||||||
if(!this.id || !this.name || !this.prefix || !isString(this.versionCode) || !isString(this.curVersion) || !isString(this.updateResUrl)) {
|
if(!this.id || !this.name || !this.prefix || !isString(this.minVersion)|| !isString(this.whitelistVersion) || !isString(this.curVersion) || !isString(this.updateResUrl)) {
|
||||||
// console.log('1111', !this.id, !this.name, !this.prefix, !isString(this.versionCode),!isString(this.curVersion), !isString(this.updateResUrl))
|
// console.log('1111', !this.id, !this.name, !this.prefix, !isString(this.minVersion),!isString(this.curVersion), !isString(this.updateResUrl))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if(this.isOpen && (!this.maxPlayerCnt || !isArray(this.timers) || this.timers.length <= 0 || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 )) {
|
if(this.isOpen && (!this.maxPlayerCnt || !isArray(this.timers) || this.timers.length <= 0 || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 )) {
|
||||||
@@ -118,7 +119,8 @@ export class UpdateRegionParams {
|
|||||||
name: this.name,
|
name: this.name,
|
||||||
prefix: this.prefix,
|
prefix: this.prefix,
|
||||||
remark: this.remark,
|
remark: this.remark,
|
||||||
versionCode: this.versionCode,
|
minVersion: this.minVersion,
|
||||||
|
whitelistVersion: this.whitelistVersion,
|
||||||
curVersion: this.curVersion,
|
curVersion: this.curVersion,
|
||||||
reviewVersion: this.reviewVersion,
|
reviewVersion: this.reviewVersion,
|
||||||
reviewEnv: this.reviewEnv,
|
reviewEnv: this.reviewEnv,
|
||||||
@@ -132,7 +134,8 @@ export class UpdateRegionParams {
|
|||||||
name: this.name||oldRegion.name,
|
name: this.name||oldRegion.name,
|
||||||
prefix: this.prefix||oldRegion.prefix,
|
prefix: this.prefix||oldRegion.prefix,
|
||||||
remark: this.remark||oldRegion.remark,
|
remark: this.remark||oldRegion.remark,
|
||||||
versionCode: this.versionCode||oldRegion.versionCode,
|
minVersion: this.minVersion||oldRegion.minVersion,
|
||||||
|
whitelistVersion: this.whitelistVersion||oldRegion.whitelistVersion,
|
||||||
curVersion: this.curVersion||oldRegion.curVersion,
|
curVersion: this.curVersion||oldRegion.curVersion,
|
||||||
reviewVersion: this.reviewVersion||oldRegion.reviewVersion,
|
reviewVersion: this.reviewVersion||oldRegion.reviewVersion,
|
||||||
reviewEnv: this.reviewEnv||oldRegion.reviewEnv,
|
reviewEnv: this.reviewEnv||oldRegion.reviewEnv,
|
||||||
@@ -148,7 +151,8 @@ export class CreateRegionParam {
|
|||||||
name: string = ''; // 大区名
|
name: string = ''; // 大区名
|
||||||
prefix: string = ''; // 区名前缀
|
prefix: string = ''; // 区名前缀
|
||||||
remark: string = '';
|
remark: string = '';
|
||||||
versionCode: string = '';
|
minVersion: string = '';
|
||||||
|
whitelistVersion: string = '';
|
||||||
env: string = ''; // 环境变量
|
env: string = ''; // 环境变量
|
||||||
gmLink: string; // 对应后台链接
|
gmLink: string; // 对应后台链接
|
||||||
gameHost: string; // 长链接
|
gameHost: string; // 长链接
|
||||||
@@ -164,7 +168,7 @@ export class CreateRegionParam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkParams() {
|
checkParams() {
|
||||||
if(!this.name || !this.prefix || !this.env || !this.gmLink || !this.gameHost || !this.gmPort || !this.webHost || !isNumber(this.gmPort) || !isString(this.versionCode) || !this.updateResUrl) {
|
if(!this.name || !this.prefix || !this.env || !this.gmLink || !this.gameHost || !this.gmPort || !this.webHost || !isNumber(this.gmPort) || !isString(this.minVersion) || !isString(this.whitelistVersion) || !this.updateResUrl) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ const privateKey = fs.readFileSync(path.resolve(__dirname, `../resource/privateK
|
|||||||
const publicKey = fs.readFileSync(path.resolve(__dirname, `../resource/publicKey`)); // 发推送加密的秘钥,和privateKey不是一对
|
const publicKey = fs.readFileSync(path.resolve(__dirname, `../resource/publicKey`)); // 发推送加密的秘钥,和privateKey不是一对
|
||||||
|
|
||||||
|
|
||||||
export async function checkWhiteList(env: string, ip: string, uid: number, serverId: number) {
|
export async function checkWhiteList(env: string, ip: string, uid: number) {
|
||||||
if(ip) {
|
if(ip) {
|
||||||
let result = await WhiteListModel.checkIp(env, ip);
|
let result = await WhiteListModel.checkIp(env, ip);
|
||||||
if(!!result) return true;
|
if(!!result) return true;
|
||||||
}
|
}
|
||||||
if(uid && serverId) {
|
if(uid) {
|
||||||
let result = await WhiteListModel.checkUid(env, serverId, uid);
|
let result = await WhiteListModel.checkUid(env, uid);
|
||||||
if(!!result) return true;
|
if(!!result) return true;
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { STATUS } from '@consts';
|
import { STATUS } from '@consts';
|
||||||
import { GameModel } from '@db/Game';
|
|
||||||
import { Controller } from 'egg';
|
import { Controller } from 'egg';
|
||||||
import { RoleModel } from '@db/Role';
|
import { RoleModel } from '@db/Role';
|
||||||
import { NoticeModel } from '@db/Notice';
|
import { NoticeModel } from '@db/Notice';
|
||||||
@@ -24,13 +23,13 @@ export default class GameController extends Controller {
|
|||||||
return ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR);
|
return ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
const versionFlag = ctx.service.utils.compareVersion(version, curRegion.versionCode);
|
const versionFlag = ctx.service.utils.compareVersion(version, curRegion.minVersion);
|
||||||
if (versionFlag >= 0) {
|
if (versionFlag >= 0) {
|
||||||
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS);
|
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//版本号太低
|
//版本号太低
|
||||||
ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR, { version: curRegion.versionCode });
|
ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR, { version: curRegion.minVersion });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,26 +119,6 @@ export default class GameController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async newServer() {
|
|
||||||
const { ctx } = this;
|
|
||||||
const { serverId, serverType, name, host, port, status } = ctx.request.body;
|
|
||||||
const serverList = await GameModel.getAllServerList();
|
|
||||||
for (let { id, host: preHost, port: prePort } of serverList) {
|
|
||||||
if (preHost === host && prePort === port && id === serverId) {
|
|
||||||
ctx.body = ctx.service.utils.resResult(STATUS.SERVER_EXISTS);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const gameInfo = await GameModel.newServer(serverId, serverType, name, host, port, status);
|
|
||||||
if (gameInfo) {
|
|
||||||
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { gameInfo });
|
|
||||||
} else {
|
|
||||||
ctx.body = ctx.service.utils.resResult(STATUS.NEW_SERVER_ERR);
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async getnotice() {
|
public async getnotice() {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Controller } from 'egg';
|
import { Controller } from 'egg';
|
||||||
import { RegionModel } from '@db/Region';
|
import { RegionModel } from '@db/Region';
|
||||||
import { STATUS } from '@consts';
|
import { STATUS } from '@consts';
|
||||||
|
import { checkWhiteList } from 'app/pubUtils/sysUtil';
|
||||||
|
|
||||||
export default class UpdateController extends Controller {
|
export default class UpdateController extends Controller {
|
||||||
public async getversion() {
|
public async getversion() {
|
||||||
@@ -15,12 +16,13 @@ export default class UpdateController extends Controller {
|
|||||||
|
|
||||||
const env = this.app.config.realEnv;
|
const env = this.app.config.realEnv;
|
||||||
const curRegion = await RegionModel.findRegionByEnv(env);
|
const curRegion = await RegionModel.findRegionByEnv(env);
|
||||||
const { curVersion, updateResUrl, addressType: originAddressType } = curRegion;
|
const { curVersion, whitelistVersion, updateResUrl, addressType: originAddressType } = curRegion;
|
||||||
|
|
||||||
if(originAddressType != addressType) {
|
if(originAddressType != addressType) {
|
||||||
return ctx.body = ctx.service.utils.resResult(STATUS.ADDRESS_ERR);
|
return ctx.body = ctx.service.utils.resResult(STATUS.ADDRESS_ERR);
|
||||||
}
|
}
|
||||||
|
let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid);
|
||||||
|
|
||||||
ctx.body = await ctx.service.update.getUpdateUrl(env, curVersion, updateResUrl);
|
ctx.body = await ctx.service.update.getUpdateUrl(env, isWhiteList? whitelistVersion: curVersion, updateResUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ module.exports = () => {
|
|||||||
if (serverId) {
|
if (serverId) {
|
||||||
let server = await ServerlistModel.findByServerId(serverId);
|
let server = await ServerlistModel.findByServerId(serverId);
|
||||||
if (server && server.maintenance && server.maintenance.isOpen && server.maintenance.startTime < nowSeconds() && server.maintenance.endTime > nowSeconds()) {
|
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);
|
let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid);
|
||||||
if (isWhiteList) {
|
if (isWhiteList) {
|
||||||
return await next();
|
return await next();
|
||||||
} else {
|
} else {
|
||||||
@@ -17,7 +17,7 @@ module.exports = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if(server && server.openTime > nowSeconds()) {
|
} else if(server && server.openTime > nowSeconds()) {
|
||||||
let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid, serverId);
|
let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid);
|
||||||
if (isWhiteList) {
|
if (isWhiteList) {
|
||||||
return await next();
|
return await next();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user