Skip to content

Commit

Permalink
补充支持监听轮询弹幕;完善界面无操作检测绕过逻辑;
Browse files Browse the repository at this point in the history
  • Loading branch information
ape-byte committed Aug 17, 2023
1 parent 5057a1d commit 2258101
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 72 deletions.
2 changes: 1 addition & 1 deletion BarrageGrab/Proxy/EventArgs/HttpResponseEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public class HttpResponseEventArgs : EventArgs
/// <summary>
/// 域名
/// </summary>
public string HostName { get; set; }
public string HostName { get; set; }
}
}
5 changes: 5 additions & 0 deletions BarrageGrab/Proxy/EventArgs/WsMessageEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ public class WsMessageEventArgs
/// 域名
/// </summary>
public string HostName { get; set; }

/// <summary>
/// 是否需要解压缩
/// </summary>
public bool NeedDecompress { get; set; } = true;
}
}
11 changes: 2 additions & 9 deletions BarrageGrab/Proxy/ISystemProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,11 @@ internal interface ISystemProxy : IDisposable
{
event EventHandler<WsMessageEventArgs> OnWebSocketData;

event EventHandler<HttpResponseEventArgs> OnResponse;

/// <summary>
/// 域名过滤器
/// </summary>
Func<string, bool> HostNameFilter { get; set; }
event EventHandler<HttpResponseEventArgs> OnFetchResponse;

/// <summary>
/// 开始监听
/// </summary>
void Start();
}


}
}
27 changes: 13 additions & 14 deletions BarrageGrab/Proxy/SystemProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ namespace BarrageGrab.Proxy
{
internal abstract class SystemProxy : ISystemProxy
{
/// <summary>
/// 域名过滤器
/// </summary>
public Func<string, bool> HostNameFilter { get; set; }

/// <summary>
/// 接收到websocket消息事件
/// </summary>
Expand All @@ -27,7 +22,7 @@ internal abstract class SystemProxy : ISystemProxy
/// <summary>
/// 接收到http响应事件
/// </summary>
public event EventHandler<HttpResponseEventArgs> OnResponse;
public event EventHandler<HttpResponseEventArgs> OnFetchResponse;

/// <summary>
/// 代理端口
Expand All @@ -45,13 +40,17 @@ internal abstract class SystemProxy : ISystemProxy
/// </summary>
/// <param name="host"></param>
/// <returns></returns>
protected bool CheckHost(string host)
{
var result = true;
protected virtual bool CheckHost(string host)
{
host = host.Trim().ToLower();

if (!Appsetting.Current.FilterHostName) return true;

if (host.StartsWith("webcast")) return true;

if (HostNameFilter != null) return HostNameFilter(host);
if (Appsetting.Current.HostNameFilter.Any(a => a.Trim().ToLower() == host)) return true;

return result;
return false;
}

/// <summary>
Expand All @@ -64,12 +63,12 @@ protected void FireWsEvent(WsMessageEventArgs args)
}

/// <summary>
/// 触发http响应事件
/// 触发弹幕http弹幕事件
/// </summary>
/// <param name="args"></param>
protected void FireOnResponse(HttpResponseEventArgs args)
protected void FireOnFetchResponse(HttpResponseEventArgs args)
{
OnResponse?.Invoke(this, args);
OnFetchResponse?.Invoke(this, args);
}

/// <summary>
Expand Down
Loading

0 comments on commit 2258101

Please sign in to comment.