瀏覽代碼

h5st设定超时和容错处理

dodo hold 1 年之前
父節點
當前提交
d8a9be2ac1

+ 14 - 0
molilian.api/Controllers/public/ApiController.cs

@@ -14,6 +14,7 @@ using static dodohold.core.ZTOExpress.CreateOrderArgs;
 using TencentCloud.Lighthouse.V20200324.Models;
 using TencentCloud.Ame.V20190916.Models;
 using TencentCloud.Omics.V20221128.Models;
+using System.Threading.Channels;
 
 namespace molilian.api.Controllers
 {
@@ -131,6 +132,8 @@ namespace molilian.api.Controllers
             var debug = form.Read("debug", false);
             var aid = form.Read("aid", 0);
 
+            int count = form.Read("count", 0);
+
             if (!string.IsNullOrEmpty(url))
             {
                 var bytes = new WebClientUtility().Request(url).ResponseBody;
@@ -143,9 +146,20 @@ namespace molilian.api.Controllers
                 oaid = $"{rand.Next(100000, 999999)}-{rand.Next(100000, 999999)}-{rand.Next(100000, 999999)}";
             }
 
+            if (count > 1)
+            {
+                for (int i = 0; i < count; i++)
+                {
+                    _ = core.PromotionQueryAsync(img, oaid, ip, scene, recommand, debug, aid);
+                }
+                return new APIResult(new { msg = "ok" });
+            }
             return await core.PromotionQueryAsync(img, oaid, ip, scene, recommand, debug, aid);
         }
 
 
+
+
+
     }
 }

+ 2 - 0
molilian.api/Controllers/public/TestController.cs

@@ -50,6 +50,7 @@ namespace molilian.api.Controllers
 
 
         [HttpGet]
+        //第一部 先加一个网卡,
         public async Task<ActionResult> CreateNetworkInterface(int id, string ecsid)
         {
             AliyunCore core = new AliyunCore(id);
@@ -61,6 +62,7 @@ namespace molilian.api.Controllers
 
 
         [HttpGet]
+        //第二部 给网卡绑定很多个辅助ip
         public async Task<ActionResult> EcsAssignPrivateIpAddresses(int id, string ecsid, int count)
         {
             AliyunCore core = new AliyunCore(id);

File diff suppressed because it is too large
+ 0 - 0
molilian.api/Properties/PublishProfiles/latest.pubxml.user


+ 12 - 1
molilian.api/Properties/launchSettings.json

@@ -4,7 +4,7 @@
       "commandName": "Project",
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "environmentVariables": {
+      "environmentVariables3": {
         "ASPNETCORE_ENVIRONMENT": "Development",
         "EndPoint": "bj",
         "NtfyServer": "https://ntfy.yunhui800.com/5Sq9BytXXM5WDY3G",
@@ -15,6 +15,17 @@
         "CenterDB": "",
         "CenterRedis": ""
       },
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development",
+        "EndPoint": "bj5",
+        "NtfyServer": "https://ntfy.yunhui800.com/5Sq9BytXXM5WDY3G",
+        "ANPush": "",
+        "DBType": "MySQL",
+        "DBConfig": "Server=49.7.231.136; Port=3306; Database=taoke; Uid=taoke; Pwd=btJ2h2TwFPka8hi2;SslMode=None;CharSet=utf8mb4;ConnectionTimeout=60;",
+        "RedisConfig": "49.7.231.136:6379,password=pKBiS4ka2IpXayIdcx00,defaultDatabase=0,idleTimeout=20000,preheat=3,tryit=2,ssl=false,prefix=webhook",
+        "CenterDB": "",
+        "CenterRedis": ""
+      },
       "environmentVariables2": {
         "ASPNETCORE_ENVIRONMENT": "Development",
         "EndPoint": "cadmin",

+ 3 - 7
molilian.core/Core/ProxyNodesCore.cs

@@ -57,13 +57,6 @@ namespace molilian.core
                                    .FirstOrDefault();
             if (ProxyNodesDTO == null) return null;
 
-#if DEBUG
-            return new WebProxy
-            {
-                Address = new Uri("http://bjapi.molilian.com:20010"),
-                Credentials = new NetworkCredential("molilian", "Bhquvmkn8zLO36lGjuqk")
-            };
-#endif
 
             return new WebProxy
             {
@@ -71,6 +64,9 @@ namespace molilian.core
                 Credentials = new NetworkCredential(ProxyNodesDTO.username, ProxyNodesDTO.password)
             };
         }
+
+
+
         public static WebProxy? GetOne(int nodeid)
         {
             var list = List();

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

@@ -169,7 +169,6 @@ namespace molilian.core
 
                 //result.url = data.Url;
                 result.url = $"https://mo.m.taobao.com/etao/search_pic_detail?appKey={account.appkey}&oaid={oaid}&pid={account.open_pid}";
-
                 string cookies = string.Empty;
                 var requestTask = Task.Run(async () =>
                 {

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

@@ -31,6 +31,8 @@ namespace molilian.core
         public int jd_limit_per_ip_24h { get; set; } = 0;
         public int jd_limit_per_oaid_24h { get; set; } = 0;
         public string jd_blacklist_regular { get; set; } = string.Empty;
+        public string jd_h5st_sign_url { get; set; } = string.Empty;
+        public string jd_h5st_sign_version { get; set; } = string.Empty;
 
         public int tk_limit_per_ip_24h { get; set; } = 0;
         public int tk_limit_per_oaid_24h { get; set; } = 0;

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

@@ -14,6 +14,7 @@
         public string company { get; set; } = string.Empty;
         public string phone { get; set; } = string.Empty;
         public string description { get; set; } = string.Empty;
+        public string note { get; set; } = string.Empty;
         public string tb_token { get; set; } = string.Empty;
         public string floorId { get; set; } = string.Empty;
         public string refpid { get; set; } = string.Empty;

+ 31 - 15
molilian.core/Plus/JDUnion/H5stHack.cs

@@ -9,12 +9,13 @@ namespace molilian.core
 
         public async Task<string> H5stHack(dynamic querystring, CancellationToken cancellationToken)
         {
+            string body = string.Empty;
             string useragent = _account.user_agent;
             if (string.IsNullOrEmpty(useragent)) useragent = ProviderFakeUserAgent.RandomComputer;
 
             var args = new
             {
-                version = "4.9.7",
+                version = _config.jd_h5st_sign_version,
                 body = querystring,
                 pin = _account.pin,
                 ua = _account.user_agent,
@@ -22,26 +23,41 @@ namespace molilian.core
             };
 
 
-            string data = args.Convert2Json();
-            string url = "http://localhost:3001/h5st";
+            try
+            {
+                string data = args.Convert2Json();
+                string url = _config.jd_h5st_sign_url;
+                if (string.IsNullOrEmpty(url)) url = "http://localhost:3001/h5st";
+
 #if DEBUG
-            url = "http://bjapi.molilian.com:3001/h5st";
+                url = "http://bjapi.molilian.com:3001/h5st";
 #endif
 
-            WebClientUtility client = new WebClientUtility();
-            client.SetContentType("application/json");
-            client.Post(data);
-            var response = await client.RequestAsync(url, "POST", cancellationToken);
+                WebClientUtility client = new WebClientUtility();
+                client.SetContentType("application/json");
+                client.Timeout = TimeSpan.FromMicroseconds(2000);
+                client.Post(data);
+                var response = await client.RequestAsync(url, "POST", cancellationToken);
+
+                body = response.Body();
+                var root = body.Convert2JsonElement();
+                int code = root.Read<int>("code");
+                string qs = root.PathRead<string>("body.qs");
+                if (code == 200)
+                {
+                    return qs;
+                }
+                _ = new LoggerLibrary("JdUnion", "h5st").Info(body).SaveAsync();
 
-            string body = response.Body();
-            var root = body.Convert2JsonElement();
-            int code = root.Read<int>("code");
-            string qs = root.PathRead<string>("body.qs");
-            if (code == 200)
+            }
+            catch (Exception ex)
             {
-                return qs;
+                _ = new LoggerLibrary("JdUnion", "h5st_error")
+                    .Info(body)
+                    .Info(ex.Message, ex.StackTrace)
+                    .SaveAsync();
+
             }
-            _ = new LoggerLibrary("JdUnion", "h5st").Info(body).SaveAsync();
             return string.Empty;
         }
 

+ 8 - 0
molilian.core/Plus/TaobaoOpen/TaobaoOpenPlus.cs

@@ -1,5 +1,6 @@
 using dodohold.core;
 using Org.BouncyCastle.Ocsp;
+using Sayaka.Common;
 using System.Net;
 using System.Text.Json;
 using System.Xml;
@@ -129,8 +130,12 @@ namespace molilian.core
             string url = GetRecommendUrl(_pid, oaid, token, type);
             string body = string.Empty;
 
+
+            string ua = ProviderFakeUserAgent.RandomMobile;
+
             var client = new WebClientUtility();
             client.Proxy = _proxy;
+            client.UserAgent = ua;
 
             if (string.IsNullOrEmpty(cookies))
             {
@@ -143,6 +148,7 @@ namespace molilian.core
                 {
                     new LoggerLibrary("debug", oaid)
                         .Info("第一次 cookies 初始化")
+                        .Info(ua, _proxy?.Address?.AbsoluteUri)
                         .Info(url, body)
                         .Save();
                 }
@@ -154,6 +160,7 @@ namespace molilian.core
 
             client = new WebClientUtility();
             client.Proxy = _proxy;
+            client.UserAgent = ua;
 
             if (!string.IsNullOrEmpty(cookies)) client.SetCookies(cookies);
             var response = await client.RequestAsync(url, "GET", cancellationToken);
@@ -163,6 +170,7 @@ namespace molilian.core
             {
                 new LoggerLibrary("debug", oaid)
                     .Info("GetRecommendData")
+                    .Info(ua, _proxy?.Address?.AbsoluteUri)
                     .Info(url, cookies)
                     .Info(body)
                     .Save();

+ 8 - 4
taobao-sdk-netcore-auto_1719572210878-20240628-source/Util/WebUtils.cs

@@ -250,11 +250,16 @@ namespace Top.Api.Util
                 req = (HttpWebRequest)WebRequest.Create(url);
             }
 
-            if (this._disableWebProxy)
+            //if (this._disableWebProxy)
+            //{
+            //    req.Proxy = null;
+            //}
+            if (Proxy != null)
             {
-                req.Proxy = null;
-            }
+                req.Proxy = Proxy;
+                req.UseDefaultCredentials = false;
 
+            }
             if (headerParams != null && headerParams.Count > 0)
             {
                 foreach (string key in headerParams.Keys)
@@ -270,7 +275,6 @@ namespace Top.Api.Util
             req.Accept = "text/xml,text/javascript";
             req.Timeout = this._timeout;
             req.ReadWriteTimeout = this._readWriteTimeout;
-            req.Proxy = Proxy;
             return req;
         }
 

Some files were not shown because too many files changed in this diff