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

更新ipwhite

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