|
|
@ -3,6 +3,19 @@ using v2rayN.Mode; |
|
|
|
|
|
|
|
|
|
|
|
namespace v2rayN.HttpProxyHandler |
|
|
|
namespace v2rayN.HttpProxyHandler |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 系统代理(http)模式 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public enum ListenerType |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
noHttpProxy = 0, |
|
|
|
|
|
|
|
GlobalHttp = 1, |
|
|
|
|
|
|
|
GlobalPac = 2, |
|
|
|
|
|
|
|
HttpOpenAndClear = 3, |
|
|
|
|
|
|
|
PacOpenAndClear = 4, |
|
|
|
|
|
|
|
HttpOpenOnly = 5, |
|
|
|
|
|
|
|
PacOpenOnly = 6 |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 系统代理(http)总处理 |
|
|
|
/// 系统代理(http)总处理 |
|
|
|
/// 启动privoxy提供http协议 |
|
|
|
/// 启动privoxy提供http协议 |
|
|
@ -12,29 +25,29 @@ namespace v2rayN.HttpProxyHandler |
|
|
|
{ |
|
|
|
{ |
|
|
|
private static bool Update(Config config, bool forceDisable) |
|
|
|
private static bool Update(Config config, bool forceDisable) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int type = config.listenerType; |
|
|
|
ListenerType type = config.listenerType; |
|
|
|
|
|
|
|
|
|
|
|
if (forceDisable) |
|
|
|
if (forceDisable) |
|
|
|
{ |
|
|
|
{ |
|
|
|
type = 0; |
|
|
|
type = ListenerType.noHttpProxy; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (type != 0) |
|
|
|
if (type != ListenerType.noHttpProxy) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int port = Global.httpPort; |
|
|
|
int port = Global.httpPort; |
|
|
|
if (port <= 0) |
|
|
|
if (port <= 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (type == 1) |
|
|
|
if (type == ListenerType.GlobalHttp) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
//ProxySetting.SetProxy($"{Global.Loopback}:{port}", Global.IEProxyExceptions, 2); |
|
|
|
//ProxySetting.SetProxy($"{Global.Loopback}:{port}", Global.IEProxyExceptions, 2); |
|
|
|
SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}"); |
|
|
|
SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (type == 2) |
|
|
|
else if (type == ListenerType.GlobalPac) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string pacUrl = GetPacUrl(); |
|
|
|
string pacUrl = GetPacUrl(); |
|
|
|
//ProxySetting.SetProxy(pacUrl, "", 4); |
|
|
|
//ProxySetting.SetProxy(pacUrl, "", 4); |
|
|
@ -42,24 +55,24 @@ namespace v2rayN.HttpProxyHandler |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
PACServerHandle.Init(config); |
|
|
|
PACServerHandle.Init(config); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (type == 3) |
|
|
|
else if (type == ListenerType.HttpOpenAndClear) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
SysProxyHandle.ResetIEProxy(); |
|
|
|
SysProxyHandle.ResetIEProxy(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (type == 4) |
|
|
|
else if (type == ListenerType.PacOpenAndClear) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string pacUrl = GetPacUrl(); |
|
|
|
string pacUrl = GetPacUrl(); |
|
|
|
SysProxyHandle.ResetIEProxy(); |
|
|
|
SysProxyHandle.ResetIEProxy(); |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
PACServerHandle.Init(config); |
|
|
|
PACServerHandle.Init(config); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (type == 5) |
|
|
|
else if (type == ListenerType.HttpOpenOnly) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
//PACServerHandle.Stop(); |
|
|
|
//SysProxyHandle.ResetIEProxy(); |
|
|
|
//SysProxyHandle.ResetIEProxy(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (type == 6) |
|
|
|
else if (type == ListenerType.PacOpenOnly) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string pacUrl = GetPacUrl(); |
|
|
|
string pacUrl = GetPacUrl(); |
|
|
|
//SysProxyHandle.ResetIEProxy(); |
|
|
|
//SysProxyHandle.ResetIEProxy(); |
|
|
@ -114,7 +127,7 @@ namespace v2rayN.HttpProxyHandler |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (config.listenerType != 5 && config.listenerType != 6) |
|
|
|
if (config.listenerType != ListenerType.HttpOpenOnly && config.listenerType != ListenerType.PacOpenOnly) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Update(config, true); |
|
|
|
Update(config, true); |
|
|
|
} |
|
|
|
} |
|
|
@ -138,7 +151,7 @@ namespace v2rayN.HttpProxyHandler |
|
|
|
public static void RestartHttpAgent(Config config, bool forced) |
|
|
|
public static void RestartHttpAgent(Config config, bool forced) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool isRestart = false; |
|
|
|
bool isRestart = false; |
|
|
|
if (config.listenerType == 0) |
|
|
|
if (config.listenerType == ListenerType.noHttpProxy) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// 关闭http proxy时,直接返回 |
|
|
|
// 关闭http proxy时,直接返回 |
|
|
|
return; |
|
|
|
return; |
|
|
|