Browse Source

Merge pull request #49 from GhostFlying/master

enable proxy for all connections
tags/2.3
clowwindy 10 years ago
parent
commit
6f358c74be
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("ProxyServer", "");
registry.SetValue("AutoConfigURL", "http://127.0.0.1:8090/pac?t=" + GetTimestamp(DateTime.Now)); registry.SetValue("AutoConfigURL", "http://127.0.0.1:8090/pac?t=" + GetTimestamp(DateTime.Now));
SystemProxy.NotifyIE(); SystemProxy.NotifyIE();
//Must Notify IE first, or the connections do not chanage
CopyProxySettingFromLan();
} }
catch (Exception) catch (Exception)
{ {
@@ -54,6 +56,7 @@ namespace Shadowsocks.Controller
registry.SetValue("ProxyServer", ""); registry.SetValue("ProxyServer", "");
registry.SetValue("AutoConfigURL", ""); registry.SetValue("AutoConfigURL", "");
SystemProxy.NotifyIE(); SystemProxy.NotifyIE();
CopyProxySettingFromLan();
} }
catch (Exception) 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) private static String GetTimestamp(DateTime value)
{ {
return value.ToString("yyyyMMddHHmmssffff"); return value.ToString("yyyyMMddHHmmssffff");


Loading…
Cancel
Save