소스 검색

增加挂机节点配置;
增加账号下探网址开关;

dodo hold 2 년 전
부모
커밋
966ba2ff5e

+ 23 - 0
molilian.api/Controllers/admin/TaobaoController.cs

@@ -69,6 +69,7 @@ namespace molilian.api.Controllers
                 case "enable_coupon":
                 case "enable_sync_order":
                 case "enable_promotionQuery":
+                case "enable_deep_url":
                 case "status":
                     bool bVal = val.Equals("True");
                     result = new DBContext.Table("tk_pool")
@@ -77,6 +78,28 @@ namespace molilian.api.Controllers
                            .Where("id=@id", new { id })
                            .Update();
                     break;
+                case "check_status":
+                    //检查状态
+                    var arr = EndPointCore.NotifyCheckDeepUrl(id);
+                    string suspended_endpoint = string.Empty;
+                    var log = new LoggerLibrary("check_suspended_endpoint");
+
+                    foreach ((string node, string message) in arr)
+                    {
+                        log.Info(node, message);
+                        if (message.Contains("霸下验证码"))
+                        {
+                            suspended_endpoint += $"{node},";
+                        }
+                    }
+                    result = new DBContext.Table("tk_pool")
+                           .Add("suspended_endpoint", suspended_endpoint)
+                           .Add("last_time", DateTime.Now)
+                           .Where("id=@id", new { id })
+                           .Update();
+
+                    log.SaveAsync();
+                    break;
                 default:
                     return new APIResult(new { data = new { success = false, msg = "更新失败,未授权操作" } });
             }

+ 53 - 0
molilian.api/Controllers/public/TaskController.cs

@@ -8,6 +8,8 @@ using System.Net;
 using System.Threading.Channels;
 using TencentCloud.Cdwch.V20200915.Models;
 using COSXML.Network;
+using System.Security.Cryptography;
+using System.Threading;
 
 namespace molilian.api.Controllers
 {
@@ -691,5 +693,56 @@ namespace molilian.api.Controllers
         }
 
 
+
+        [HttpGet]
+        public async Task<ActionResult> CheckDeepUrl(int accountid)
+        {
+            var postContent = "88✔7Fi43dJwWpV£ https://m.tb.cn/h.g92hfR4JLgn7yvG  MF7997 我分享给你了一个超赞的内容,快来看看吧";
+            var channel = "tb";
+            var ip = "127.0.0.1";
+            var oaid = "test-oaid";
+
+            bool success = false;
+            string message;
+
+            //============================== 放弃转链-没有匹配账号 ==============================
+            TkPoolDTO? account = TkPoolCore.GetOne(accountid);
+            if (account == null)
+            {
+                return new APIResult(new
+                {
+                    success = false,
+                    message = "没有匹配账号",
+                });
+            }
+            var alimama = new AlimamaPlus(account);
+
+            TkDataDTO result = new TkDataDTO();
+            string url = AlimamaPlus.GetLink(postContent);
+            if (string.IsNullOrEmpty(url))
+            {
+                return new APIResult(new
+                {
+                    success = false,
+                    message = "无效URL",
+                });
+            }
+
+            (success, string content) = await alimama.GetDesiredUrlAsync(url);
+            if (content.Contains("霸下通用 web 页面-验证码"))
+            {
+                message = "霸下验证码";
+            }
+            else
+            {
+                message = content;
+            }
+            return new APIResult(new
+            {
+                success = true,
+                message,
+            });
+        }
+
     }
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
molilian.api/Properties/PublishProfiles/https___ccr.ccs.tencentyun.com_shaobin.pubxml.user


+ 39 - 0
molilian.core/Core/EndPointCore.cs

@@ -145,6 +145,45 @@ Server=rm-2ze74506m3gfsqe7mco.rwlb.rds.aliyuncs.com; Port=3306; Database=coupon;
             });
         }
 
+
+
+        public static List<(string, string)> NotifyCheckDeepUrl(int accountid, CancellationToken cancellationToken = default)
+        {
+            var result = ProcessEndPointNodes<(string, string)>(node =>
+            {
+                try
+                {
+                    if (!node.is_public_api) return (node.name, "break");
+                    if (!node.status) return (node.name, "账号下线");
+
+                    string url = $"{node.api_server}Task_70160bd632/CheckDeepUrl?accountid={accountid}";
+                    var result = new WebClientUtility().Request(url, "GET");
+                    string body = result.Body();
+                    var root = body.Convert2JsonElement();
+                    var message = root.Read<string>("message", string.Empty);
+                    return (node.name, message);
+                    
+
+                }
+                catch (Exception ex)
+                {
+                    _ = new LoggerLibrary("CheckDeepUrl", "error")
+                    .Info(node.Convert2Json(), $"accountid:\t{accountid}")
+                    .Info(ex.Message, ex.StackTrace)
+                    .SaveAsync();
+
+                    NotifyCore.Notify(new NifyMessage
+                    {
+                        message = $"【CheckDeepUrl异常】{node.description}\n{ex.Message}\n{ex.StackTrace}",
+                        priority = NifyMessagePriority.high,
+                        tags = ["red_circle"]
+                    });
+                    return (node.name, ex.Message);
+                }
+            });
+            return result;
+        }
+
     }
 
 }

+ 5 - 0
molilian.core/Core/taoke/TkLogCore.cs

@@ -17,6 +17,7 @@ using CSRedis;
 using System.Data;
 using TencentCloud.Omics.V20221128.Models;
 using TencentCloud.Csip.V20221121.Models;
+using COSXML.Network;
 
 
 namespace molilian.core
@@ -545,6 +546,10 @@ namespace molilian.core
                             }); break;
                     }
                 }
+                if (response.subCode == TkSubCodeEnum.Captcha || "霸下验证码".Equals(response.reason))
+                {
+                    TkPoolCore.Suspend(response.end_point, response.accountId, response.accountName, "霸下验证码");
+                }
             }
             catch (Exception ex)
             {

+ 32 - 2
molilian.core/Core/taoke/TkPoolCore.cs

@@ -37,7 +37,7 @@ namespace molilian.core
         {
             var list = List();
             if (!list.Any()) return null;
-            return list.Where(e => IsNotExceedDailyIncomeLimit(e, action)).OrderBy(l => Guid.NewGuid()).FirstOrDefault();
+            return list.Where(e => FilterNodes(e, action)).OrderBy(l => Guid.NewGuid()).FirstOrDefault();
         }
         public static TkPoolDTO? GetOne(int id)
         {
@@ -80,8 +80,9 @@ namespace molilian.core
             }
             catch (Exception ex) { return 0; }
         }
-        private static bool IsNotExceedDailyIncomeLimit(TkPoolDTO item, TkAction action)
+        private static bool FilterNodes(TkPoolDTO item, TkAction action)
         {
+            if (!string.IsNullOrEmpty(item.suspended_endpoint) && item.suspended_endpoint.Contains($"{_end_point}|")) return false;
 
             if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
             {
@@ -139,6 +140,34 @@ namespace molilian.core
             _ = List(true);
         }
 
+        public static void Suspend(string endpoint, int accountId, string name, string content)
+        {
+            string cache_key = $"cache:tk_pool:{accountId}:suspend";
+            long count = RedisHelper.IncrBy(cache_key);
+            RedisHelper.Expire(cache_key, 10);
+            if (count > 1) return;
+
+            var update = new DBContext.Table("tk_pool").Add("suspended_endpoint:", $"CONCAT(suspended_endpoint, '{endpoint},')");
+
+            if (accountId > 0)
+            {
+                update.Where("id=@accountId", new { accountId }).Update();
+            }
+            else
+            {
+                update.Where("name=@name", new { name }).Update();
+            }
+            _ = List(true);
+            NotifyCore.Notify(new NifyMessage
+            {
+                message = $"【淘客{accountId}:{name}】{endpoint} 暂停",
+                priority = NifyMessagePriority.high,
+                tags = ["red_circle"]
+            });
+            NotifyCore.AnPushNotify("暂停", $"【淘客{accountId}:{name}】{endpoint} 暂停");
+            EndPointCore.NotifyReload(true);
+        }
+
         public static void Disabled(int accountId, string name, string content)
         {
 #if DEBUG
@@ -195,6 +224,7 @@ namespace molilian.core
                    .Add("cookies", cookies)
                    .Add("user_agent", user_agent)
                    .Add("status", status)
+                   .Add("supend_endpoint", string.Empty)
                    .Add("last_time", DateTime.Now)
                    .Add("login_time", DateTime.Now)
                    .Where("id=@id", new { exist.id })

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

@@ -21,6 +21,7 @@ using TencentCloud.Soe.V20180724.Models;
 using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
 using System.Runtime.Intrinsics.Arm;
 using ZstdSharp.Unsafe;
+using System.Text.RegularExpressions;
 
 
 namespace molilian.core
@@ -238,6 +239,30 @@ namespace molilian.core
                     });
                 }
 
+
+
+                //那就初步筛选3   有tb.cn 并且有   or  手淘发现
+                string pattern = @"^(?!【淘宝】).*https?:\/\/m\.tb\.cn.*(?:手淘发现|手淘搜索)";
+                bool isMatch = Regex.IsMatch(content, pattern);
+                if (isMatch)
+                {
+                    result.success = false;
+                    result.message = "放弃转链";
+                    result.reason = "初步筛选3";
+                    result.subCode = TkSubCodeEnum.Prelim3;
+                    result.itemName = "点击打开淘宝APP";
+                    _ = TkLogCore.ParseLogAsync(result);
+
+                    return TaobaoParseOutput(result, swData, new
+                    {
+                        result.success,
+                        result.message,
+                        result.content,
+                        result.itemName,
+                        result.deeplink_url,
+                    });
+
+                }
                 //============================== 放弃转链-地区过滤 ==============================
                 bool is_ignore2 = AlimamaPlus.ShouldIgnoreRequest(ip, oaid, out reason);
 
@@ -289,10 +314,12 @@ namespace molilian.core
 
 
                 int timeout = alimama._config.rt_max;
+#if DEBUG
+                timeout = 10000;
+#endif
                 using var cts = new CancellationTokenSource();
                 cts.CancelAfter(timeout);
 
-
                 var requestTask = Task.Run(() => alimama.UnionParse2Async(content, result, cts.Token, swData), cts.Token);
                 var delayTask = Task.Delay(timeout, cts.Token);
                 var completedTask = await Task.WhenAny(requestTask, delayTask);

+ 37 - 1
molilian.core/DTO/Emun/TkChannelEnum.cs

@@ -5,11 +5,47 @@
         tb = 0,
         jd = 1,
         dy = 2,
+        pdd = 3,
+        vipshop = 4,
+        tmall = 5,
+        xhs = 6,
+
 
         tool = 100,
-        wemeet = 101,
+
+        wemeet = 101, //腾讯会议
         bdpan = 102,
+        quark = 103, //夸克
+        quarkpan = 104,
+
+        vqq = 105, //腾讯视频
+        meituan = 106,//美团
+        xianyu = 107, //闲鱼
+
+        iqiyi = 108, //爱奇艺
+        music163 = 109,//网易云音乐
+        xigua = 110,
+        kugou = 1111,
+        feizhu = 112,
+        zhuanzhuan = 113,//转转
+        bili = 114,
+        baidu = 115,
+        weibo = 116,
+        youku = 117,
+        toutiao = 118,
+        qqbrowser = 119,//QQ浏览器
+        qqnews = 120,
+        uc = 121, //UC浏览器
+        qqmusic = 122,
+        qqkg = 123, //全民k歌
+        kuwo = 124,
+        xima = 125,
+        dewu = 126, //得物
+        alibaba = 127,
+        dylite = 128,
+        bdlite = 129, //百度极速版
     }
+
     public enum CpsChannelEnum
     {
         invalid = 0,

+ 7 - 0
molilian.core/DTO/alimama/TkDataDTO.cs

@@ -54,6 +54,13 @@ namespace molilian.core
         /// </summary>
         Prelim1_5 = 110,
 
+        Captcha = 111,
+
+        /// <summary>
+        /// 初筛3
+        /// </summary>
+        Prelim3 = 112,
+
     }
 
 

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

@@ -23,6 +23,7 @@
         public DateTime last_time { get; set; } = DateTime.Now;
         public DateTime login_time { get; set; } = DateTime.Now;
         public bool status { get; set; }
+        public string suspended_endpoint { get; set; } = string.Empty;
         public string nodeName { get; set; } = string.Empty;
         public decimal current_amt { get; set; } = 0;
         public decimal daily_income_limit { get; set; } = 0;
@@ -36,6 +37,7 @@
         public bool enable_coupon { get; set; } = false;
         public bool enable_sync_order { get; set; } = false;
         public bool enable_promotionQuery { get; set; } = false;
+        public bool enable_deep_url { get; set; } = false;
 
 
         public string appkey { get; set; } = string.Empty;

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

@@ -133,6 +133,7 @@ namespace molilian.core
                     case LinkTypeEnum.video:
                     case LinkTypeEnum.note:
                     case LinkTypeEnum.goods:
+                    case LinkTypeEnum.baseDomain:
                         result.reason = string.Empty;
                         break;
                     default:
@@ -180,7 +181,7 @@ namespace molilian.core
                 if (url.Contains("https://s.tb.cn/") ||
                     url.Contains("http://s.tb.cn/") ||
                     url.Contains("http://m.tb.cn/") ||
-                    url.Contains("http://m.tb.cn/"))
+                    url.Contains("https://m.tb.cn/"))
                 {
                     result = result.Replace(url, shortLink);
                 }

+ 49 - 15
molilian.core/Plus/Alimama/parse_2.cs

@@ -118,6 +118,7 @@ namespace molilian.core
                     return (true, resultUrl);
                 }
             }
+
             return (false, url);
         }
 
@@ -177,7 +178,7 @@ namespace molilian.core
         /// </summary>
         /// <param name="url"></param>
         /// <returns></returns>
-        async Task<(bool, string)> GetDesiredUrlAsync(string url, CancellationToken cancellationToken = default)
+        public async Task<(bool, string)> GetDesiredUrlAsync(string url, CancellationToken cancellationToken = default)
         {
             string result;
             try
@@ -185,6 +186,10 @@ namespace molilian.core
                 if (!url.Contains("m.tb.cn") && !url.Contains("s.tb.cn"))
                     return (false, "不是淘宝短网址");
 
+
+
+                if (!_account.enable_deep_url) return (true, url);
+
                 string desiredUrlPattern = "var url = '(.*?)'";
                 WebClientUtility client = new()
                 {
@@ -193,9 +198,11 @@ namespace molilian.core
                 };
 #if DEBUG
                 client.Proxy = null;
-#endif
+                var response = await client.RequestAsync(url, "GET");
+#else
                 client.Timeout = GetRequestTimeout(0);
                 var response = await client.RequestAsync(url, "GET", cancellationToken);
+#endif
 
                 var responseBody = response.Body();
                 result = responseBody;
@@ -396,13 +403,13 @@ namespace molilian.core
             result.shortLinkurl = null;
         }
 
-        private async Task<TkDataDTO> InternalTextProcessingAsync(string content, TkDataDTO result,
-            CancellationToken cancellationToken,
+        public async Task<TkDataDTO> InternalTextProcessingAsync(string content, TkDataDTO result,
+            CancellationToken cancellationToken = default,
             Dictionary<string, long> swData = null)
         {
             bool success;
             string resultText;
-            LinkTypeEnum link_type = LinkTypeEnum.unknown;
+            result.link_type = LinkTypeEnum.unknown;
 
             //============================== 放弃转链-其他推广链接 ==============================
             string url = GetLink(content);
@@ -430,14 +437,16 @@ namespace molilian.core
                     return result;
                 }
 
+
                 Stopwatch sw = Stopwatch.StartNew();
                 (success, resultText) = await GetDesiredUrlAsync(url, cancellationToken);
                 sw.Stop();
                 // 获取执行时间
                 result.elapsedTime2 = (int)sw.ElapsedMilliseconds;
                 swData?.Add("\tGetDesiredUrlAsync", sw.ElapsedMilliseconds);
-
                 //============================== 放弃转链-请求超时 ==============================
+#if DEBUG
+#else
                 if (result.elapsedTime2 >= _config.rt_max || (!success && resultText.Contains("was canceled")))
                 {
                     result.success = false;
@@ -446,6 +455,7 @@ namespace molilian.core
                     result.subCode = TkSubCodeEnum.Other;
                     return result;
                 }
+#endif
 
                 if (success)
                 {
@@ -473,27 +483,36 @@ namespace molilian.core
                         result.shortLinkurl = desiredUrl;
                         return result;
                     }
-                    link_type = GetLinkType(desiredUrl);
+                    result.link_type = GetLinkType(desiredUrl);
                 }
                 else
                 {
-                    link_type = GetLinkType(url);
+                    result.link_type = GetLinkType(url);
                 }
 
-                if ((result.content.Contains("霸下通用 web 页面-验证码")))
+                if (result.content.Contains("霸下通用 web 页面-验证码"))
                 {
-                    result.subCode = TkSubCodeEnum.Other;
+                    result.subCode = TkSubCodeEnum.Captcha;
                     result.reason = "霸下验证码";
                 }
+                else
+                {
+                    if (result.link_type == LinkTypeEnum.baseDomain)
+                    {
+                        result.content = content;
+                    }
+                    else
+                    {
+                        result.reason = "非标准链接";
+                        result.subCode = TkSubCodeEnum.NonStdLink;
 
-
+                    }
+                }
                 result.success = false;
                 result.message = "放弃转链";
-                result.reason = "非标准链接";
-                result.subCode = TkSubCodeEnum.NonStdLink;
                 result.content = resultText;
-                result.link_type = link_type;
                 result.shortLinkurl = url;
+
                 return result;
                 //return (false, result, link_type, url);
             }
@@ -528,6 +547,8 @@ namespace molilian.core
         {
             if (string.IsNullOrEmpty(url)) return LinkTypeEnum.unknown;
 
+            if (url.Contains("m.tb.cn") || url.Contains("s.tb.cn")) return LinkTypeEnum.baseDomain;
+
             if (url.StartsWith("https://huodong.m.taobao.com/act/talent/live.html")) return LinkTypeEnum.live;
             if (url.StartsWith("https://web.m.taobao.com/app/tnode/web/index")) return LinkTypeEnum.video;
             if (url.StartsWith("https://shop.m.taobao.com/shop/shopIndex.htm")) return LinkTypeEnum.profile;
@@ -580,7 +601,12 @@ namespace molilian.core
             if (!string.IsNullOrEmpty(_user_agent)) client.UserAgent = _user_agent;
             client.Timeout = GetRequestTimeout(result.elapsedTime2);
             //var response = client.Request(url);
+
+#if DEBUG
+            var response = await client.RequestAsync(url, "GET");
+#else
             var response = await client.RequestAsync(url, "GET", cancellationToken);
+#endif
 
             stopwatch.Stop();
             result.elapsedTime3 = (int)stopwatch.ElapsedMilliseconds;
@@ -622,6 +648,14 @@ namespace molilian.core
                 }
                 catch (Exception ex)
                 {
+                    _ = new LoggerLibrary("api_error", "fail")
+                        .Info(ex.Message, ex.StackTrace)
+                        .SaveAsync();
+
+                    if (body.Contains("https://g.alicdn.com/sd/punish/waf_block.html"))
+                    {
+                        throw new Exception("waf_block");
+                    }
                     throw new Exception(body);
                 }
 
@@ -751,7 +785,7 @@ namespace molilian.core
                 result.pic = pic;
                 result.qrCodeUrl = qrCodeUrl;
             }
-            catch
+            catch (Exception ex)
             {
                 if (response.ResponseMessage?.StatusCode == System.Net.HttpStatusCode.OK)
                 {

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.