✨ feat(选服): 服务器即将开启状态不可进入

This commit is contained in:
luying
2022-10-19 20:14:48 +08:00
parent 1870673fbd
commit de90f05301
5 changed files with 30 additions and 4 deletions
+13 -1
View File
@@ -14,6 +14,9 @@ import { pick } from 'underscore';
import { Reward } from '../domain/battleField/pvp';
import { CheckMeterial } from './role/checkMaterial';
import IP2Region from "ip2region";
import { getServerCreateTime } from './redisService';
import { checkWhiteList } from '../pubUtils/sysUtil';
import { nowSeconds } from '../pubUtils/timeUtil';
const query = new IP2Region({ disableIpv6: true });
@@ -301,4 +304,13 @@ export async function getIpLocation(ip: string) {
} catch(e) {
console.error('setIpLocation', e)
}
}
}
// 服务器是否开启
export async function checkServerIsOpen(serverId: number, ip: string, uid: number) {
let isWhiteList = await checkWhiteList(pinus.app.get('env'), ip, uid, serverId);
if(isWhiteList) return true;
let serverTime = await getServerCreateTime(serverId);
return serverTime <= nowSeconds();
}