Browse Source

enable proxy for all connections

tags/2.3
GhostFlying 10 years ago
parent
commit
58ba4e28e7
1 changed files with 22 additions and 0 deletions
  1. +22
    -0
      shadowsocks-csharp/Controller/SystemProxy.cs

+ 22
- 0
shadowsocks-csharp/Controller/SystemProxy.cs View File

@@ -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");


Loading…
Cancel
Save