sdk: ip限制

This commit is contained in:
luying
2021-11-09 20:01:36 +08:00
parent 89b583d0f1
commit d77ee9dfc9
5 changed files with 220 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import { pick } from 'underscore';
import { UserOrderModel } from '@db/UserOrder';
import { nowSeconds } from 'app/pubUtils/timeUtil';
import { RoleModel } from '@db/Role';
import { gameData } from 'app/pubUtils/data';
/**
* Test Service
@@ -24,10 +25,14 @@ export default class Sdk extends Service {
public async pay37Callback(params: PayCallback37Data) {
const { ctx } = this;
const { app } = ctx;
const ip = ctx.request.ip;
let checkResult = ctx.service.sdk.check37Sign(params);
if(!checkResult) return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.MD5_ERR, '');
// ip校验
if(gameData.whiteip.indexOf(ip) == -1) {
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.IP_LIMIT, '');
}
if(nowSeconds() - params.time > 15 * 60) {
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.TIME_IS_EXPIRED, '');