You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

SystemProxy.cs 1.7 kB

11 years ago
11 years ago
11 years ago
11 years ago
9 years ago
9 years ago
9 years ago
9 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using Shadowsocks.Model;
  3. using Shadowsocks.Util.SystemProxy;
  4. namespace Shadowsocks.Controller
  5. {
  6. public static class SystemProxy
  7. {
  8. private static string GetTimestamp(DateTime value)
  9. {
  10. return value.ToString("yyyyMMddHHmmssfff");
  11. }
  12. public static void Update(Configuration config, bool forceDisable, PACServer pacSrv)
  13. {
  14. bool global = config.global;
  15. bool enabled = config.enabled;
  16. if (forceDisable)
  17. {
  18. enabled = false;
  19. }
  20. try
  21. {
  22. if (enabled)
  23. {
  24. if (global)
  25. {
  26. Sysproxy.SetIEProxy(true, true, "127.0.0.1:" + config.localPort.ToString(), null);
  27. }
  28. else
  29. {
  30. string pacUrl;
  31. if (config.useOnlinePac && !config.pacUrl.IsNullOrEmpty())
  32. {
  33. pacUrl = config.pacUrl;
  34. }
  35. else
  36. {
  37. pacUrl = pacSrv.PacUrl;
  38. }
  39. Sysproxy.SetIEProxy(true, false, null, pacUrl);
  40. }
  41. }
  42. else
  43. {
  44. Sysproxy.SetIEProxy(false, false, null, null);
  45. }
  46. }
  47. catch (ProxyException ex)
  48. {
  49. Logging.LogUsefulException(ex);
  50. }
  51. }
  52. }
  53. }