From 250a8fcfbfe3b00c3d7bdadc4972a8a3619f6d77 Mon Sep 17 00:00:00 2001 From: Muihd <1083092844@qq.com> Date: Sun, 12 May 2024 15:43:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=9A=E8=BF=87=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8A=96=E9=9F=B3=E5=8F=B7=E8=BF=9B=E5=85=A5=E6=88=BF?= =?UTF-8?q?=E9=97=B4=E6=88=BF=E9=97=B4=E4=BF=A1=E6=81=AF=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BarrageGrab/Properties/AssemblyInfo.cs | 4 ++-- BarrageGrab/Proxy/SystemProxy.cs | 3 ++- BarrageGrab/Proxy/TitaniumProxy.cs | 8 +++++--- BarrageGrab/WssBarrageGrab.cs | 22 +++++++++++++--------- BarrageGrab/WssBarrageService.csproj | 8 ++++---- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/BarrageGrab/Properties/AssemblyInfo.cs b/BarrageGrab/Properties/AssemblyInfo.cs index 82fe99e..a36c1ed 100644 --- a/BarrageGrab/Properties/AssemblyInfo.cs +++ b/BarrageGrab/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.7.3.0")] -[assembly: AssemblyFileVersion("2.7.3.0")] +[assembly: AssemblyVersion("2.7.4.0")] +[assembly: AssemblyFileVersion("2.7.4.0")] [assembly: NeutralResourcesLanguage("zh-CN")] diff --git a/BarrageGrab/Proxy/SystemProxy.cs b/BarrageGrab/Proxy/SystemProxy.cs index 661417c..0920319 100644 --- a/BarrageGrab/Proxy/SystemProxy.cs +++ b/BarrageGrab/Proxy/SystemProxy.cs @@ -108,7 +108,8 @@ namespace BarrageGrab.Proxy { RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true); registry.SetValue("ProxyEnable", 1); - registry.SetValue("ProxyServer", $"http=localhost:{ProxyPort};https=localhost:{ProxyPort}"); + registry.SetValue("ProxyServer", $"127.0.0.1:{ProxyPort}"); + OnProxyStatus?.Invoke(this, new SystemProxyChangeEventArgs() { Open = true diff --git a/BarrageGrab/Proxy/TitaniumProxy.cs b/BarrageGrab/Proxy/TitaniumProxy.cs index 724f3a7..33c7bb5 100644 --- a/BarrageGrab/Proxy/TitaniumProxy.cs +++ b/BarrageGrab/Proxy/TitaniumProxy.cs @@ -243,7 +243,7 @@ namespace BarrageGrab.Proxy var urlNoQuery = url.Split('?')[0]; var processid = e.HttpClient.ProcessId.Value; var processName = base.GetProcessName(processid); - var liveRoomMactch = Regex.Match(uri.Trim(), @".*:\/\/live.douyin\.com\/(\d+)"); + var liveRoomMactch = Regex.Match(uri.Trim(), @".*:\/\/live.douyin\.com\/([0-9a-zA-Z_]+)"); var liveHomeMatch = Regex.Match(uri.Trim(), @".*:\/\/live.douyin\.com\/?$"); var contentType = e.HttpClient.Response.ContentType ?? ""; @@ -586,8 +586,10 @@ namespace BarrageGrab.Proxy proxyServer.Start(AppSetting.Current.UsedProxy); if (AppSetting.Current.UsedProxy) { - proxyServer.SetAsSystemHttpProxy(explicitEndPoint); - proxyServer.SetAsSystemHttpsProxy(explicitEndPoint); + base.RegisterSystemProxy(); + //使用其自带的系统代理设置可能会导致格式问题 + //proxyServer.SetAsSystemHttpProxy(explicitEndPoint); + //proxyServer.SetAsSystemHttpsProxy(explicitEndPoint); } } } diff --git a/BarrageGrab/WssBarrageGrab.cs b/BarrageGrab/WssBarrageGrab.cs index 80e0df2..c1ed54c 100644 --- a/BarrageGrab/WssBarrageGrab.cs +++ b/BarrageGrab/WssBarrageGrab.cs @@ -125,11 +125,11 @@ namespace BarrageGrab var response = Serializer.Deserialize(new ReadOnlyMemory(allBuff)); - response.Messages.ForEach(f => DoMessage(f,e.ProcessName)); + response.Messages.ForEach(f => DoMessage(f, e.ProcessName)); } - catch (Exception ex) + catch (Exception ex) { - Logger.LogError(ex,$"处理弹幕数据包时出错:{ex.Message}"); + Logger.LogError(ex, $"处理弹幕数据包时出错:{ex.Message}"); } } @@ -142,7 +142,7 @@ namespace BarrageGrab response.Messages.ForEach(f => { - DoMessage(f,e.ProcessName); + DoMessage(f, e.ProcessName); }); } @@ -150,7 +150,7 @@ namespace BarrageGrab Dictionary> msgDic = new Dictionary>(); //发送事件 - private void DoMessage(Message msg,string processName) + private void DoMessage(Message msg, string processName) { List msgIdList; if (msgDic.ContainsKey(msg.Method)) @@ -168,7 +168,11 @@ namespace BarrageGrab } msgIdList.Add(msg.msgId); - if (msgIdList.Count > 300) msgIdList.RemoveAt(0); + //每种消息类型设置300容量应该足够,不太可能存在一条消息被挤出队列后再次出现 + while (msgIdList.Count > 300) + { + msgIdList.RemoveAt(0); + } try { @@ -178,13 +182,13 @@ namespace BarrageGrab case "WebcastMemberMessage": { var arg = Serializer.Deserialize(new ReadOnlyMemory(msg.Payload)); - this.OnMemberMessage?.Invoke(this, new RoomMessageEventArgs(processName,arg)); + this.OnMemberMessage?.Invoke(this, new RoomMessageEventArgs(processName, arg)); break; } //关注 case "WebcastSocialMessage": { - var arg = Serializer.Deserialize(new ReadOnlyMemory(msg.Payload)); + var arg = Serializer.Deserialize(new ReadOnlyMemory(msg.Payload)); this.OnSocialMessage?.Invoke(this, new RoomMessageEventArgs(processName, arg)); break; } @@ -255,7 +259,7 @@ namespace BarrageGrab public RoomMessageEventArgs() { - + } public RoomMessageEventArgs(string process, T data) diff --git a/BarrageGrab/WssBarrageService.csproj b/BarrageGrab/WssBarrageService.csproj index 493dbe9..17ed360 100644 --- a/BarrageGrab/WssBarrageService.csproj +++ b/BarrageGrab/WssBarrageService.csproj @@ -13,6 +13,8 @@ v4.6.2 512 true + false + publish\ true Disk @@ -25,10 +27,8 @@ true 0 1.0.0.%2a - false false true - true @@ -40,12 +40,12 @@ 4 - pdbonly + none true bin\Release\ TRACE prompt - 4 + 0