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

@@ -30,6 +30,11 @@ namespace GrasscutterTools.Utils
{
private const string TAG = "Proxy";
static ProxyHelper()
{
Eavesdropper.Certifier = new Certifier("jie65535", "GrasscutterTools Root Certificate Authority");
}
#region - Windows API -
[DllImport("wininet.dll")]
@@ -171,6 +176,8 @@ namespace GrasscutterTools.Utils
private static string _gcDispatch;
public static void StartProxy(string gcDispatch)
{
// Check Url format
var _ = new Uri(gcDispatch);
_gcDispatch = gcDispatch.TrimEnd('/');
Logger.I(TAG, "Start Proxy, redirect to " + _gcDispatch);
StartGsProxyServer(ProxyServerPort);
@@ -184,12 +191,16 @@ namespace GrasscutterTools.Utils
StopGsProxyServer();
}
public static bool CheckAndCreateCertifier()
public static bool CheckAndCreateCertificate()
{
Eavesdropper.Certifier = new Certifier("jie65535", "GrasscutterTools Root Certificate Authority");
return Eavesdropper.Certifier.CreateTrustedRootCertificate();
}
public static bool DestroyCertificate()
{
return Eavesdropper.Certifier.DestroyTrustedRootCertificate();
}
public static bool IsRunning => Eavesdropper.IsRunning;
}
}