From 7f37c7344abe519b7fdb381602773d12d1044099 Mon Sep 17 00:00:00 2001
From: Muihd <1083092844@qq.com>
Date: Thu, 16 May 2024 22:24:45 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AA=97=E4=BD=93=E5=88=9D?=
=?UTF-8?q?=E5=A7=8B=E5=8C=96=E9=97=AE=E9=A2=98;=20=E4=BF=AE=E5=A4=8D?=
=?UTF-8?q?=E8=BD=AE=E8=AF=A2=E6=A8=A1=E5=BC=8Fpayload=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=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/Forms/FormView.cs | 11 ++++++-----
BarrageGrab/Logger.cs | 1 +
.../Proxy/ProxyEventArgs/HttpResponseEventArgs.cs | 5 +++++
BarrageGrab/Proxy/TitaniumProxy.cs | 4 +++-
BarrageGrab/WssBarrageGrab.cs | 4 +++-
5 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/BarrageGrab/Forms/FormView.cs b/BarrageGrab/Forms/FormView.cs
index 60ebdf3..430a38b 100644
--- a/BarrageGrab/Forms/FormView.cs
+++ b/BarrageGrab/Forms/FormView.cs
@@ -29,11 +29,7 @@ namespace BarrageGrab
InitializeComponent();
barServer.OnPrint += WssService_OnPrint;
barServer.Grab.Proxy.OnProxyStatus += Proxy_OnProxyStatus;
- AppRuntime.RoomCaches.OnCache += RoomCaches_OnCache;
- this.txb_wsaddr.Text = barServer.ServerLocation;
- this.txb_upstreamProxy.Text = proxy.HttpUpstreamProxy;
- this.cbx_barrageLog.Checked = AppSetting.Current.BarrageLog;
- InitTabPages();
+ AppRuntime.RoomCaches.OnCache += RoomCaches_OnCache;
}
private void InitTabPages()
@@ -155,6 +151,11 @@ namespace BarrageGrab
private void FormView_Load(object sender, EventArgs e)
{
+ this.txb_wsaddr.Text = barServer.ServerLocation;
+ this.txb_upstreamProxy.Text = proxy.HttpUpstreamProxy;
+ this.cbx_barrageLog.Checked = AppSetting.Current.BarrageLog;
+ InitTabPages();
+
this.cbx_enableProxy.Checked = SystemProxy.ProxyIsOpen();
}
diff --git a/BarrageGrab/Logger.cs b/BarrageGrab/Logger.cs
index 7e7a532..967da2c 100644
--- a/BarrageGrab/Logger.cs
+++ b/BarrageGrab/Logger.cs
@@ -83,6 +83,7 @@ namespace BarrageGrab
{
var dir = Path.Combine(AppContext.BaseDirectory, "logs", "弹幕日志");
var room = AppRuntime.RoomCaches.GetCachedWebRoomInfo(msg.RoomId.ToString());
+ if(room == null) return;
var date = DateTime.Now.ToString("yyyy年MM月dd日直播");
dir = Path.Combine(dir, $"({room.WebRoomId}){room?.Owner?.Nickname ?? "-1"}", date);
if (!Directory.Exists(dir))
diff --git a/BarrageGrab/Proxy/ProxyEventArgs/HttpResponseEventArgs.cs b/BarrageGrab/Proxy/ProxyEventArgs/HttpResponseEventArgs.cs
index 2df1ada..82f1b5c 100644
--- a/BarrageGrab/Proxy/ProxyEventArgs/HttpResponseEventArgs.cs
+++ b/BarrageGrab/Proxy/ProxyEventArgs/HttpResponseEventArgs.cs
@@ -31,5 +31,10 @@ namespace BarrageGrab.Proxy.ProxyEventArgs
/// 域名
///
public string HostName { get; set; }
+
+ ///
+ /// 有效载荷
+ ///
+ public byte[] Payload { get; set; }
}
}
diff --git a/BarrageGrab/Proxy/TitaniumProxy.cs b/BarrageGrab/Proxy/TitaniumProxy.cs
index 33c7bb5..b202bdc 100644
--- a/BarrageGrab/Proxy/TitaniumProxy.cs
+++ b/BarrageGrab/Proxy/TitaniumProxy.cs
@@ -207,13 +207,15 @@ namespace BarrageGrab.Proxy
//轮询方式(当抖音ws连接断开后,客户端也会降级使用轮询模式获取弹幕)
if (uri.Contains(BARRAGE_POOL_PATH) && contentType.Contains("application/protobuffer"))
{
- //var payload = await e.GetResponseBody();
+ var payload = await e.GetResponseBody();
+
base.FireOnFetchResponse(new HttpResponseEventArgs()
{
HttpClient = e.HttpClient,
ProcessID = processid,
HostName = hostname,
ProcessName = base.GetProcessName(processid),
+ Payload = payload
});
}
}
diff --git a/BarrageGrab/WssBarrageGrab.cs b/BarrageGrab/WssBarrageGrab.cs
index c1ed54c..70162f7 100644
--- a/BarrageGrab/WssBarrageGrab.cs
+++ b/BarrageGrab/WssBarrageGrab.cs
@@ -136,7 +136,9 @@ namespace BarrageGrab
//http 数据处理
private void Proxy_OnFetchResponse(object sender, HttpResponseEventArgs e)
{
- var payload = e.HttpClient.Response.Body;
+ var payload = e.Payload;
+
+ if (payload == null || payload.Length == 0) return;
var response = Serializer.Deserialize(new ReadOnlyMemory(payload));