public void OnAliveProxy(ProxyInfo proxyInfo) { if (proxyInfo.Details != null && proxyInfo.Details.Details != null && Context.Get<AllSettings>().IgnoredHttpProxyTypes.Any(item => item.ToString() == proxyInfo.Details.Details.Type)) return; if (ExportAllowed && ExportSettings.ExportSearchResult) { lock (this) { if (stream == null) { stream = CreateFile(GetDirectory(proxyInfo.Details.Details)); } stream.WriteLine(proxyInfo.ToString(ExportSettings.ExportCountry, ExportSettings.ExportProxyType)); } } Context.Get<ISearchResult>().Add(proxyInfo); isProxyFound = true; if (!isTimingNotificationSent) { isTimingNotificationSent = true; Context.Get<IGA>().EndTrackTiming(TimingCategory.SearchSpeed, TimingVariable.TimeForGetFirstProxy, GAResources.FirstProxyFound); } }
protected override void SetProxy(ProxyInfo proxyInfo) { if (proxyInfo != null) { SocksProxyTypes type = proxyInfo.Details.Details.GetStrongType<SocksProxyTypes>(); if (type == SocksProxyTypes.Socks5) { Context.Get<IMessageBox>().Information(Resources.ThisClientDoesntSupportSocks5Proxies); IsProxyChangeCancelled = true; return; } if (type != SocksProxyTypes.Socks4) { if (Context.Get<IMessageBox>().YesNoQuestion(Resources.TypeOfProxyIsNotDefinedDoYouWantToContinue) == MessageBoxResult.No) { IsProxyChangeCancelled = true; return; } } } base.SetProxy(proxyInfo); }
static void application_ProxyAlive(ProxyInfo proxyInfo) { switch (proxyInfo.Details.Details.GetStrongType<HttpProxyTypes>()) { case HttpProxyTypes.Anonymous: case HttpProxyTypes.HighAnonymous: Console.WriteLine(proxyInfo.AddressPort); break; default: break; } }
protected override void SetProxy(ProxyInfo proxyInfo) { if (proxyInfo != null) { IniFile.WriteValue(SettingsPath, SectionName, string.Format("{0} server", ProtocolName), proxyInfo.AddressPort); IniFile.WriteValue(SettingsPath, SectionName, string.Format("Use {0}", ProtocolName), "1"); } else { IniFile.WriteValue(SettingsPath, SectionName, string.Format("{0} server", ProtocolName), null); IniFile.WriteValue(SettingsPath, SectionName, string.Format("Use {0}", ProtocolName), null); } }
protected override void SetProxy(ProxyInfo proxyInfo) { //Proxy was not specified if (WinINet.ProxyIpPort == null) { WinINet.SetProxy(proxyInfo != null, proxyInfo != null ? GetProtocolString(proxyInfo) : null); return; } List<string> arguments = WinINet.ProxyIpPort .Split(';') .ToList(); //Single host is used for all types of proxy if (arguments.Count == 1 && arguments.Single().Split('=').Length == 1) { WinINet.SetProxy(proxyInfo != null, proxyInfo != null ? proxyInfo.AddressPort : null); return; } //Single protocol specific proxy is set or array of them int index = GetIndexOfCurrentProtocol(arguments); if (proxyInfo == null) { if (index != -1) arguments.RemoveAt(index); WinINet.SetProxy(arguments.Any(), arguments.Any() ? string.Join(",", arguments) : null); return; } if (index == -1) arguments.Add(GetProtocolString(proxyInfo)); else arguments[index] = GetProtocolString(proxyInfo); WinINet.SetProxy(true, string.Join(",", arguments)); }
protected override string SetProxy(ProxyInfo proxyInfo, string content) { SocksProxyTypes? type = proxyInfo != null ? (SocksProxyTypes?)proxyInfo.Details.Details.GetStrongType<SocksProxyTypes>() : null; if (type.HasValue) { if (type != SocksProxyTypes.Socks4 && type != SocksProxyTypes.Socks5) { Context.Get<IMessageBox>().Information(Resources.CannotSetProxyForFirefoxWhenSocksVersionIsNotDefined); IsProxyChangeCancelled = true; return content; } } content = base.SetProxy(proxyInfo, content); if (type.HasValue) { return WritePref(content, "network.proxy.socks_version", ((int)type).ToString()); } return content; }
private string GetProtocolString(ProxyInfo proxyInfo) { return string.Format("{0}={1}", GetProtocolName("http", "socks"), proxyInfo.AddressPort); }
protected virtual string SetProxy(ProxyInfo proxyInfo, string content) { content = WritePref(content, proxyTypePref, proxyInfo != null ? "1" : "0"); content = WritePref(content, ProxyPref, proxyInfo != null ? string.Format("\"{0}\"", proxyInfo.Address) : null); return WritePref(content, ProxyPortPref, proxyInfo != null ? proxyInfo.Port.ToString() : null); }
protected sealed override void SetProxy(ProxyInfo proxyInfo) { File.WriteAllText(SettingsPath, SetProxy(proxyInfo, File.ReadAllText(SettingsPath))); }
protected abstract void SetProxy(ProxyInfo proxyInfo);
public void OnAliveProxy(ProxyInfo proxyInfo) { if (ProxyAlive != null) ProxyAlive(proxyInfo); }