enable proxy for all connections
This commit is contained in:
@@ -35,6 +35,8 @@ namespace Shadowsocks.Controller
|
||||
registry.SetValue("ProxyServer", "");
|
||||
registry.SetValue("AutoConfigURL", "http://127.0.0.1:8090/pac?t=" + GetTimestamp(DateTime.Now));
|
||||
SystemProxy.NotifyIE();
|
||||
//Must Notify IE first, or the connections do not chanage
|
||||
CopyProxySettingFromLan();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -54,6 +56,7 @@ namespace Shadowsocks.Controller
|
||||
registry.SetValue("ProxyServer", "");
|
||||
registry.SetValue("AutoConfigURL", "");
|
||||
SystemProxy.NotifyIE();
|
||||
CopyProxySettingFromLan();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -62,6 +65,25 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
}
|
||||
|
||||
private static void CopyProxySettingFromLan()
|
||||
{
|
||||
RegistryKey registry =
|
||||
Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections",
|
||||
true);
|
||||
var defulatValue = registry.GetValue("DefaultConnectionSettings");
|
||||
var connections = registry.GetValueNames();
|
||||
foreach (String each in connections){
|
||||
if (!(each.Equals("DefaultConnectionSettings")
|
||||
|| each.Equals("LAN Connection")
|
||||
|| each.Equals("SavedLegacySettings")))
|
||||
{
|
||||
//set all the connections's proxy as the lan
|
||||
registry.SetValue(each, defulatValue);
|
||||
}
|
||||
}
|
||||
NotifyIE();
|
||||
}
|
||||
|
||||
private static String GetTimestamp(DateTime value)
|
||||
{
|
||||
return value.ToString("yyyyMMddHHmmssffff");
|
||||
|
||||
Reference in New Issue
Block a user