public MainWindow() { InitializeComponent(); HideButtons(); Outreach_panel.Visibility = Visibility.Visible; ProxyServers.ServersInit(); }
public void SaveProxys() { if (ProxyServers.WriteServers()) { MessageBox.Show("Changes saved."); } }
public void AutoRetestProxy() { var proxyEntitys = ProxyServers; ProxyServers.ForEach(proxyEntity => CheckProxy(proxyEntity)); SaveProxyServers(); }
private void CheckProxyServers() { try { Loading = true; ProxyServers.Clear(); var testTargetUri = TestTargetUri; if (testTargetUri != null) { var route = ProxyClient.CreateRoute(LocalProxy); foreach (var hostEndPoint in ProxyPageScanner.ScanPage(ProxyPage.PageUri, ProxyPage.ParseAsText, ProxyPage.HostPortEx, route, testTargetUri)) { var ipEndPoint = hostEndPoint.IPEndPoint; if (ipEndPoint == null) { continue; } var location = Geolocation.Locate(ipEndPoint.Address, route); var p = ProxyAnalyzer.MeasurePerformance(route, testTargetUri); if (p == null) { continue; } var proxy = new Proxy(hostEndPoint, location, (int)p.Ping.TotalMilliseconds, (int)(p.DownloadSpeed / 1024)); ProxyServers.Add(proxy); } } } finally { Loading = false; } }
void SetEndRankParse() { Rank_Pause_button.Visibility = Visibility.Collapsed; Rank_Continue_button.Visibility = Visibility.Collapsed; Rank_Start_button.Visibility = Visibility.Visible; Rank_Cancel_button.IsEnabled = false; ProxyServers.WriteServers(); }
void SetEndWhoisParse() { Whois_Pause_button.Visibility = Visibility.Collapsed; Whois_Continue_button.Visibility = Visibility.Collapsed; Whois_Start_button.Visibility = Visibility.Visible; Whois_Cancel_button.IsEnabled = false; ProxyServers.WriteServers(); }
public void DeleteProxy() { ProxyServer ps = Proxys_datagrid.SelectedItem as ProxyServer; if (ps != null) { ProxyServers.Delete(ps); } }
private void Add_Button_Click(object sender, RoutedEventArgs e) { try { ProxyServers.AddProxy(Convert.ToInt32(Port_textbox.Text), Adress_textbox.Text, User_textbox.Text, Password_textbox.Text, Convert.ToInt32(Limits_textbox.Text)); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void DoAutoAddFreeProxy(FreeProxySource src) { foreach (var path in src.Paths) { RestClient client = new RestClient(src.Host); var req = client.TakeRequest(path); req.Node.Method = Method.GET; req.Node.AddHeader("User-Agent", "Mozilla / 5.0(Windows NT 10.0; WOW64; rv: 63.0) Gecko / 20100101 Firefox / 63.0"); req.Node.AddHeader("Accept", "text / html,application / xhtml + xml,application / xml; q = 0.9,*/*;q=0.8"); req.Node.AddHeader("Accept-Language", "zh-TW,zh;q=0.8,en-US;q=0.5,en;q=0.3"); req.Node.AddHeader("Accept-Encoding", "gzip, deflate"); var dReq = ((dynamic)req); //dReq.Parameter.url = HttpUtility.UrlPathEncode(longUrl); var rlt = client.Execute(req); var htmlText = encoding.GetString(rlt.RawBytes); var matchs = src.ContentRegex.Matches(htmlText); foreach (Match match in matchs) { if (match.Success) { var ip = match.Groups[1].Value; if (string.IsNullOrEmpty(ip)) { continue; } if (!string.IsNullOrEmpty(src.ReplaceDotString)) { ip = ip.Replace(src.ReplaceDotString, ""); } if (!string.IsNullOrEmpty(src.ReplaceDotString)) { ip = ip.Replace(src.ReplaceDotString, "."); } var port = Convert.ToInt32(match.Groups[2].Value, src.IsHexPortType ? 16 : 10); var newProxy = new WebProxyServerEntity() { FailedNum = 0, IP = ip, Port = port }; if (this.ProxyServers.Find(pxy => pxy.IP == newProxy.IP) == null) { if (CheckProxy(newProxy)) { ProxyServers.Add(newProxy); } } } } } }
private void ChangeProxy() { int index = ProxyServers.IndexOf(CurrentProxy); if (index < ProxyServers.Count - 1) { CurrentProxy = ProxyServers.ElementAt(index + 1); } else { GetProxyServers(); } }
// honor the X-Forwarded-For header set by a configured set of trusted // proxy servers. allows audit logging and proxy user checks to work // via an http proxy public static string GetRemoteAddr(HttpServletRequest request) { string remoteAddr = request.GetRemoteAddr(); string proxyHeader = request.GetHeader("X-Forwarded-For"); if (proxyHeader != null && ProxyServers.IsProxyServer(remoteAddr)) { string clientAddr = proxyHeader.Split(",")[0].Trim(); if (!clientAddr.IsEmpty()) { remoteAddr = clientAddr; } } return(remoteAddr); }
/// <summary> /// 新增或插入数据 /// </summary> /// <param name="proxy"></param> /// <returns></returns> public void AddOrUpdateProxy(ProxyServer proxy) { var result = string.Empty; //创建一个BmobQuery查询对象 BmobQuery query = new BmobQuery(); //查询playerName的值为bmob的记录 query.WhereEqualTo("proxy", proxy.proxy).And().WhereEqualTo("port", proxy.port); var futrue = Bmob.FindTaskAsync <ProxyServers>(ProxyServers.TABLE_NAME, query); ProxyServers proxyServer; if (futrue.Result == null || futrue.Result.results == null || futrue.Result.results.Count == 0) { proxyServer = new ProxyServers(); proxyServer.Set(proxy); if (BmobUser.CurrentUser != null) { proxyServer.user = BmobUser.CurrentUser; } var createResult = Bmob.CreateTaskAsync(proxyServer); } else { proxyServer = futrue.Result.results.FirstOrDefault(); proxyServer.Set(proxy); if (proxyServer.status.Get() == 0) { proxyServer.failedcount = proxyServer.failedcount.Get() + 1; } if (BmobUser.CurrentUser != null) { proxyServer.user = BmobUser.CurrentUser; } if (proxy.failedcount > 5) //失败次数大于5次删除云端 { Bmob.DeleteTaskAsync(ProxyServers.TABLE_NAME, proxyServer.objectId); } else { var updateResult = Bmob.UpdateTaskAsync(ProxyServers.TABLE_NAME, proxyServer.objectId, proxyServer); } } }
private void GetProxyServers() { var proxyPage = RetrievePage("http://www.sslproxies.org/"); // Generate structured document var proxyParser = new HtmlParser(); var proxyDoc = proxyParser.Parse(proxyPage); // Get proxy list var proxyIp = proxyDoc.QuerySelectorAll("table.fpltable > tbody > tr > td:nth-child(1)"); var proxyPort = proxyDoc.QuerySelectorAll("table.fpltable > tbody > tr > td:nth-child(2)"); for (int i = 0; i < proxyIp.Length; i++) { ProxyServers.Add(new ProxyServer { Ip = proxyIp[i].TextContent, Port = proxyPort[i].TextContent }); } CurrentProxy = ProxyServers.First(); }
private void Clear_Button_Click(object sender, RoutedEventArgs e) { ProxyServers.Clear(); Proxys_datagrid.ItemsSource = ProxyServers.Servers; }
public int ProxyServersToCheck() { lock (ProxyServers) { int i; if (!running) { return(-1); } if (!ProxyCheckerContinue()) { return(-2); } // Go troght all proxy servers and sellect with to test. // Priorety 1: working proxy serers that have not been testet sines ProxyReCheck time i = 0; foreach (ProxyServer server in ProxyServers.ToList()) { if (server.Shudled != default(DateTime) && DateTime.Compare(DateTime.Now, server.Shudled.AddMinutes(Properties.Settings.Default.ProxyReCheck)) > 0 && server.Status.Substring(0, 2) == "Ok") { server.Shudled = DateTime.Now; debug("ProxyServersToCheck: Found pri 1. Last checked " + server.Shudled.ToShortTimeString() + " with status " + server.Status); return(i); } i++; } // Priorety 2: new proxy serrvers i = 0; foreach (ProxyServer server in ProxyServers.ToList()) { if (server.Shudled == default(DateTime)) { server.Shudled = DateTime.Now; debug("ProxyServersToCheck: Found pri 2. Newer checked. "); return(i); } i++; } // Priorety 3: old proxy serrvers that was not ok when we testet them last time i = 0; foreach (ProxyServer server in ProxyServers.ToList()) { if (server.Shudled != default(DateTime) && DateTime.Compare(DateTime.Now, server.Shudled.AddMinutes(Properties.Settings.Default.ProxyReCheck)) > 0 && server.Status.Substring(0, 2) != "Ok") { server.Shudled = DateTime.Now; debug("ProxyServersToCheck: Found pri 3. Last checked " + server.Shudled.ToShortTimeString() + " with status " + server.Status); return(i); } i++; } return(-1); } }