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

@@ -475,6 +475,7 @@ export const FILENAME = {
DIC_AUCTION_REWARD: 'dic_zyz_auctionReward',
DIC_PVP_DIFFICULTRATIO: 'dic_zyz_pvp_difficultRatio',
DIC_PVP_DAILY_TASK: 'dic_zyz_pvp_dailyTask',
DIC_WHITE_IP: 'dic_pay_white_ip',
}
export const WAR_RELATE_TABLES = [

View File

@@ -94,6 +94,7 @@ import { dicExpeditionSubAttr, loadExpeditionSubAttr } from './dictionary/DicExp
import { dicAuctionPool, loadAuctionReward } from './dictionary/DicAuctionReward';
import { dicGuildTrainInfo, loadGuildTrainInfo } from './dictionary/DicGuildTrainInfo';
import { dicPvpDifficultRatio, loadPvpDifficultRatio } from './dictionary/DicPvpDifficultRatio';
import { dicWhiteIp, loadWhiteIp } from './dictionary/DicWhiteIp';
import { pick } from "underscore";
export const gameData = {
@@ -237,7 +238,8 @@ export const gameData = {
holiday: dicHoliday,
expeditionSubAttr: dicExpeditionSubAttr,
auctionPool: dicAuctionPool,
auctionTime: new Map<number, { hour: number, minute: number, seconds: number}>()
auctionTime: new Map<number, { hour: number, minute: number, seconds: number}>(),
whiteip: dicWhiteIp,
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据
@@ -937,6 +939,7 @@ function loadDatas() {
loadAuctionReward();
loadGuildTrainInfo();
loadPvpDifficultRatio();
loadWhiteIp();
}
// 重载dicParam

View File

@@ -0,0 +1,23 @@
// 支付回调白名单
import {readFileAndParse, parseNumberList, parseGoodStr} from '../util'
import { FILENAME } from '../../consts'
import { RewardInter } from '../interface';
export interface DicWhiteIp {
// 渠道
readonly channel: string;
// ip
readonly ip: number;
}
export const dicWhiteIp: string[] = [];
export function loadWhiteIp() {
dicWhiteIp.splice(0, dicWhiteIp.length);
let arr = readFileAndParse(FILENAME.DIC_WHITE_IP);
arr.forEach(o => {
dicWhiteIp.push(o.ip);
});
arr = undefined;
}

View File

@@ -0,0 +1,186 @@
[
{
"channel": "37",
"ip": "14.18.237.10"
},
{
"channel": "37",
"ip": "14.18.237.59"
},
{
"channel": "37",
"ip": "14.18.237.166"
},
{
"channel": "37",
"ip": "14.18.237.168"
},
{
"channel": "37",
"ip": "14.18.237.186"
},
{
"channel": "37",
"ip": "14.18.237.188"
},
{
"channel": "37",
"ip": "14.18.237.118"
},
{
"channel": "37",
"ip": "183.60.124.218"
},
{
"channel": "37",
"ip": "14.18.237.199"
},
{
"channel": "37",
"ip": "14.18.237.7"
},
{
"channel": "37",
"ip": "14.18.237.29"
},
{
"channel": "37",
"ip": "14.18.237.28"
},
{
"channel": "37",
"ip": "121.201.25.10"
},
{
"channel": "37",
"ip": "121.201.25.59"
},
{
"channel": "37",
"ip": "121.201.25.166"
},
{
"channel": "37",
"ip": "121.201.25.168"
},
{
"channel": "37",
"ip": "121.201.25.186"
},
{
"channel": "37",
"ip": "121.201.25.188"
},
{
"channel": "37",
"ip": "121.201.25.118"
},
{
"channel": "37",
"ip": "121.201.25.199"
},
{
"channel": "37",
"ip": "121.201.25.28"
},
{
"channel": "37",
"ip": "121.201.25.29"
},
{
"channel": "37",
"ip": "121.201.25.7"
},
{
"channel": "37",
"ip": "193.112.165.10 "
},
{
"channel": "37",
"ip": "129.204.167.106"
},
{
"channel": "37",
"ip": "134.175.206.137"
},
{
"channel": "37",
"ip": "106.55.68.195"
},
{
"channel": "37",
"ip": "106.55.81.96"
},
{
"channel": "37",
"ip": "106.55.69.50"
},
{
"channel": "37",
"ip": "42.194.242.152"
},
{
"channel": "37",
"ip": "42.194.234.254"
},
{
"channel": "37",
"ip": "42.194.233.254"
},
{
"channel": "37",
"ip": "42.194.230.180"
},
{
"channel": "37",
"ip": "42.194.226.92"
},
{
"channel": "37",
"ip": "221.5.32.10"
},
{
"channel": "37",
"ip": "221.5.32.59"
},
{
"channel": "37",
"ip": "221.5.32.166"
},
{
"channel": "37",
"ip": "221.5.32.168"
},
{
"channel": "37",
"ip": "221.5.32.186"
},
{
"channel": "37",
"ip": "221.5.32.188"
},
{
"channel": "37",
"ip": "221.5.32.118"
},
{
"channel": "37",
"ip": "221.5.110.26"
},
{
"channel": "37",
"ip": "221.5.32.199"
},
{
"channel": "37",
"ip": "221.5.32.7"
},
{
"channel": "37",
"ip": "221.5.32.29"
},
{
"channel": "37",
"ip": "221.5.32.28"
}
]

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, '');