mirror of https://github.com/2dust/v2rayN
add ieproxy
parent
cf204fac39
commit
3e35882fee
|
@ -9,6 +9,7 @@ using v2rayN.Handler;
|
|||
using v2rayN.HttpProxyHandler;
|
||||
using v2rayN.Mode;
|
||||
using v2rayN.Base;
|
||||
using v2rayN.Tool;
|
||||
|
||||
namespace v2rayN.Forms
|
||||
{
|
||||
|
@ -1178,15 +1179,8 @@ namespace v2rayN.Forms
|
|||
|
||||
string fileName = downloadHandle.DownloadFileName;
|
||||
fileName = Utils.GetPath(fileName);
|
||||
using (ZipArchive archive = ZipFile.OpenRead(fileName))
|
||||
{
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
if (entry.Length == 0)
|
||||
continue;
|
||||
entry.ExtractToFile(Utils.GetPath(entry.Name), true);
|
||||
}
|
||||
}
|
||||
FileManager.ZipExtractToFile(fileName);
|
||||
|
||||
AppendText(false, UIRes.I18N("MsgUpdateV2rayCoreSuccessfullyMore"));
|
||||
|
||||
Global.reloadV2ray = true;
|
||||
|
|
|
@ -161,6 +161,8 @@ namespace v2rayN
|
|||
slow = 3000
|
||||
}
|
||||
public const string StatisticLogOverall = "StatisticLogOverall.json";
|
||||
|
||||
public const string IEProxyExceptions = "<local>;localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;172.32.*";
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -43,22 +43,22 @@ namespace v2rayN.Handler
|
|||
|
||||
public StatisticsHandler(Mode.Config config, Action<ulong, ulong, List<ServerStatItem>> update)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Environment.Is64BitOperatingSystem)
|
||||
{
|
||||
FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x64.dll"), Resources.grpc_csharp_ext_x64_dll);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x86.dll"), Resources.grpc_csharp_ext_x86_dll);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
//try
|
||||
//{
|
||||
// if (Environment.Is64BitOperatingSystem)
|
||||
// {
|
||||
// FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x64.dll"), Resources.grpc_csharp_ext_x64_dll);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x86.dll"), Resources.grpc_csharp_ext_x86_dll);
|
||||
// }
|
||||
//}
|
||||
//catch (IOException ex)
|
||||
//{
|
||||
// Utils.SaveLog(ex.Message, ex);
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
config_ = config;
|
||||
Enable = config.enableStatistics;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace v2rayN.HttpProxyHandler
|
|||
/// <summary>
|
||||
/// 系统代理(http)总处理
|
||||
/// 启动privoxy提供http协议
|
||||
/// 使用SysProxy设置IE系统代理或者PAC模式
|
||||
/// 设置IE系统代理或者PAC模式
|
||||
/// </summary>
|
||||
class HttpProxyHandle
|
||||
{
|
||||
|
@ -31,31 +31,31 @@ namespace v2rayN.HttpProxyHandler
|
|||
if (type == 1)
|
||||
{
|
||||
//PACServerHandle.Stop();
|
||||
SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}", null);
|
||||
ProxySetting.SetProxy($"{Global.Loopback}:{port}", Global.IEProxyExceptions, 2);
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
string pacUrl = GetPacUrl();
|
||||
SysProxyHandle.SetIEProxy(true, false, null, pacUrl);
|
||||
ProxySetting.SetProxy(pacUrl, "", 4);
|
||||
//PACServerHandle.Stop();
|
||||
PACServerHandle.Init(config);
|
||||
}
|
||||
else if (type == 3)
|
||||
{
|
||||
//PACServerHandle.Stop();
|
||||
SysProxyHandle.SetIEProxy(false, false, null, null);
|
||||
ProxySetting.UnsetProxy();
|
||||
}
|
||||
else if (type == 4)
|
||||
{
|
||||
string pacUrl = GetPacUrl();
|
||||
SysProxyHandle.SetIEProxy(false, false, null, null);
|
||||
ProxySetting.UnsetProxy();
|
||||
//PACServerHandle.Stop();
|
||||
PACServerHandle.Init(config);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SysProxyHandle.SetIEProxy(false, false, null, null);
|
||||
ProxySetting.UnsetProxy();
|
||||
//PACServerHandle.Stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,26 +8,46 @@ namespace v2rayN.HttpProxyHandler
|
|||
{
|
||||
public static bool UnsetProxy()
|
||||
{
|
||||
return SetProxy(null, null);
|
||||
}
|
||||
public static bool SetProxy(string strProxy)
|
||||
{
|
||||
return SetProxy(strProxy, null);
|
||||
return SetProxy(null, null, 1);
|
||||
}
|
||||
|
||||
public static bool SetProxy(string strProxy, string exceptions)
|
||||
public static bool SetProxy(string strProxy, string exceptions, int type)
|
||||
{
|
||||
InternetPerConnOptionList list = new InternetPerConnOptionList();
|
||||
|
||||
int optionCount = Utils.IsNullOrEmpty(strProxy) ? 1 : (Utils.IsNullOrEmpty(exceptions) ? 2 : 3);
|
||||
int optionCount = 1;
|
||||
if (type == 1)
|
||||
{
|
||||
optionCount = 1;
|
||||
}
|
||||
else if (type == 2 || type == 4)
|
||||
{
|
||||
optionCount = Utils.IsNullOrEmpty(exceptions) ? 2 : 3;
|
||||
}
|
||||
|
||||
int m_Int = (int)PerConnFlags.PROXY_TYPE_DIRECT;
|
||||
PerConnOption m_Option = PerConnOption.INTERNET_PER_CONN_FLAGS;
|
||||
if (type == 2)
|
||||
{
|
||||
m_Int = (int)(PerConnFlags.PROXY_TYPE_DIRECT | PerConnFlags.PROXY_TYPE_PROXY);
|
||||
m_Option = PerConnOption.INTERNET_PER_CONN_PROXY_SERVER;
|
||||
}
|
||||
else if (type == 4)
|
||||
{
|
||||
m_Int = (int)(PerConnFlags.PROXY_TYPE_DIRECT | PerConnFlags.PROXY_TYPE_AUTO_PROXY_URL);
|
||||
m_Option = PerConnOption.INTERNET_PER_CONN_AUTOCONFIG_URL;
|
||||
}
|
||||
|
||||
//int optionCount = Utils.IsNullOrEmpty(strProxy) ? 1 : (Utils.IsNullOrEmpty(exceptions) ? 2 : 3);
|
||||
InternetConnectionOption[] options = new InternetConnectionOption[optionCount];
|
||||
// USE a proxy server ...
|
||||
options[0].m_Option = PerConnOption.INTERNET_PER_CONN_FLAGS;
|
||||
options[0].m_Value.m_Int = (int)((optionCount < 2) ? PerConnFlags.PROXY_TYPE_DIRECT : (PerConnFlags.PROXY_TYPE_DIRECT | PerConnFlags.PROXY_TYPE_PROXY));
|
||||
//options[0].m_Value.m_Int = (int)((optionCount < 2) ? PerConnFlags.PROXY_TYPE_DIRECT : (PerConnFlags.PROXY_TYPE_DIRECT | PerConnFlags.PROXY_TYPE_PROXY));
|
||||
options[0].m_Value.m_Int = m_Int;
|
||||
// use THIS proxy server
|
||||
if (optionCount > 1)
|
||||
{
|
||||
options[1].m_Option = PerConnOption.INTERNET_PER_CONN_PROXY_SERVER;
|
||||
options[1].m_Option = m_Option;
|
||||
options[1].m_Value.m_StringPtr = Marshal.StringToHGlobalAuto(strProxy);
|
||||
// except for these addresses ...
|
||||
if (optionCount > 2)
|
||||
|
@ -181,7 +201,7 @@ namespace v2rayN.HttpProxyHandler
|
|||
string ProxyServer = rk.GetValue("ProxyServer").ToString();
|
||||
rk.Close();
|
||||
return ProxyServer;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue