Procházet zdrojové kódy

京东转链增加地区控制;

dodo hold před 2 roky
rodič
revize
b1bd1afbcd

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user


+ 1 - 0
molilian.core/Core/taoke/UnionParseCore.cs

@@ -451,6 +451,7 @@ namespace molilian.core
                     _ = TkLogCore.ParseLogAsync(result);
                     return new APIResult(result);
                 }
+                 
                 result = await JdUnionPlus.JdParseAsync(account, content, result, cancellationToken);
             }
             catch (Exception ex)

+ 1 - 0
molilian.core/DTO/alimama/TkConfigDTO.cs

@@ -12,6 +12,7 @@ namespace molilian.core
         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;

+ 1 - 1
molilian.core/Plus/Alimama/parse.cs

@@ -245,7 +245,7 @@ namespace molilian.core
 
 
 
-        static bool IgnoreRegionIncluded(string _ignoreRegions, string? ipInfo, out string regionInfo)
+        public static bool IgnoreRegionIncluded(string _ignoreRegions, string? ipInfo, out string regionInfo)
         {
             regionInfo = string.Empty;
             if (string.IsNullOrEmpty(_ignoreRegions) || string.IsNullOrEmpty(ipInfo)) return false;

+ 12 - 0
molilian.core/Plus/JDUnion/JdUnionPlus.cs

@@ -256,6 +256,18 @@ namespace molilian.core
                 result.deeplink_url = GetDeeplink(url);
                 return result;
             }
+
+
+            //============================== 放弃转链-地区过滤 ==============================
+            bool is_ignore2 = FlowControlIgnoreRequest(out string reason);
+            if (is_ignore2)
+            {
+                result.success = false;
+                result.message = "放弃转链";
+                result.reason = reason;
+                return result;
+            }
+
             result.shortLinkurl = await plus.GetPromotionAsync(account.site_id, url, cancellationToken);
 
             var success = !string.IsNullOrEmpty(result.shortLinkurl);

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

@@ -27,6 +27,7 @@ namespace molilian.core
     {
         string _app_key;
         string _app_secret;
+        static Random _random = new Random();
         public JdUnionPlus(string app_key, string app_secret)
         {
             _app_key = app_key;
@@ -109,29 +110,51 @@ namespace molilian.core
             return body;
         }
 
-
         public static bool ShouldIgnoreRequest(string ip, string oaid, out string reason)
         {
             reason = string.Empty;
             try
             {
+                // IP和流量控制
                 var config = TkConfigCore.Get();
+                string ignorePercentageCity = config.jdIgnorePercentageCity;
+                string? ipInfo = IP2RegionPlus.Search(ip);
+                if (AlimamaPlus.IgnoreRegionIncluded(ignorePercentageCity, ipInfo, out string regionInfo))
+                {
+                    reason = $"地区控制:{regionInfo}";
+                    return true;
+                }
+            }
+            catch (Exception ex)
+            {
+                reason = "配置异常";
+            }
+            return false;
+        }
 
+        public static bool FlowControlIgnoreRequest(out string reason)
+        {
+            reason = string.Empty;
+            try
+            {
+                // IP和流量控制
+                var config = TkConfigCore.Get();
                 int ignorePercentage = config.jdIgnorePercentage;
                 if (ignorePercentage == 0) return false;
-                Random random = new Random();
-                var randomValue = (decimal)random.Next(0, 100);
-                bool result = randomValue <= ignorePercentage; // 如果生成的随机数小于忽略百分比,则返回 true,表示需要忽略请求
-                if (result) reason = "流量控制";
-                return result;
 
+                var randomValue = (decimal)_random.Next(0, 100);
+                bool result = randomValue <= ignorePercentage; // 如果生成的随机数小于忽略百分比,则返回 true,表示需要忽略请求
+                if (result)
+                {
+                    reason = "流量控制";
+                    return true;
+                }
             }
             catch (Exception ex)
             {
                 reason = $"配置异常";
-                return true;
             }
+            return false;
         }
-
     }
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů