add other proxy detection for proxy

This commit is contained in:
moux23333 2024-01-28 11:56:32 +08:00
parent caf71ca841
commit 8dae0c0aed

View file

@ -1,4 +1,6 @@
namespace FreeSR.Tool.Proxy
using System.Net;
namespace FreeSR.Tool.Proxy
{
internal static class Program
{
@ -10,6 +12,7 @@
private static void Main(string[] args)
{
Console.Title = Title;
CheckProxy();
s_proxyService = new ProxyService("127.0.0.1", 8888);
AppDomain.CurrentDomain.ProcessExit += s_processExitHandler;
@ -21,5 +24,43 @@
{
s_proxyService.Shutdown();
}
public static void CheckProxy()
{
try
{
string ProxyInfo = GetProxyInfo();
if (ProxyInfo != null)
{
Console.WriteLine("well... It seems you are using other proxy software(such as Clash,V2RayN,Fiddler,etc)");
Console.WriteLine($"You system proxy: {ProxyInfo}");
Console.WriteLine("You have to close all other proxy software to make sure FreeSR.Tool.Proxy can work well.");
Console.WriteLine("Press any key to continue if you closed other proxy software, or you think you are not using other proxy.");
Console.ReadKey();
}
}
catch (NullReferenceException)
{
}
}
public static string GetProxyInfo()
{
try
{
IWebProxy proxy = WebRequest.GetSystemWebProxy();
Uri proxyUri = proxy.GetProxy(new Uri("https://www.example.com"));
string proxyIP = proxyUri.Host;
int proxyPort = proxyUri.Port;
string info = proxyIP + ":" + proxyPort;
return info;
}
catch
{
return null;
}
}
}
}