启用系统代理时禁用“自动检测设置”,并且无必要时不清除原有代理服务器设置。
This commit is contained in:
@@ -55,16 +55,21 @@ namespace Shadowsocks.Controller
|
||||
else
|
||||
pacUrl = "http://127.0.0.1:" + config.localPort.ToString() + "/pac?t=" + GetTimestamp(DateTime.Now);
|
||||
registry.SetValue("ProxyEnable", 0);
|
||||
registry.SetValue("ProxyServer", "");
|
||||
//registry.SetValue("ProxyServer", ""); //Unnecessary
|
||||
registry.SetValue("AutoConfigURL", pacUrl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
registry.SetValue("ProxyEnable", 0);
|
||||
registry.SetValue("ProxyServer", "");
|
||||
if (global)
|
||||
{
|
||||
registry.SetValue("ProxyServer", "");
|
||||
}
|
||||
registry.SetValue("AutoConfigURL", "");
|
||||
}
|
||||
//Set AutoDetectProxy Off
|
||||
IEAutoDetectProxy(false);
|
||||
SystemProxy.NotifyIE();
|
||||
//Must Notify IE first, or the connections do not chanage
|
||||
CopyProxySettingFromLan();
|
||||
@@ -106,5 +111,30 @@ namespace Shadowsocks.Controller
|
||||
{
|
||||
return value.ToString("yyyyMMddHHmmssffff");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks or unchecks the IE Options Connection setting of "Automatically detect Proxy"
|
||||
/// </summary>
|
||||
/// <param name="set">Provide 'true' if you want to check the 'Automatically detect Proxy' check box. To uncheck, pass 'false'</param>
|
||||
private static void IEAutoDetectProxy(bool set)
|
||||
{
|
||||
RegistryKey registry =
|
||||
Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections",
|
||||
true);
|
||||
byte[] defConnection = (byte[])registry.GetValue("DefaultConnectionSettings");
|
||||
byte[] savedLegacySetting = (byte[])registry.GetValue("SavedLegacySettings");
|
||||
if (set)
|
||||
{
|
||||
defConnection[8] = Convert.ToByte(defConnection[8] & 8);
|
||||
savedLegacySetting[8] = Convert.ToByte(savedLegacySetting[8] & 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
defConnection[8] = Convert.ToByte(defConnection[8] & ~8);
|
||||
savedLegacySetting[8] = Convert.ToByte(savedLegacySetting[8] & ~8);
|
||||
}
|
||||
registry.SetValue("DefaultConnectionSettings", defConnection);
|
||||
registry.SetValue("SavedLegacySettings", savedLegacySetting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user