public static TestProxyResult TestProxy(IWebProxyWithStatus wp, int timeoutInMs = 10000) { TestProxyResult result = new TestProxyResult(); var sw = new Stopwatch(); using (Devmasters.Net.HttpClient.URLContent url = new Devmasters.Net.HttpClient.URLContent("http://api.devmasters.cz/ip.ashx")) { try { sw.Start(); url.Timeout = timeoutInMs; url.Proxy = wp; string content = url.GetContent().Text; result.Success = (content == wp.GetProxy(apiHost).Host); } catch (Exception ex) { result.Success = false; result.Error = ex; } finally { sw.Stop(); result.ElapsedTime = sw.Elapsed; } return(result); } }
public void CheckStatus(IWebProxyWithStatus proxy) { TestProxyResult res = Helper.TestProxy(proxy); proxy.SetStatus(res); }