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.HttpProxyHandler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Base;
|
using v2rayN.Base;
|
||||||
|
using v2rayN.Tool;
|
||||||
|
|
||||||
namespace v2rayN.Forms
|
namespace v2rayN.Forms
|
||||||
{
|
{
|
||||||
|
@ -1178,15 +1179,8 @@ namespace v2rayN.Forms
|
||||||
|
|
||||||
string fileName = downloadHandle.DownloadFileName;
|
string fileName = downloadHandle.DownloadFileName;
|
||||||
fileName = Utils.GetPath(fileName);
|
fileName = Utils.GetPath(fileName);
|
||||||
using (ZipArchive archive = ZipFile.OpenRead(fileName))
|
FileManager.ZipExtractToFile(fileName);
|
||||||
{
|
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
|
||||||
{
|
|
||||||
if (entry.Length == 0)
|
|
||||||
continue;
|
|
||||||
entry.ExtractToFile(Utils.GetPath(entry.Name), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AppendText(false, UIRes.I18N("MsgUpdateV2rayCoreSuccessfullyMore"));
|
AppendText(false, UIRes.I18N("MsgUpdateV2rayCoreSuccessfullyMore"));
|
||||||
|
|
||||||
Global.reloadV2ray = true;
|
Global.reloadV2ray = true;
|
||||||
|
|
|
@ -162,6 +162,8 @@ namespace v2rayN
|
||||||
}
|
}
|
||||||
public const string StatisticLogOverall = "StatisticLogOverall.json";
|
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
|
#endregion
|
||||||
|
|
||||||
#region 全局变量
|
#region 全局变量
|
||||||
|
|
|
@ -43,22 +43,22 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
public StatisticsHandler(Mode.Config config, Action<ulong, ulong, List<ServerStatItem>> update)
|
public StatisticsHandler(Mode.Config config, Action<ulong, ulong, List<ServerStatItem>> update)
|
||||||
{
|
{
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
if (Environment.Is64BitOperatingSystem)
|
// if (Environment.Is64BitOperatingSystem)
|
||||||
{
|
// {
|
||||||
FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x64.dll"), Resources.grpc_csharp_ext_x64_dll);
|
// FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x64.dll"), Resources.grpc_csharp_ext_x64_dll);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x86.dll"), Resources.grpc_csharp_ext_x86_dll);
|
// FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x86.dll"), Resources.grpc_csharp_ext_x86_dll);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
catch (IOException ex)
|
//catch (IOException ex)
|
||||||
{
|
//{
|
||||||
Utils.SaveLog(ex.Message, ex);
|
// Utils.SaveLog(ex.Message, ex);
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
config_ = config;
|
config_ = config;
|
||||||
Enable = config.enableStatistics;
|
Enable = config.enableStatistics;
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace v2rayN.HttpProxyHandler
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 系统代理(http)总处理
|
/// 系统代理(http)总处理
|
||||||
/// 启动privoxy提供http协议
|
/// 启动privoxy提供http协议
|
||||||
/// 使用SysProxy设置IE系统代理或者PAC模式
|
/// 设置IE系统代理或者PAC模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class HttpProxyHandle
|
class HttpProxyHandle
|
||||||
{
|
{
|
||||||
|
@ -31,31 +31,31 @@ namespace v2rayN.HttpProxyHandler
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
{
|
{
|
||||||
//PACServerHandle.Stop();
|
//PACServerHandle.Stop();
|
||||||
SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}", null);
|
ProxySetting.SetProxy($"{Global.Loopback}:{port}", Global.IEProxyExceptions, 2);
|
||||||
}
|
}
|
||||||
else if (type == 2)
|
else if (type == 2)
|
||||||
{
|
{
|
||||||
string pacUrl = GetPacUrl();
|
string pacUrl = GetPacUrl();
|
||||||
SysProxyHandle.SetIEProxy(true, false, null, pacUrl);
|
ProxySetting.SetProxy(pacUrl, "", 4);
|
||||||
//PACServerHandle.Stop();
|
//PACServerHandle.Stop();
|
||||||
PACServerHandle.Init(config);
|
PACServerHandle.Init(config);
|
||||||
}
|
}
|
||||||
else if (type == 3)
|
else if (type == 3)
|
||||||
{
|
{
|
||||||
//PACServerHandle.Stop();
|
//PACServerHandle.Stop();
|
||||||
SysProxyHandle.SetIEProxy(false, false, null, null);
|
ProxySetting.UnsetProxy();
|
||||||
}
|
}
|
||||||
else if (type == 4)
|
else if (type == 4)
|
||||||
{
|
{
|
||||||
string pacUrl = GetPacUrl();
|
string pacUrl = GetPacUrl();
|
||||||
SysProxyHandle.SetIEProxy(false, false, null, null);
|
ProxySetting.UnsetProxy();
|
||||||
//PACServerHandle.Stop();
|
//PACServerHandle.Stop();
|
||||||
PACServerHandle.Init(config);
|
PACServerHandle.Init(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SysProxyHandle.SetIEProxy(false, false, null, null);
|
ProxySetting.UnsetProxy();
|
||||||
//PACServerHandle.Stop();
|
//PACServerHandle.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,26 +8,46 @@ namespace v2rayN.HttpProxyHandler
|
||||||
{
|
{
|
||||||
public static bool UnsetProxy()
|
public static bool UnsetProxy()
|
||||||
{
|
{
|
||||||
return SetProxy(null, null);
|
return SetProxy(null, null, 1);
|
||||||
}
|
|
||||||
public static bool SetProxy(string strProxy)
|
|
||||||
{
|
|
||||||
return SetProxy(strProxy, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool SetProxy(string strProxy, string exceptions)
|
public static bool SetProxy(string strProxy, string exceptions, int type)
|
||||||
{
|
{
|
||||||
InternetPerConnOptionList list = new InternetPerConnOptionList();
|
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];
|
InternetConnectionOption[] options = new InternetConnectionOption[optionCount];
|
||||||
// USE a proxy server ...
|
// USE a proxy server ...
|
||||||
options[0].m_Option = PerConnOption.INTERNET_PER_CONN_FLAGS;
|
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
|
// use THIS proxy server
|
||||||
if (optionCount > 1)
|
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);
|
options[1].m_Value.m_StringPtr = Marshal.StringToHGlobalAuto(strProxy);
|
||||||
// except for these addresses ...
|
// except for these addresses ...
|
||||||
if (optionCount > 2)
|
if (optionCount > 2)
|
||||||
|
|
Loading…
Reference in New Issue