示例#1
0
 public void StopProxy()
 {
     if (proxyServer.ProxyRunning)
     {
         proxyServer.BeforeRequest  -= OnRequest;
         proxyServer.BeforeResponse -= OnResponse;
         //proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation;
         //proxyServer.ClientCertificateSelectionCallback -= OnCertificateSelection;
         proxyServer.Stop();
         hostsService.RemoveHostsByTag();
     }
 }
示例#2
0
 public void Initialize()
 {
     //启动时恢复host
     hostsService.RemoveHostsByTag();
     if (ProxySettings.SupportProxyServicesStatus.Value.Count > 0)
     {
         foreach (var item in ProxyDomains.Value)
         {
             if (ProxySettings.SupportProxyServicesStatus.Value.TryGetValue((int)item.DomainTag, out bool value))
             {
                 item.IsEnable = value;
             }
         }
     }
     Proxy = new HttpProxy(ProxyDomains.Value, ProductInfo.Product)
     {
         IsEnableScript         = IsEnableScript,
         IsOnlyWorkSteamBrowser = IsOnlyWorkSteamBrowser
     };
     InitJsScript();
     if (ProxySettings.ProgramStartupRunProxy.Value)
     {
         ProxyStatus = true;
     }
 }