mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-10-20 19:39:47 +08:00
Add HTTP(S) proxy (#208)
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
this.TxtHost = new System.Windows.Forms.ComboBox();
|
||||
this.BtnQueryServerStatus = new System.Windows.Forms.Button();
|
||||
this.LblHost = new System.Windows.Forms.Label();
|
||||
this.BtnProxy = new System.Windows.Forms.Button();
|
||||
this.GrpServerStatus.SuspendLayout();
|
||||
this.GrpRemoteCommand.SuspendLayout();
|
||||
this.TPOpenCommandCheck.SuspendLayout();
|
||||
@@ -286,8 +287,8 @@
|
||||
//
|
||||
resources.ApplyResources(this.TxtHost, "TxtHost");
|
||||
this.TxtHost.Name = "TxtHost";
|
||||
this.TxtHost.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtHost_KeyDown);
|
||||
this.TxtHost.SelectedIndexChanged += new System.EventHandler(this.TxtHost_SelectedIndexChanged);
|
||||
this.TxtHost.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtHost_KeyDown);
|
||||
//
|
||||
// BtnQueryServerStatus
|
||||
//
|
||||
@@ -301,10 +302,18 @@
|
||||
resources.ApplyResources(this.LblHost, "LblHost");
|
||||
this.LblHost.Name = "LblHost";
|
||||
//
|
||||
// BtnProxy
|
||||
//
|
||||
resources.ApplyResources(this.BtnProxy, "BtnProxy");
|
||||
this.BtnProxy.Name = "BtnProxy";
|
||||
this.BtnProxy.UseVisualStyleBackColor = true;
|
||||
this.BtnProxy.Click += new System.EventHandler(this.BtnProxy_Click);
|
||||
//
|
||||
// PageOpenCommand
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.BtnProxy);
|
||||
this.Controls.Add(this.LnkLinks);
|
||||
this.Controls.Add(this.LnkGOODHelp);
|
||||
this.Controls.Add(this.LnkInventoryKamera);
|
||||
@@ -365,5 +374,6 @@
|
||||
private System.Windows.Forms.ComboBox TxtHost;
|
||||
private System.Windows.Forms.Button BtnQueryServerStatus;
|
||||
private System.Windows.Forms.Label LblHost;
|
||||
private System.Windows.Forms.Button BtnProxy;
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,8 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Eavesdrop;
|
||||
|
||||
using GrasscutterTools.DispatchServer;
|
||||
using GrasscutterTools.DispatchServer.Model;
|
||||
using GrasscutterTools.Game;
|
||||
@@ -47,6 +49,8 @@ namespace GrasscutterTools.Pages
|
||||
if (DesignMode) return;
|
||||
|
||||
InitServerRecords();
|
||||
if (!string.IsNullOrEmpty(Settings.Default.Host))
|
||||
TxtHost.Items.Add(Settings.Default.Host);
|
||||
TxtHost.Items.AddRange(ServerRecords.Select(it => it.Host).ToArray());
|
||||
|
||||
NUDRemotePlayerId.Value = Settings.Default.RemoteUid;
|
||||
@@ -57,6 +61,14 @@ namespace GrasscutterTools.Pages
|
||||
TxtToken.Text = Settings.Default.TokenCache;
|
||||
Task.Delay(1000).ContinueWith(_ => ShowTipInRunButton?.Invoke(Resources.TokenRestoredFromCache));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(TxtHost.Text))
|
||||
{
|
||||
TxtHost.Items.Add("http://127.0.0.1:443");
|
||||
TxtHost.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
BtnProxy.Text = Resources.StartProxy;
|
||||
}
|
||||
|
||||
#region - 服务器记录 -
|
||||
@@ -161,6 +173,19 @@ namespace GrasscutterTools.Pages
|
||||
Settings.Default.RemoteUid = NUDRemotePlayerId.Value;
|
||||
Settings.Default.Host = TxtHost.Text;
|
||||
Settings.Default.TokenCache = Common.OC?.Token;
|
||||
|
||||
try
|
||||
{
|
||||
Logger.I(TAG, "Stop Proxy");
|
||||
ProxyHelper.StopProxy();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
MessageBox.Show(ex.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
#endif
|
||||
Logger.E(TAG, "Stop Proxy Failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -240,6 +265,7 @@ namespace GrasscutterTools.Pages
|
||||
MessageBox.Show(ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (isOcEnabled)
|
||||
{
|
||||
LblOpenCommandSupport.Text = "√";
|
||||
@@ -252,6 +278,8 @@ namespace GrasscutterTools.Pages
|
||||
LblOpenCommandSupport.ForeColor = Color.Red;
|
||||
GrpRemoteCommand.Enabled = false;
|
||||
}
|
||||
|
||||
BtnProxy.Enabled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -583,5 +611,44 @@ namespace GrasscutterTools.Pages
|
||||
}
|
||||
|
||||
#endregion - 导入存档 GOOD -
|
||||
|
||||
|
||||
#region - 代理 Porxy -
|
||||
|
||||
/// <summary>
|
||||
/// 点击代理按钮时触发
|
||||
/// </summary>
|
||||
private void BtnProxy_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 正在运行则关闭
|
||||
if (ProxyHelper.IsRunning)
|
||||
{
|
||||
ProxyHelper.StopProxy();
|
||||
BtnProxy.Text = Resources.StartProxy;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 创建根证书并检查信任
|
||||
if (!ProxyHelper.CheckAndCreateCertifier())
|
||||
{
|
||||
MessageBox.Show("必须先信任根证书才能继续", Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// 启动代理
|
||||
ProxyHelper.StartProxy(Common.OC.Host);
|
||||
BtnProxy.Text = Resources.StopProxy;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.E(TAG, "Start Proxy failed.", ex);
|
||||
MessageBox.Show(ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -151,7 +151,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>LnkLinks.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="LnkGOODHelp.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -184,7 +184,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>LnkGOODHelp.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="LnkInventoryKamera.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -214,7 +214,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>LnkInventoryKamera.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="LblGOODHelp.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -244,7 +244,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>LblGOODHelp.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="ButtonOpenGOODImport.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -274,7 +274,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>ButtonOpenGOODImport.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="LblHostTip.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -307,7 +307,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>LblHostTip.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="GrpServerStatus.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -514,7 +514,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>GrpServerStatus.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="GrpRemoteCommand.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -923,7 +923,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>GrpRemoteCommand.ZOrder" xml:space="preserve">
|
||||
<value>7</value>
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="TxtHost.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -932,7 +932,7 @@
|
||||
<value>136, 34</value>
|
||||
</data>
|
||||
<data name="TxtHost.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>182, 23</value>
|
||||
<value>182, 25</value>
|
||||
</data>
|
||||
<data name="TxtHost.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
@@ -941,13 +941,13 @@
|
||||
<value>TxtHost</value>
|
||||
</data>
|
||||
<data name=">>TxtHost.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>TxtHost.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>TxtHost.ZOrder" xml:space="preserve">
|
||||
<value>8</value>
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="BtnQueryServerStatus.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -977,7 +977,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>BtnQueryServerStatus.ZOrder" xml:space="preserve">
|
||||
<value>9</value>
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="LblHost.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>None</value>
|
||||
@@ -1010,7 +1010,34 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>LblHost.ZOrder" xml:space="preserve">
|
||||
<value>10</value>
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="BtnProxy.Enabled" type="System.Boolean, mscorlib">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="BtnProxy.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>3, 3</value>
|
||||
</data>
|
||||
<data name="BtnProxy.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>120, 25</value>
|
||||
</data>
|
||||
<data name="BtnProxy.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="BtnProxy.Text" xml:space="preserve">
|
||||
<value>启动代理</value>
|
||||
</data>
|
||||
<data name=">>BtnProxy.Name" xml:space="preserve">
|
||||
<value>BtnProxy</value>
|
||||
</data>
|
||||
<data name=">>BtnProxy.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>BtnProxy.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>BtnProxy.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
@@ -1022,6 +1049,6 @@
|
||||
<value>PageOpenCommand</value>
|
||||
</data>
|
||||
<data name=">>$this.Type" xml:space="preserve">
|
||||
<value>GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.7.4.0, Culture=neutral, PublicKeyToken=de2b1c089621e923</value>
|
||||
<value>GrasscutterTools.Pages.BasePage, GrasscutterTools, Version=1.13.0.0, Culture=neutral, PublicKeyToken=de2b1c089621e923</value>
|
||||
</data>
|
||||
</root>
|
Reference in New Issue
Block a user