public bool ShouldProxyBeBypassed(HttpProxySettings proxySettings, HttpUri url)
        {
            //We are utilizing the WebProxy implementation here to save us having to re-implement it. This way we use Microsofts implementation
            var proxy = new WebProxy(proxySettings.Host + ":" + proxySettings.Port, proxySettings.BypassLocalAddress, proxySettings.BypassListAsArray);

            return(proxy.IsBypassed((Uri)url));
        }
예제 #2
0
        protected virtual System.Net.Http.HttpClient CreateHttpClient(HttpProxySettings proxySettings)
        {
            var handler = new SocketsHttpHandler()
            {
                AutomaticDecompression  = DecompressionMethods.GZip | DecompressionMethods.Brotli,
                UseCookies              = false, // sic - we don't want to use a shared cookie container
                AllowAutoRedirect       = false,
                Credentials             = GetCredentialCache(),
                PreAuthenticate         = true,
                MaxConnectionsPerServer = 12,
                ConnectCallback         = onConnect,
                SslOptions              = new SslClientAuthenticationOptions
                {
                    RemoteCertificateValidationCallback = _certificateValidationService.ShouldByPassValidationError
                }
            };

            if (proxySettings != null)
            {
                handler.Proxy = _createManagedWebProxy.GetWebProxy(proxySettings);
            }

            var client = new System.Net.Http.HttpClient(handler)
            {
                Timeout = Timeout.InfiniteTimeSpan
            };

            return(client);
        }
예제 #3
0
        public HttpProxySettings SetHttpProxy(HttpProxySettings settings)
        {
            if (_dataContainer != null)
                _dataContainer.HttpProxySettings = settings;

            return settings;
        }
예제 #4
0
 public void CopyProperties(HttpProxySettings source)
 {
     this.UseProxy  = source.UseProxy;
     this.ProxyHost = source.ProxyHost;
     this.ProxyPort = source.ProxyPort;
     this.UserName  = source.UserName;
     this.Password  = source.Password;
 }
예제 #5
0
 private void HttpProxySettingsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         HttpProxySettings settings = _dataContainer.HttpProxySettings;
         HttpProxySettingsForm form = new HttpProxySettingsForm { HttpProxySettings = settings };
         if (form.ShowDialog() == DialogResult.OK)
             form.HttpProxySettings.Save();
     }
     catch (Exception ex)
     {
         ex.ToMessageBox();
     }
 }
예제 #6
0
        public HttpProxySettings GetProxySettings(HttpRequest request)
        {
            if (!_configService.ProxyEnabled)
            {
                return(null);
            }

            var proxySettings = new HttpProxySettings(_configService.ProxyType,
                                                      _configService.ProxyHostname,
                                                      _configService.ProxyPort,
                                                      _configService.ProxyBypassFilter,
                                                      _configService.ProxyBypassLocalAddresses,
                                                      _configService.ProxyUsername,
                                                      _configService.ProxyPassword);

            if (ShouldProxyBeBypassed(proxySettings, request.Url))
            {
                return(null);
            }

            return(proxySettings);
        }
예제 #7
0
 public HttpsConnectionFactory(HttpProxySettings proxySettings)
 {
     this.ProxySettings = proxySettings;
     this.TargetPort = 8099;
 }
예제 #8
0
 public HttpsConnectionFactory(HttpProxySettings proxySettings)
 {
     this.ProxySettings = proxySettings;
     this.TargetPort    = 8099;
 }