后台:修改白名单
This commit is contained in:
@@ -9,7 +9,7 @@ module.exports = () => {
|
||||
if (serverId) {
|
||||
let server = await ServerlistModel.findByServerId(serverId);
|
||||
if (server && server.maintenance && server.maintenance.isOpen && server.maintenance.startTime < nowSeconds() && server.maintenance.endTime > nowSeconds()) {
|
||||
let isWhiteList = await checkWhiteList(ctx.tel, ctx.request.ip);
|
||||
let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid, serverId);
|
||||
if (isWhiteList) {
|
||||
await next();
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Context } from 'egg';
|
||||
|
||||
module.exports = () => {
|
||||
return async function parmsDecode(ctx: Context, next) {
|
||||
|
||||
let xRealIp = typeof ctx.header['x-real-ip'] == 'string'? ctx.header['x-real-ip']: ctx.header['x-real-ip'][0];
|
||||
ctx.clientIp = xRealIp||ctx.request.ip;
|
||||
console.log('*****', ctx.clientIp);
|
||||
await next();
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ import { UserModel } from '@db/User';
|
||||
|
||||
module.exports = () => {
|
||||
return async function tokenParser(ctx, next) {
|
||||
|
||||
if (!ctx.request.body || !ctx.request.body.token) {
|
||||
console.error('token not found');
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Application } from 'egg';
|
||||
|
||||
export default (app: Application) => {
|
||||
const { controller, router } = app;
|
||||
|
||||
const tokenParser = app.middleware.tokenParser();
|
||||
const checkMainten = app.middleware.checkMainten();
|
||||
router.get('/dev', controller.home.dev);
|
||||
|
||||
@@ -29,7 +29,6 @@ export default class Auth extends Service {
|
||||
|
||||
public async deviceLogin(isGuest: boolean, token: string, deviceId: string, platform: string, pkgName: string, serverType: string, getuiCID: string) {
|
||||
const ctx = this.ctx;
|
||||
const ip = ctx.request.ip;
|
||||
|
||||
let user = await UserModel.findUserByToken(token);
|
||||
|
||||
@@ -46,7 +45,7 @@ export default class Auth extends Service {
|
||||
});
|
||||
} else {
|
||||
|
||||
user = await UserModel.createUser(isGuest, tel, token, platform, pkgName, serverType, deviceId, 0, ip);
|
||||
user = await UserModel.createUser(isGuest, tel, token, platform, pkgName, serverType, deviceId, 0, ctx.clientIp);
|
||||
if (getuiCID) {//更新个推cid
|
||||
await UserModel.updateGetuiCID(tel, getuiCID);
|
||||
}
|
||||
@@ -66,7 +65,7 @@ export default class Auth extends Service {
|
||||
}
|
||||
} else {
|
||||
const token = ctx.service.utils.generateStr(256);
|
||||
user = await UserModel.updateToken(user.tel, token, deviceId, ip);
|
||||
user = await UserModel.updateToken(user.tel, token, deviceId, ctx.clientIp);
|
||||
if (getuiCID) {//更新个推cid
|
||||
await UserModel.updateGetuiCID(user.tel, getuiCID);
|
||||
}
|
||||
@@ -188,7 +187,6 @@ export default class Auth extends Service {
|
||||
*/
|
||||
public async smsLogin(tel: string, deviceId: string, code: string, platform: string, pkgName: string, serverType: string, getuiCID: string) {
|
||||
const ctx = this.ctx;
|
||||
const ip = ctx.request.ip;
|
||||
// 参数检查
|
||||
const telVerify = this.checkTelNo(tel);
|
||||
if (telVerify.status !== 0) {
|
||||
@@ -218,7 +216,7 @@ export default class Auth extends Service {
|
||||
|
||||
// 用户注册登录
|
||||
const token = ctx.service.utils.generateStr(256);
|
||||
const user = await UserModel.createOrUpdate(false, tel, token, platform, pkgName, serverType, deviceId, ip);
|
||||
const user = await UserModel.createOrUpdate(false, tel, token, platform, pkgName, serverType, deviceId, ctx.clientIp);
|
||||
if (getuiCID) {//更新个推cid
|
||||
await UserModel.updateGetuiCID(tel, getuiCID);
|
||||
}
|
||||
@@ -403,7 +401,6 @@ export default class Auth extends Service {
|
||||
const { channelType, pst, clientId, deviceId, platform, platformAppid, childGameId, pkgName, serverType, getuiCID } = params;
|
||||
|
||||
const ctx = this.ctx;
|
||||
const ip = ctx.request.ip;
|
||||
|
||||
let requestResult = await loginValidata(channelType, { clientId, pst, platformAppid, childGameId });
|
||||
if(!requestResult) return this.ctx.service.utils.resResult(STATUS.CHANNEL_ERR);
|
||||
@@ -416,7 +413,7 @@ export default class Auth extends Service {
|
||||
const token = ctx.service.utils.generateStr(256);
|
||||
let user = await UserModel.createOrUpdateChannelUser(channelId, channelType, {
|
||||
...requestResult.data, childGameId, platformAppid
|
||||
}, token, platform, pkgName, serverType, deviceId, ip);
|
||||
}, token, platform, pkgName, serverType, deviceId, ctx.clientIp);
|
||||
if (getuiCID) {//更新个推cid
|
||||
await UserModel.updateGetuiCIDByChannel(channelId, getuiCID);
|
||||
}
|
||||
|
||||
@@ -29,14 +29,12 @@ export default class Sdk extends Service {
|
||||
public async pay37Callback(params: PayCallback37Data) {
|
||||
const { ctx } = this;
|
||||
const { app } = ctx;
|
||||
let ip = typeof ctx.header['x-real-ip'] == 'string'? ctx.header['x-real-ip']: ctx.header['x-real-ip'][0];
|
||||
console.log('*****pay37Callback', ip)
|
||||
|
||||
let checkResult = this.check37Sign(params);
|
||||
if(!checkResult) return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.MD5_ERR, '');
|
||||
|
||||
console.log('*****pay37Callback check sign ok')
|
||||
if(gameData.whiteip.indexOf(ip) == -1) {
|
||||
if(gameData.whiteip.indexOf(ctx.clientIp) == -1) {
|
||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.IP_LIMIT, '');
|
||||
}
|
||||
|
||||
@@ -95,9 +93,6 @@ export default class Sdk extends Service {
|
||||
}
|
||||
|
||||
public treatRoleOrGuildNameValidate(params: RoleNameCallBackParam|GuildNameCallBackParam|GetGuildInfoByUserParam) {
|
||||
const { ctx } = this;
|
||||
let ip = ctx.header['x-real-ip'];
|
||||
console.log('*****', ip)
|
||||
|
||||
if(!params.checkParams()) return SDK_37_TREAT_CODE.WRONG_PARAMS;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export default (appInfo: EggAppInfo) => {
|
||||
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
|
||||
};
|
||||
// add your egg config in here
|
||||
config.middleware = [ 'parmsDecode' ];
|
||||
config.middleware = [ 'parmsDecode', 'getIp' ];
|
||||
|
||||
config.mongoose = {
|
||||
url: 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', // 内网
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
"distribute": "cross-env EGG_SERVER_ENV=distribute npm run dev",
|
||||
"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"
|
||||
"stable": "cross-env EGG_SERVER_ENV=stable npm run dev",
|
||||
"deve": "cross-env EGG_SERVER_ENV=dev npm run dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/underscore": "^1.11.3",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import 'egg';
|
||||
import ExportCheckMainten from '../../../app/middleware/checkMainten';
|
||||
import ExportGetIp from '../../../app/middleware/getIp';
|
||||
import ExportGmTokenParser from '../../../app/middleware/gmTokenParser';
|
||||
import ExportParmsDecode from '../../../app/middleware/parmsDecode';
|
||||
import ExportTokenParser from '../../../app/middleware/tokenParser';
|
||||
@@ -10,6 +11,7 @@ import ExportTokenParser from '../../../app/middleware/tokenParser';
|
||||
declare module 'egg' {
|
||||
interface IMiddleware {
|
||||
checkMainten: typeof ExportCheckMainten;
|
||||
getIp: typeof ExportGetIp;
|
||||
gmTokenParser: typeof ExportGmTokenParser;
|
||||
parmsDecode: typeof ExportParmsDecode;
|
||||
tokenParser: typeof ExportTokenParser;
|
||||
|
||||
Reference in New Issue
Block a user