|
@@ -55,16 +55,21 @@ namespace Shadowsocks.Controller |
|
|
else
|
|
|
else
|
|
|
pacUrl = "http://127.0.0.1:" + config.localPort.ToString() + "/pac?t=" + GetTimestamp(DateTime.Now);
|
|
|
pacUrl = "http://127.0.0.1:" + config.localPort.ToString() + "/pac?t=" + GetTimestamp(DateTime.Now);
|
|
|
registry.SetValue("ProxyEnable", 0);
|
|
|
registry.SetValue("ProxyEnable", 0);
|
|
|
registry.SetValue("ProxyServer", "");
|
|
|
|
|
|
|
|
|
//registry.SetValue("ProxyServer", ""); //Unnecessary
|
|
|
registry.SetValue("AutoConfigURL", pacUrl);
|
|
|
registry.SetValue("AutoConfigURL", pacUrl);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
{
|
|
|
{
|
|
|
registry.SetValue("ProxyEnable", 0);
|
|
|
registry.SetValue("ProxyEnable", 0);
|
|
|
registry.SetValue("ProxyServer", "");
|
|
|
|
|
|
|
|
|
if (global)
|
|
|
|
|
|
{
|
|
|
|
|
|
registry.SetValue("ProxyServer", "");
|
|
|
|
|
|
}
|
|
|
registry.SetValue("AutoConfigURL", "");
|
|
|
registry.SetValue("AutoConfigURL", "");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//Set AutoDetectProxy Off
|
|
|
|
|
|
IEAutoDetectProxy(false);
|
|
|
SystemProxy.NotifyIE();
|
|
|
SystemProxy.NotifyIE();
|
|
|
//Must Notify IE first, or the connections do not chanage
|
|
|
//Must Notify IE first, or the connections do not chanage
|
|
|
CopyProxySettingFromLan();
|
|
|
CopyProxySettingFromLan();
|
|
@@ -106,5 +111,30 @@ namespace Shadowsocks.Controller |
|
|
{
|
|
|
{
|
|
|
return value.ToString("yyyyMMddHHmmssffff");
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|