From ba46b2e5333fe1634076b2a58fc85c72536828ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E7=8C=BF?= <1083092844@qq.com>
Date: Tue, 14 Nov 2023 20:29:18 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9A=E6=8C=87?=
=?UTF-8?q?=E4=BB=A4=E6=94=AF=E6=8C=81;=20=E6=B7=BB=E5=8A=A0Form=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BarrageGrab/App.config | 2 +
BarrageGrab/Appsetting.cs | 8 +-
BarrageGrab/FormView.Designer.cs | 394 +++++++++++++++++++++++
BarrageGrab/FormView.cs | 20 ++
BarrageGrab/FormView.resx | 120 +++++++
BarrageGrab/Modles/JsonEntity/Command.cs | 15 +
BarrageGrab/Program.cs | 9 +
BarrageGrab/Proxy/ISystemProxy.cs | 12 +-
BarrageGrab/Proxy/SystemProxy.cs | 6 +-
BarrageGrab/WinApi.cs | 58 ++++
BarrageGrab/WsBarrageService.cs | 52 ++-
BarrageGrab/WssBarrageGrab.cs | 5 +
BarrageGrab/WssBarrageService.csproj | 13 +
13 files changed, 693 insertions(+), 21 deletions(-)
create mode 100644 BarrageGrab/FormView.Designer.cs
create mode 100644 BarrageGrab/FormView.cs
create mode 100644 BarrageGrab/FormView.resx
diff --git a/BarrageGrab/App.config b/BarrageGrab/App.config
index db48bf7..5a5fae5 100644
--- a/BarrageGrab/App.config
+++ b/BarrageGrab/App.config
@@ -24,6 +24,8 @@
+
+
diff --git a/BarrageGrab/Appsetting.cs b/BarrageGrab/Appsetting.cs
index ee0297f..f414c69 100644
--- a/BarrageGrab/Appsetting.cs
+++ b/BarrageGrab/Appsetting.cs
@@ -29,6 +29,7 @@ namespace BarrageGrab
UsedProxy = bool.Parse(AppSettings["usedProxy"].Trim());
ListenAny = bool.Parse(AppSettings["listenAny"].Trim());
UpstreamProxy = AppSettings["upstreamProxy"].Trim();
+ HideConsole = bool.Parse(AppSettings["hideConsole"].Trim());
var printFilter = AppSettings["printFilter"].Trim().ToLower();
if (printFilter != "all")
@@ -97,6 +98,11 @@ namespace BarrageGrab
///
/// 上游代理地址
///
- public string UpstreamProxy { get; set; }
+ public string UpstreamProxy { get; private set; }
+
+ ///
+ /// 隐藏控制台
+ ///
+ public bool HideConsole { get; private set; }
}
}
diff --git a/BarrageGrab/FormView.Designer.cs b/BarrageGrab/FormView.Designer.cs
new file mode 100644
index 0000000..131d23c
--- /dev/null
+++ b/BarrageGrab/FormView.Designer.cs
@@ -0,0 +1,394 @@
+namespace BarrageGrab
+{
+ partial class FormView
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.richTextBox1 = new System.Windows.Forms.RichTextBox();
+ this.cbx_bgtype_1 = new System.Windows.Forms.CheckBox();
+ this.cbx_bgtype_5 = new System.Windows.Forms.CheckBox();
+ this.cbx_bgtype_2 = new System.Windows.Forms.CheckBox();
+ this.cbx_bgtype_3 = new System.Windows.Forms.CheckBox();
+ this.cbx_bgtype_4 = new System.Windows.Forms.CheckBox();
+ this.cbx_bgtype_6 = new System.Windows.Forms.CheckBox();
+ this.cbx_bgtype_7 = new System.Windows.Forms.CheckBox();
+ this.cbx_bgtype_8 = new System.Windows.Forms.CheckBox();
+ this.cbx_bgtype_9 = new System.Windows.Forms.CheckBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.label1 = new System.Windows.Forms.Label();
+ this.listBox1 = new System.Windows.Forms.ListBox();
+ this.cbx_enableProxy = new System.Windows.Forms.CheckBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.panel2 = new System.Windows.Forms.Panel();
+ this.panel3 = new System.Windows.Forms.Panel();
+ this.label5 = new System.Windows.Forms.Label();
+ this.nud_wsport = new System.Windows.Forms.NumericUpDown();
+ this.cbx_loopback = new System.Windows.Forms.CheckBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.txb_upstreamProxy = new System.Windows.Forms.TextBox();
+ this.cbx_barrageLog = new System.Windows.Forms.CheckBox();
+ this.flowLayoutPanel1.SuspendLayout();
+ this.panel1.SuspendLayout();
+ this.panel2.SuspendLayout();
+ this.panel3.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.nud_wsport)).BeginInit();
+ this.SuspendLayout();
+ //
+ // richTextBox1
+ //
+ this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.richTextBox1.Location = new System.Drawing.Point(15, 0);
+ this.richTextBox1.Name = "richTextBox1";
+ this.richTextBox1.Size = new System.Drawing.Size(715, 260);
+ this.richTextBox1.TabIndex = 0;
+ this.richTextBox1.Text = "";
+ //
+ // cbx_bgtype_1
+ //
+ this.cbx_bgtype_1.AutoSize = true;
+ this.cbx_bgtype_1.Location = new System.Drawing.Point(3, 13);
+ this.cbx_bgtype_1.Name = "cbx_bgtype_1";
+ this.cbx_bgtype_1.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_1.TabIndex = 0;
+ this.cbx_bgtype_1.Text = "消息";
+ this.cbx_bgtype_1.UseVisualStyleBackColor = true;
+ //
+ // cbx_bgtype_5
+ //
+ this.cbx_bgtype_5.AutoSize = true;
+ this.cbx_bgtype_5.Location = new System.Drawing.Point(3, 38);
+ this.cbx_bgtype_5.Name = "cbx_bgtype_5";
+ this.cbx_bgtype_5.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_5.TabIndex = 1;
+ this.cbx_bgtype_5.Text = "礼物";
+ this.cbx_bgtype_5.UseVisualStyleBackColor = true;
+ //
+ // cbx_bgtype_2
+ //
+ this.cbx_bgtype_2.AutoSize = true;
+ this.cbx_bgtype_2.Location = new System.Drawing.Point(3, 63);
+ this.cbx_bgtype_2.Name = "cbx_bgtype_2";
+ this.cbx_bgtype_2.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_2.TabIndex = 2;
+ this.cbx_bgtype_2.Text = "点赞";
+ this.cbx_bgtype_2.UseVisualStyleBackColor = true;
+ //
+ // cbx_bgtype_3
+ //
+ this.cbx_bgtype_3.AutoSize = true;
+ this.cbx_bgtype_3.Location = new System.Drawing.Point(3, 88);
+ this.cbx_bgtype_3.Name = "cbx_bgtype_3";
+ this.cbx_bgtype_3.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_3.TabIndex = 3;
+ this.cbx_bgtype_3.Text = "进房";
+ this.cbx_bgtype_3.UseVisualStyleBackColor = true;
+ //
+ // cbx_bgtype_4
+ //
+ this.cbx_bgtype_4.AutoSize = true;
+ this.cbx_bgtype_4.Location = new System.Drawing.Point(3, 113);
+ this.cbx_bgtype_4.Name = "cbx_bgtype_4";
+ this.cbx_bgtype_4.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_4.TabIndex = 4;
+ this.cbx_bgtype_4.Text = "关注";
+ this.cbx_bgtype_4.UseVisualStyleBackColor = true;
+ //
+ // cbx_bgtype_6
+ //
+ this.cbx_bgtype_6.AutoSize = true;
+ this.cbx_bgtype_6.Location = new System.Drawing.Point(3, 138);
+ this.cbx_bgtype_6.Name = "cbx_bgtype_6";
+ this.cbx_bgtype_6.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_6.TabIndex = 5;
+ this.cbx_bgtype_6.Text = "统计";
+ this.cbx_bgtype_6.UseVisualStyleBackColor = true;
+ //
+ // cbx_bgtype_7
+ //
+ this.cbx_bgtype_7.AutoSize = true;
+ this.cbx_bgtype_7.Location = new System.Drawing.Point(3, 163);
+ this.cbx_bgtype_7.Name = "cbx_bgtype_7";
+ this.cbx_bgtype_7.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_7.TabIndex = 6;
+ this.cbx_bgtype_7.Text = "粉团";
+ this.cbx_bgtype_7.UseVisualStyleBackColor = true;
+ //
+ // cbx_bgtype_8
+ //
+ this.cbx_bgtype_8.AutoSize = true;
+ this.cbx_bgtype_8.Location = new System.Drawing.Point(3, 188);
+ this.cbx_bgtype_8.Name = "cbx_bgtype_8";
+ this.cbx_bgtype_8.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_8.TabIndex = 7;
+ this.cbx_bgtype_8.Text = "分享";
+ this.cbx_bgtype_8.UseVisualStyleBackColor = true;
+ //
+ // cbx_bgtype_9
+ //
+ this.cbx_bgtype_9.AutoSize = true;
+ this.cbx_bgtype_9.Location = new System.Drawing.Point(3, 213);
+ this.cbx_bgtype_9.Name = "cbx_bgtype_9";
+ this.cbx_bgtype_9.Size = new System.Drawing.Size(59, 19);
+ this.cbx_bgtype_9.TabIndex = 8;
+ this.cbx_bgtype_9.Text = "下播";
+ this.cbx_bgtype_9.UseVisualStyleBackColor = true;
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(839, 9);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(105, 15);
+ this.label2.TabIndex = 3;
+ this.label2.Text = "🚀 代理抓取中";
+ //
+ // flowLayoutPanel1
+ //
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_1);
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_5);
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_2);
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_3);
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_4);
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_6);
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_7);
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_8);
+ this.flowLayoutPanel1.Controls.Add(this.cbx_bgtype_9);
+ this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Left;
+ this.flowLayoutPanel1.Location = new System.Drawing.Point(15, 0);
+ this.flowLayoutPanel1.Name = "flowLayoutPanel1";
+ this.flowLayoutPanel1.Padding = new System.Windows.Forms.Padding(0, 10, 0, 0);
+ this.flowLayoutPanel1.Size = new System.Drawing.Size(79, 260);
+ this.flowLayoutPanel1.TabIndex = 4;
+ //
+ // panel1
+ //
+ this.panel1.Controls.Add(this.flowLayoutPanel1);
+ this.panel1.Controls.Add(this.richTextBox1);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.panel1.Location = new System.Drawing.Point(0, 263);
+ this.panel1.Name = "panel1";
+ this.panel1.Padding = new System.Windows.Forms.Padding(15, 0, 5, 0);
+ this.panel1.Size = new System.Drawing.Size(735, 260);
+ this.panel1.TabIndex = 5;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(249, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(37, 15);
+ this.label1.TabIndex = 6;
+ this.label1.Text = "配置";
+ //
+ // listBox1
+ //
+ this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)));
+ this.listBox1.FormattingEnabled = true;
+ this.listBox1.ItemHeight = 15;
+ this.listBox1.Location = new System.Drawing.Point(18, 41);
+ this.listBox1.Name = "listBox1";
+ this.listBox1.Size = new System.Drawing.Size(228, 199);
+ this.listBox1.TabIndex = 7;
+ //
+ // cbx_enableProxy
+ //
+ this.cbx_enableProxy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.cbx_enableProxy.AutoSize = true;
+ this.cbx_enableProxy.Location = new System.Drawing.Point(634, 8);
+ this.cbx_enableProxy.Name = "cbx_enableProxy";
+ this.cbx_enableProxy.Size = new System.Drawing.Size(89, 19);
+ this.cbx_enableProxy.TabIndex = 8;
+ this.cbx_enableProxy.Text = "启用抓取";
+ this.cbx_enableProxy.UseVisualStyleBackColor = true;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(15, 9);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(121, 15);
+ this.label3.TabIndex = 9;
+ this.label3.Text = "房间缓存列表(0)";
+ //
+ // panel2
+ //
+ this.panel2.Controls.Add(this.cbx_barrageLog);
+ this.panel2.Controls.Add(this.panel3);
+ this.panel2.Controls.Add(this.label1);
+ this.panel2.Controls.Add(this.listBox1);
+ this.panel2.Controls.Add(this.cbx_enableProxy);
+ this.panel2.Controls.Add(this.label3);
+ this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
+ this.panel2.Location = new System.Drawing.Point(0, 0);
+ this.panel2.Name = "panel2";
+ this.panel2.Size = new System.Drawing.Size(735, 257);
+ this.panel2.TabIndex = 10;
+ //
+ // panel3
+ //
+ this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.panel3.Controls.Add(this.txb_upstreamProxy);
+ this.panel3.Controls.Add(this.label5);
+ this.panel3.Controls.Add(this.nud_wsport);
+ this.panel3.Controls.Add(this.cbx_loopback);
+ this.panel3.Controls.Add(this.label4);
+ this.panel3.Location = new System.Drawing.Point(252, 41);
+ this.panel3.Name = "panel3";
+ this.panel3.Size = new System.Drawing.Size(471, 199);
+ this.panel3.TabIndex = 13;
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Cursor = System.Windows.Forms.Cursors.Arrow;
+ this.label5.Location = new System.Drawing.Point(3, 64);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(112, 15);
+ this.label5.TabIndex = 13;
+ this.label5.Text = "上游代理地址:";
+ //
+ // nud_wsport
+ //
+ this.nud_wsport.Location = new System.Drawing.Point(113, 16);
+ this.nud_wsport.Maximum = new decimal(new int[] {
+ 65534,
+ 0,
+ 0,
+ 0});
+ this.nud_wsport.Minimum = new decimal(new int[] {
+ 1000,
+ 0,
+ 0,
+ 0});
+ this.nud_wsport.Name = "nud_wsport";
+ this.nud_wsport.Size = new System.Drawing.Size(84, 25);
+ this.nud_wsport.TabIndex = 11;
+ this.nud_wsport.Value = new decimal(new int[] {
+ 1000,
+ 0,
+ 0,
+ 0});
+ //
+ // cbx_loopback
+ //
+ this.cbx_loopback.AutoSize = true;
+ this.cbx_loopback.Location = new System.Drawing.Point(219, 19);
+ this.cbx_loopback.Name = "cbx_loopback";
+ this.cbx_loopback.Size = new System.Drawing.Size(74, 19);
+ this.cbx_loopback.TabIndex = 12;
+ this.cbx_loopback.Text = "仅回环";
+ this.cbx_loopback.UseVisualStyleBackColor = true;
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(9, 21);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(98, 15);
+ this.label4.TabIndex = 10;
+ this.label4.Text = "WS服务端口:";
+ //
+ // txb_upstreamProxy
+ //
+ this.txb_upstreamProxy.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.txb_upstreamProxy.Location = new System.Drawing.Point(113, 60);
+ this.txb_upstreamProxy.Name = "txb_upstreamProxy";
+ this.txb_upstreamProxy.Size = new System.Drawing.Size(180, 25);
+ this.txb_upstreamProxy.TabIndex = 14;
+ //
+ // cbx_barrageLog
+ //
+ this.cbx_barrageLog.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.cbx_barrageLog.AutoSize = true;
+ this.cbx_barrageLog.Location = new System.Drawing.Point(532, 8);
+ this.cbx_barrageLog.Name = "cbx_barrageLog";
+ this.cbx_barrageLog.Size = new System.Drawing.Size(89, 19);
+ this.cbx_barrageLog.TabIndex = 14;
+ this.cbx_barrageLog.Text = "弹幕日志";
+ this.cbx_barrageLog.UseVisualStyleBackColor = true;
+ //
+ // FormView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(735, 523);
+ this.Controls.Add(this.panel2);
+ this.Controls.Add(this.panel1);
+ this.Controls.Add(this.label2);
+ this.MaximizeBox = false;
+ this.Name = "FormView";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "FormView";
+ this.flowLayoutPanel1.ResumeLayout(false);
+ this.flowLayoutPanel1.PerformLayout();
+ this.panel1.ResumeLayout(false);
+ this.panel2.ResumeLayout(false);
+ this.panel2.PerformLayout();
+ this.panel3.ResumeLayout(false);
+ this.panel3.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.nud_wsport)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.RichTextBox richTextBox1;
+ private System.Windows.Forms.CheckBox cbx_bgtype_5;
+ private System.Windows.Forms.CheckBox cbx_bgtype_1;
+ private System.Windows.Forms.CheckBox cbx_bgtype_6;
+ private System.Windows.Forms.CheckBox cbx_bgtype_4;
+ private System.Windows.Forms.CheckBox cbx_bgtype_3;
+ private System.Windows.Forms.CheckBox cbx_bgtype_2;
+ private System.Windows.Forms.CheckBox cbx_bgtype_7;
+ private System.Windows.Forms.CheckBox cbx_bgtype_9;
+ private System.Windows.Forms.CheckBox cbx_bgtype_8;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.ListBox listBox1;
+ private System.Windows.Forms.CheckBox cbx_enableProxy;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Panel panel2;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Panel panel3;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.NumericUpDown nud_wsport;
+ private System.Windows.Forms.CheckBox cbx_loopback;
+ private System.Windows.Forms.TextBox txb_upstreamProxy;
+ private System.Windows.Forms.CheckBox cbx_barrageLog;
+ }
+}
\ No newline at end of file
diff --git a/BarrageGrab/FormView.cs b/BarrageGrab/FormView.cs
new file mode 100644
index 0000000..4c730ec
--- /dev/null
+++ b/BarrageGrab/FormView.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace BarrageGrab
+{
+ public partial class FormView : Form
+ {
+ public FormView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/BarrageGrab/FormView.resx b/BarrageGrab/FormView.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/BarrageGrab/FormView.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/BarrageGrab/Modles/JsonEntity/Command.cs b/BarrageGrab/Modles/JsonEntity/Command.cs
index 124fb2d..8b3e6b7 100644
--- a/BarrageGrab/Modles/JsonEntity/Command.cs
+++ b/BarrageGrab/Modles/JsonEntity/Command.cs
@@ -6,6 +6,11 @@ using System.Threading.Tasks;
namespace BarrageGrab.Modles.JsonEntity
{
+ /*
+ * 例如发送 {"Cmd":1,"Data":true} 到ws连接地址 关闭程序
+ * 前往 http://wstool.jackxiang.com/ 在线ws测试
+ */
+
public enum CommandCode
{
///
@@ -17,6 +22,16 @@ namespace BarrageGrab.Modles.JsonEntity
/// 安全关闭程序
///
Close = 1,
+
+ ///
+ /// 启用系统代理 Data:bool
+ ///
+ EnableProxy = 2,
+
+ ///
+ /// 是否显示控制台 Data:bool
+ ///
+ DisplayConsole = 3,
}
public class Command
diff --git a/BarrageGrab/Program.cs b/BarrageGrab/Program.cs
index b219958..8f77090 100644
--- a/BarrageGrab/Program.cs
+++ b/BarrageGrab/Program.cs
@@ -23,6 +23,15 @@ namespace BarrageGrab
WinApi.SetConsoleCtrlHandler(cancelHandler, true);//捕获控制台关闭
WinApi.DisableQuickEditMode();//禁用控制台快速编辑模式
Console.Title = "抖音弹幕监听推送";
+
+ if(Appsetting.Current.HideConsole)
+ {
+ var hWnd = WinApi.FindWindow(null, Console.Title);
+ if (hWnd != IntPtr.Zero)
+ {
+ WinApi.ShowWindow(hWnd,WinApi.CmdShow.SW_HIDE);
+ }
+ }
bool exited = false;
AppRuntime.WssService.StartListen();
diff --git a/BarrageGrab/Proxy/ISystemProxy.cs b/BarrageGrab/Proxy/ISystemProxy.cs
index 51fa5ff..417cac5 100644
--- a/BarrageGrab/Proxy/ISystemProxy.cs
+++ b/BarrageGrab/Proxy/ISystemProxy.cs
@@ -5,12 +5,22 @@ using BarrageGrab.Proxy.ProxyEventArgs;
namespace BarrageGrab.Proxy
{
- internal interface ISystemProxy : IDisposable
+ public interface ISystemProxy : IDisposable
{
event EventHandler OnWebSocketData;
event EventHandler OnFetchResponse;
+ ///
+ /// 关闭系统代理
+ ///
+ void CloseSystemProxy();
+
+ ///
+ /// 注册为系统代理
+ ///
+ void RegisterSystemProxy();
+
///
/// 开始监听
///
diff --git a/BarrageGrab/Proxy/SystemProxy.cs b/BarrageGrab/Proxy/SystemProxy.cs
index a734d01..394bd7c 100644
--- a/BarrageGrab/Proxy/SystemProxy.cs
+++ b/BarrageGrab/Proxy/SystemProxy.cs
@@ -91,9 +91,9 @@ namespace BarrageGrab.Proxy
}
///
- /// 注册系统代理
+ /// 注册为系统代理
///
- protected void RegisterSystemProxy()
+ public void RegisterSystemProxy()
{
RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 1);
@@ -103,7 +103,7 @@ namespace BarrageGrab.Proxy
///
/// 关闭系统代理
///
- protected void CloseSystemProxy()
+ public void CloseSystemProxy()
{
RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 0);
diff --git a/BarrageGrab/WinApi.cs b/BarrageGrab/WinApi.cs
index 99c53bc..9b48913 100644
--- a/BarrageGrab/WinApi.cs
+++ b/BarrageGrab/WinApi.cs
@@ -29,6 +29,16 @@ namespace BarrageGrab
[DllImport("kernel32.dll", SetLastError = true)]
internal static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint mode);
+ ///If the function fails, the return value is NULL.
+ [DllImport("user32.dll")]
+ public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
+
+
+ [DllImport("User32.dll", EntryPoint = "ShowWindow")]
+ public static extern bool ShowWindow(IntPtr hWnd, CmdShow nCmdShow);
+
+
+
///
/// 启用控制台快速编辑
///
@@ -52,5 +62,53 @@ namespace BarrageGrab
mode &= ~ENABLE_QUICK_EDIT_MODE;
SetConsoleMode(hStdin, mode);
}
+
+
+
+ public enum CmdShow : int
+ {
+
+ SW_HIDE = 0,
+
+ SW_SHOWNORMAL = 1,
+
+ SW_SHOWMINIMIZED = 2,
+ ///
+ /// Activates the window and displays it as a maximized window.
+ ///
+ SW_SHOWMAXIMIZED = 3,
+ ///
+ /// Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated.
+ ///
+ SW_SHOWNOACTIVATE = 4,
+ ///
+ /// Activates the window and displays it in its current size and position.
+ ///
+ SW_SHOW = 5,
+ ///
+ /// Minimizes the specified window and activates the next top-level window in the Z order.
+ ///
+ SW_MINIMIZE = 6,
+ ///
+ /// Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
+ ///
+ SW_SHOWMINNOACTIVE = 7,
+ ///
+ /// Displays the window in its current size and position. This value is similar to SW_SHOW, except that the window is not activated.
+ ///
+ SW_SHOWNA = 8,
+ ///
+ /// Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
+ ///
+ SW_RESTORE = 9,
+ ///
+ /// Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
+ ///
+ SW_SHOWDEFAULT = 10,
+ ///
+ /// Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread.
+ ///
+ SW_FORCEMINIMIZE = 11
+ }
}
}
diff --git a/BarrageGrab/WsBarrageService.cs b/BarrageGrab/WsBarrageService.cs
index 62c7f86..c86b8fe 100644
--- a/BarrageGrab/WsBarrageService.cs
+++ b/BarrageGrab/WsBarrageService.cs
@@ -19,7 +19,6 @@ using BarrageGrab.Modles.ProtoEntity;
namespace BarrageGrab
{
-
///
/// 弹幕服务
///
@@ -34,7 +33,7 @@ namespace BarrageGrab
ConsoleWriter console = new ConsoleWriter();
WssBarrageGrab grab = new WssBarrageGrab();
Appsetting Appsetting = Appsetting.Current;
- bool debug = false;
+ bool debug = false;
///
/// 服务关闭后触发
@@ -88,7 +87,7 @@ namespace BarrageGrab
if (Appsetting.RoomIds.Length == 0) return true;
return Appsetting.RoomIds.Any(a => a == roomid);
}
-
+
//解析用户
private MsgUser GetUser(User data)
{
@@ -178,10 +177,10 @@ namespace BarrageGrab
User = GetUser(msg.User)
};
enty.Level = enty.User.FansClub.Level;
-
+
var msgType = PackMsgType.粉丝团消息;
PrintMsg(enty, msgType);
- Broadcast(new BarrageMsgPack(enty.ToJson(), msgType,e.Process));
+ Broadcast(new BarrageMsgPack(enty.ToJson(), msgType, e.Process));
}
//统计消息
@@ -201,7 +200,7 @@ namespace BarrageGrab
Content = $"当前直播间人数 {msg.onlineUserForAnchor},累计直播间人数 {msg.totalPvForAnchor}",
User = null
};
-
+
var msgType = PackMsgType.直播间统计;
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), msgType, e.Process);
@@ -277,7 +276,7 @@ namespace BarrageGrab
GiftName = msg.Gift.Name,
User = GetUser(msg.User)
};
-
+
var msgType = PackMsgType.礼物消息;
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), PackMsgType.礼物消息, e.Process);
@@ -298,7 +297,7 @@ namespace BarrageGrab
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
User = GetUser(msg.User)
};
-
+
var msgType = PackMsgType.关注消息;
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), msgType, e.Process);
@@ -327,7 +326,7 @@ namespace BarrageGrab
ShareType = type,
User = GetUser(msg.User)
};
-
+
var msgType = PackMsgType.直播间分享;
PrintMsg(enty, msgType);
@@ -352,7 +351,7 @@ namespace BarrageGrab
CurrentCount = msg.memberCount,
User = GetUser(msg.User)
};
-
+
var msgType = PackMsgType.进直播间;
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), msgType, e.Process);
@@ -376,7 +375,7 @@ namespace BarrageGrab
Total = msg.Total,
User = GetUser(msg.User)
};
-
+
var msgType = PackMsgType.点赞消息;
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), msgType, e.Process);
@@ -397,7 +396,7 @@ namespace BarrageGrab
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
User = GetUser(msg.User),
};
-
+
var msgType = PackMsgType.弹幕消息;
PrintMsg(enty, msgType);
@@ -422,7 +421,7 @@ namespace BarrageGrab
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
User = null
};
-
+
var msgType = PackMsgType.下播;
PrintMsg(enty, msgType);
pack = new BarrageMsgPack(enty.ToJson(), PackMsgType.下播, e.Process);
@@ -479,9 +478,30 @@ namespace BarrageGrab
var cmdPack = JsonConvert.DeserializeObject(message);
if (cmdPack == null) return;
- if (cmdPack.Cmd == CommandCode.Close)
+ switch (cmdPack.Cmd)
{
- this.Close();
+ case CommandCode.Close:
+ this.Close();
+ break;
+ case CommandCode.EnableProxy:
+ {
+ var enable = (bool)cmdPack.Data;
+ if (enable)
+ this.grab.Proxy.RegisterSystemProxy();
+ else
+ this.grab.Proxy.CloseSystemProxy();
+ break;
+ }
+ case CommandCode.DisplayConsole:
+ {
+ var display = (bool)cmdPack.Data;
+ var hand = WinApi.FindWindow(null, Console.Title);
+ if (hand != IntPtr.Zero)
+ {
+ WinApi.ShowWindow(hand, display ? WinApi.CmdShow.SW_SHOW : WinApi.CmdShow.SW_HIDE);
+ }
+ break;
+ }
}
}
catch (Exception) { }
@@ -512,7 +532,7 @@ namespace BarrageGrab
{
var state = item.Value;
if (item.Value.Socket.IsAvailable)
- {
+ {
state.Socket.Send(pack.ToJson());
}
else
diff --git a/BarrageGrab/WssBarrageGrab.cs b/BarrageGrab/WssBarrageGrab.cs
index d6b2494..7cdd773 100644
--- a/BarrageGrab/WssBarrageGrab.cs
+++ b/BarrageGrab/WssBarrageGrab.cs
@@ -65,6 +65,11 @@ namespace BarrageGrab
///
public event EventHandler> OnFansclubMessage;
+ ///
+ /// 代理
+ ///
+ public ISystemProxy Proxy { get => proxy; }
+
public WssBarrageGrab()
{
proxy.OnWebSocketData += Proxy_OnWebSocketData;
diff --git a/BarrageGrab/WssBarrageService.csproj b/BarrageGrab/WssBarrageService.csproj
index 7c84212..86299ed 100644
--- a/BarrageGrab/WssBarrageService.csproj
+++ b/BarrageGrab/WssBarrageService.csproj
@@ -102,6 +102,7 @@
+
..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll
@@ -123,6 +124,7 @@
..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
@@ -136,6 +138,12 @@
+
+ Form
+
+
+ FormView.cs
+
@@ -182,5 +190,10 @@
false
+
+
+ FormView.cs
+
+
\ No newline at end of file