Add Proxy page

This commit is contained in:
2023-10-08 00:01:20 +08:00
parent 2c2f05c5b2
commit 2a51fcb47d
18 changed files with 579 additions and 126 deletions

View File

@@ -64,8 +64,6 @@ namespace GrasscutterTools.Pages
TxtHost.Items.Add("http://127.0.0.1:443");
TxtHost.SelectedIndex = 0;
}
BtnProxy.Text = Resources.StartProxy;
}
#region - -
@@ -248,6 +246,8 @@ namespace GrasscutterTools.Pages
return;
}
Settings.Default.Host = host;
var isOcEnabled = false;
try
{
@@ -275,8 +275,6 @@ namespace GrasscutterTools.Pages
LblOpenCommandSupport.ForeColor = Color.Red;
GrpRemoteCommand.Enabled = false;
}
BtnProxy.Enabled = true;
}
catch (Exception ex)
{
@@ -608,44 +606,5 @@ 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
}
}