public override async Task<ProxyTypeDetails> GetProxyDetails(Proxy proxy, TaskItem task, CancellationTokenSource cancellationToken) { string proxyUriString = GetProxyUriString(proxy); var httpDownloaderContainer = new HttpDownloaderContainer<SocksHttpClientHandler, SocksProgressMessageHandler>(); string content = await httpDownloaderContainer.HttpDownloader.GetContentOrNull(GetProxyTypeDetectorUrl(proxy, Resources.SocksProxyType), proxy, cancellationToken); if (content == null) return new SocksProxyDetails(Application.SocksProxyHashTable[proxyUriString], null); string[] values = content.Split(','); IPAddress outgoingIPAddress; if (values.Length != 2 || !IPAddress.TryParse(values[1], out outgoingIPAddress)) return new SocksProxyDetails(SocksProxyTypes.ChangesContent, null); return new SocksProxyDetails(Application.SocksProxyHashTable[proxyUriString], outgoingIPAddress); }
public Application Create(TaskItem task, ProxySearchFeedback feedback) { Context.Set(new CancellationTokenSource()); Context.Set<IHttpDownloaderContainer>(HttpDownloaderContainer); task.UpdateDetails(Resources.ReadingConfigurationOfSelectedSearch); IDetectable searchEngineDetectable = DetectableManager.CreateDetectableInstance<ISearchEngine>(Settings.SelectedTabSettings.SearchEngineDetectableType); IDetectable proxyCheckerDetectable = DetectableManager.CreateDetectableInstance<IProxyChecker>(Settings.SelectedTabSettings.ProxyCheckerDetectableType); IDetectable geoIPDetectable = DetectableManager.CreateDetectableInstance<IGeoIP>(Settings.GeoIPDetectableType); ISearchEngine searchEngine = DetectableManager.CreateImplementationInstance<ISearchEngine>(searchEngineDetectable, Settings.SelectedTabSettings.SearchEngineSettings, searchEngineDetectable.InterfaceSettings); feedback.ExportAllowed = !(searchEngine is FolderSearchEngine); task.UpdateDetails(Resources.PreparingProxyProvider); IProxyProvider proxyProvider = new ProxyProvider(Context.Get<IBlackList>(), new ParseMethodsProvider(Settings.ParseDetails)); task.UpdateDetails(Resources.PreparingProxyChecker); IProxyChecker proxyChecker = DetectableManager.CreateImplementationInstance<IProxyChecker>(proxyCheckerDetectable, Settings.SelectedTabSettings.ProxyCheckerSettings, proxyCheckerDetectable.InterfaceSettings); task.UpdateDetails(Resources.PreparingGeoIpService); IGeoIP geoIP = DetectableManager.CreateImplementationInstance<IGeoIP>(geoIPDetectable, Settings.GeoIPSettings, geoIPDetectable.InterfaceSettings); task.UpdateDetails(Resources.PreparingApplication); Application application = new Application(searchEngine, proxyChecker, HttpDownloaderContainer, geoIP, proxyProvider, Context.Get<ITaskManager>()); application.ProxyAlive += feedback.OnAliveProxy; application.OnError += Context.Get<IErrorFeedback>().SetException; return application; }
public override async Task<ProxyTypeDetails> GetProxyDetails(Proxy proxy, TaskItem task, CancellationTokenSource cancellationToken) { task.UpdateDetails(string.Format(Resources.WaitUntilProxyDetailsProviderConfiguredFormat, proxy.AddressPort), Tasks.TaskStatus.Slow); await initializatinTask; task.UpdateDetails(string.Format(Resources.ProxyDeterminingProxyType, proxy.AddressPort), Tasks.TaskStatus.Normal); string result = await httpDownloaderContainer.HttpDownloader.GetContentOrNull(GetProxyTypeDetectorUrl(proxy, myIPAddress, Resources.HttpProxyType), proxy, cancellationToken); if (result == null) return new HttpProxyDetails(HttpProxyTypes.CannotVerify, null); string[] values = result.Split(','); HttpProxyTypes proxyType; IPAddress outgoingIPAddress; if (values.Length != 2 || !Enum.TryParse(values[0], out proxyType) || !IPAddress.TryParse(values[1], out outgoingIPAddress)) return new HttpProxyDetails(HttpProxyTypes.ChangesContent, null); return new HttpProxyDetails(proxyType, outgoingIPAddress); }