Commit 418706a0 authored by 姜登's avatar 姜登

更新ipwhite

parent c8ab3d1d
Pipeline #18511 passed with stage
in 6 seconds
......@@ -4,7 +4,7 @@
* @Author: jd
* @Date: 2019-02-25 18:59:53
* @LastEditors : jd
* @LastEditTime : 2019-12-24 14:27:40
* @LastEditTime : 2019-12-25 10:59:00
*/
'use strict';
......@@ -18,6 +18,7 @@ class CacheService extends Service {
const { taskPrefix } = config.lockKeys;
this.ipLimitNum = config.ipLimitNum;
this.taskPrefix = taskPrefix;
this.ipwhite = config.ipwhite;
}
/**
......@@ -27,7 +28,7 @@ class CacheService extends Service {
* - exprie: 过期时间
*/
async set({ key, value = {}, exprie = 300 }) {
const { ctx, app, taskPrefix, ipLimitNum } = this;
const { ctx, app, taskPrefix, ipLimitNum, ipwhite } = this;
const data = await app.redis.get(taskPrefix + key);
if (!data || (data && data.status !== 'success')) {
......@@ -42,7 +43,7 @@ class CacheService extends Service {
if (order.appKey === '3BA01E15AC6742E2883ADA4817840D5F' && value.status === 'login') {
const ip = ctx.request.ip.split(',');
const iplimit = await app.redis.get(ip[0]);
if (ip[0] !== '101.71.242.179' && ip[0] !== '122.224.130.226') {
if (!ipwhite.includes(ip[0])) {
if (!iplimit) {
await app.redis.set(ip[0], JSON.stringify({ count: 1 }), 'EX', 15 * 3600);
ctx.logger.info(`ipLimit set ${ip[0]} value:`, 1);
......
......@@ -4,7 +4,7 @@
* @Author: jd
* @Date: 2019-02-25 18:59:53
* @LastEditors : jd
* @LastEditTime : 2019-12-24 14:27:20
* @LastEditTime : 2019-12-25 11:00:32
*/
'use strict';
......@@ -13,12 +13,13 @@ const Service = require('egg').Service;
class TaskService extends Service {
constructor(ctx) {
super(ctx);
const { config: { taskAPI, LOCK_KEY, ipLimitNum } } = this;
const { config: { taskAPI, LOCK_KEY, ipLimitNum, ipwhite } } = this;
this.taskAPI = taskAPI;
this.baseURL = taskAPI.host;
this.citylistURL = taskAPI.citylist;
this.LOCK_KEY = LOCK_KEY;
this.ipLimitNum = ipLimitNum;
this.ipwhite = ipwhite;
}
......@@ -98,9 +99,9 @@ class TaskService extends Service {
return result.data;
}
async iplimit() {
const { ctx, app, ipLimitNum } = this;
const { ctx, app, ipLimitNum, ipwhite } = this;
const ip = ctx.request.ip.split(',');
if (ip[0] !== '101.71.242.179' && ip[0] !== '122.224.130.226') {
if (!ipwhite.includes(ip[0])) {
const iplimit = await app.redis.get(ip[0]);
if (iplimit) {
const { count } = JSON.parse(iplimit);
......
......@@ -87,6 +87,7 @@ module.exports = () => {
};
config.ipLimitNum = 3;
config.ipwhite = ['122.224.130.226', '101.71.242.178', '101.71.242.179', '101.71.242.180', '101.71.242.181', '101.71.242.182'];
config.sequelize = {
datasources: [{
......
......@@ -118,6 +118,8 @@ module.exports = () => {
}],
};
config.ipwhite = ['122.224.130.226', '101.71.242.178', '101.71.242.179', '101.71.242.180', '101.71.242.181', '101.71.242.182'];
config.callbackUrl = process.env.CALLBACK_URL || 'https://dev-nginx.jianbing.com/gjjh5/callback';
return config;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment