Kaynağa Gözat

增加OAID黑名单

dodo hold 1 yıl önce
ebeveyn
işleme
dadc8f630a

+ 2 - 2
molilian.api/Controllers/public/TkController.cs

@@ -83,8 +83,8 @@ namespace molilian.api.Controllers
             var oaid = form.Read("oaid", string.Empty);
             int accountid = form.Read("aid", 0);
 #if DEBUG
-            ip = "127.0.0.1";
-            oaid = "test-oaid";
+            //ip = "127.0.0.1";
+            //oaid = "test-oaid";
 #endif
             return await UnionParseCore.UnionParseAsync(content, channel, ip, oaid, accountid);
         }  

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user


+ 50 - 20
molilian.core/Core/log/base.cs

@@ -408,32 +408,62 @@ namespace molilian.core
                 return Task.CompletedTask;
             });
         }
-        private static void saveClientRequestTotal(TkChannelEnum channel, string ip, string oaid)
+        private async static Task saveClientRequestTotal(TkChannelEnum channel, string ip, string oaid)
         {
-            string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
-            RedisHelper.IncrBy(cacheKey);
-            RedisHelper.Expire(cacheKey, 86400);
-
-            if (!string.IsNullOrEmpty(oaid))
+            await saveClientRequestTotal(channel.ToString(), ip, oaid);
+        }
+        private static async Task saveClientRequestTotal(string channel, string ip, string oaid)
+        {
+            await EndPointCore.ProcessEndPointNodesAsync(node =>
             {
-                cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
-                RedisHelper.IncrBy(cacheKey);
-                RedisHelper.Expire(cacheKey, 86400);
-            }
+                if (string.IsNullOrEmpty(node.redis_server)) return Task.CompletedTask;
+
+
+#if DEBUG
+                switch (node.name)
+                {
+
+                    case "bj":
+                        node.redis_server = "101.200.46.46:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
+                        break;
+                    case "gz":
+                        node.redis_server = "8.138.110.158:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook";
+                        break;
+                    case "coupon1":
+                        node.redis_server = "c1api.molilian.com:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=coupon";
+                        break;
+                    default: return Task.CompletedTask;
+                }
+
+#endif
+
+
+                var redis = RedisClientManager.GetRedisClient(node.redis_server);
+
+                string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
+                redis.IncrBy(cacheKey);
+                redis.Expire(cacheKey, 86400);
+
+                if (!string.IsNullOrEmpty(oaid))
+                {
+                    cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
+                    redis.IncrBy(cacheKey);
+                    redis.Expire(cacheKey, 86400);
+                }
+                return Task.CompletedTask;
+            });
+
         }
-        private static void saveClientRequestTotal(string channel, string ip, string oaid)
+        public static bool InBlacklist(string blacklist, string oaid)
         {
-            string cacheKey = $":cache:{channel}:ip:{DateTime.Now:yyyyMMdd}:{ip}";
-            RedisHelper.IncrBy(cacheKey);
-            RedisHelper.Expire(cacheKey, 86400);
+            if (string.IsNullOrEmpty(blacklist)) return false;
 
-            if (!string.IsNullOrEmpty(oaid))
-            {
-                cacheKey = $":cache:{channel}:oaid:{DateTime.Now:yyyyMMdd}:{oaid}";
-                RedisHelper.IncrBy(cacheKey);
-                RedisHelper.Expire(cacheKey, 86400);
-            }
+            var arr = blacklist.Split(new[] { "\r\n" }, StringSplitOptions.None)
+                   .Select(s => s.Trim()).ToArray();
+            return arr.Contains(oaid);
         }
+
+
         public static int getClientRequestTotalByOAID(TkChannelEnum channel, string oaid)
         {
             if (string.IsNullOrEmpty(oaid)) return 0;

+ 4 - 2
molilian.core/DTO/alimama/TkConfigDTO.cs

@@ -9,15 +9,15 @@ namespace molilian.core
         [Key]
         public int id { get; set; }
         public int ignorePercentage { get; set; } = 0;
-        public int jdIgnorePercentage { get; set; } = 0;
         public string pass_salt { get; set; } = string.Empty;
         public string ignorePercentageCity { get; set; } = string.Empty;
-        public string jdIgnorePercentageCity { get; set; } = string.Empty;
         public int fake_click_min { get; set; }
         public int fake_click_max { get; set; }
         public int fake_click_ttl { get; set; } = 86400;
         public int rt_max { get; set; } = 0;
 
+        public string blacklist_oaid { get; set; } = string.Empty;
+
         /// <summary>
         /// 搜同款超时时间
         /// </summary>
@@ -26,6 +26,8 @@ namespace molilian.core
         public string tk_blacklist_regular { get; set; } = string.Empty;
         public string multi_token_regular { get; set; } = string.Empty;
 
+        public int jdIgnorePercentage { get; set; } = 0;
+        public string jdIgnorePercentageCity { get; set; } = string.Empty;
         public int jd_limit_per_ip_24h { get; set; } = 0;
         public int jd_limit_per_oaid_24h { get; set; } = 0;
 

+ 8 - 2
molilian.core/Plus/Alimama/parse.cs

@@ -468,11 +468,17 @@ namespace molilian.core
                     return true;
                 }
 
+                if (TkLogCore.InBlacklist(config.blacklist_oaid, oaid))
+                {
+                    reason = "OAID黑名单";
+                    return true;
+                }
+
                 int limit_num = config.tk_limit_per_ip_24h;
                 if (limit_num > 0)
                 {
                     int num = TkLogCore.getClientRequestTotalByIp(TkChannelEnum.tb, ip);
-                    if (num > limit_num)
+                    if (num >= limit_num)
                     {
                         reason = "IP控制";
                         return true;
@@ -482,7 +488,7 @@ namespace molilian.core
                 if (limit_num > 0)
                 {
                     int num = TkLogCore.getClientRequestTotalByOAID(TkChannelEnum.tb, oaid);
-                    if (num > limit_num)
+                    if (num >= limit_num)
                     {
                         reason = "OAID控制";
                         return true;

+ 8 - 2
molilian.core/Plus/JDUnion/base.cs

@@ -122,11 +122,17 @@ namespace molilian.core
                     return true;
                 }
 
+                if (TkLogCore.InBlacklist(config.blacklist_oaid, oaid))
+                {
+                    reason = "OAID黑名单";
+                    return true;
+                }
+
                 int limit_num = config.jd_limit_per_ip_24h;
                 if (limit_num > 0)
                 {
                     int num = TkLogCore.getClientRequestTotalByIp(TkChannelEnum.jd, ip);
-                    if (num > limit_num)
+                    if (num >= limit_num)
                     {
                         reason = "IP控制";
                         return true;
@@ -136,7 +142,7 @@ namespace molilian.core
                 if (limit_num > 0)
                 {
                     int num = TkLogCore.getClientRequestTotalByOAID(TkChannelEnum.jd, oaid);
-                    if (num > limit_num)
+                    if (num >= limit_num)
                     {
                         reason = "OAID控制";
                         return true;

+ 8 - 2
molilian.core/Plus/ks/base.cs

@@ -50,11 +50,17 @@ namespace molilian.core
                     return true;
                 }
 
+                if (TkLogCore.InBlacklist(config.blacklist_oaid, oaid))
+                {
+                    reason = "OAID黑名单";
+                    return true;
+                }
+
                 int limit_num = config.ks_limit_per_ip_24h;
                 if (limit_num > 0)
                 {
                     int num = TkLogCore.getClientRequestTotalByIp(TkChannelEnum.ks, ip);
-                    if (num > limit_num)
+                    if (num >= limit_num)
                     {
                         reason = "IP控制";
                         return true;
@@ -65,7 +71,7 @@ namespace molilian.core
                 if (limit_num > 0)
                 {
                     int num = TkLogCore.getClientRequestTotalByOAID(TkChannelEnum.ks, oaid);
-                    if (num > limit_num)
+                    if (num >= limit_num)
                     {
                         reason = "OAID控制";
                         return true;

+ 8 - 2
molilian.core/Plus/pdd/base.cs

@@ -63,11 +63,17 @@ namespace molilian.core
                     return true;
                 }
 
+                if (TkLogCore.InBlacklist(config.blacklist_oaid, oaid))
+                {
+                    reason = "OAID黑名单";
+                    return true;
+                }
+
                 int limit_num = config.pdd_limit_per_ip_24h;
                 if (limit_num > 0)
                 {
                     int num = TkLogCore.getClientRequestTotalByIp(TkChannelEnum.pdd, ip);
-                    if (num > limit_num)
+                    if (num >= limit_num)
                     {
                         reason = "IP控制";
                         return true;
@@ -77,7 +83,7 @@ namespace molilian.core
                 if (limit_num > 0)
                 {
                     int num = TkLogCore.getClientRequestTotalByOAID(TkChannelEnum.pdd, oaid);
-                    if (num > limit_num)
+                    if (num >= limit_num)
                     {
                         reason = "OAID控制";
                         return true;

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor