private static void ExtractServers(Servers serversInstance, threads threadsInstance, byte[] data) { if (data == null) return; String datastr = Encoding.ASCII.GetString(data); var seps = new string[1]; seps[0] = "\\"; string[] ips = datastr.Split(seps, StringSplitOptions.RemoveEmptyEntries); foreach (var s in ips) { if (s.Length != 6) continue; String ip = ""; ip += ((int)s[0]).ToString(CultureInfo.InvariantCulture) + "."; ip += ((int)s[1]).ToString(CultureInfo.InvariantCulture) + "."; ip += ((int)s[2]).ToString(CultureInfo.InvariantCulture) + "."; ip += ((int)s[3]).ToString(CultureInfo.InvariantCulture); int port = (s[4]) * 256 + (s[5]); threadsInstance.addServerThread(ip, port, serversInstance); } }
private static void ExtractServers(Servers serversInstance, threads threadsInstance, byte[] data) { if (data == null) { return; } String datastr = Encoding.ASCII.GetString(data); var seps = new string[1]; seps[0] = "\\"; string[] ips = datastr.Split(seps, StringSplitOptions.RemoveEmptyEntries); foreach (var s in ips) { if (s.Length != 6) { continue; } String ip = ""; ip += ((int)s[0]).ToString(CultureInfo.InvariantCulture) + "."; ip += ((int)s[1]).ToString(CultureInfo.InvariantCulture) + "."; ip += ((int)s[2]).ToString(CultureInfo.InvariantCulture) + "."; ip += ((int)s[3]).ToString(CultureInfo.InvariantCulture); int port = (s[4]) * 256 + (s[5]); threadsInstance.addServerThread(ip, port, serversInstance); } }
private void view_Load(object sender, EventArgs e) { serverview.ListViewItemSorter = lvs; //turn off thread safety CheckForIllegalCrossThreadCalls = false; threadsInstance = new threads(this); Application.DoEvents(); //select the first item in the latency filter drop box latencydrop.SelectedIndex = 0; //make sure the current directory is the working directory resetDirectory(); //get config FormConfigRestore.LoadConfig(this, configlocation); //get previous info serversInstance.deserialise(serverlistfile); //get all the columns serverview.Columns.Clear(); foreach (var kvp in protocolInstance.getColumns()) { serverview.Columns.Add(kvp.Key, kvp.Value).Name = kvp.Key; } //apply the loaded filters to all the servers allServersToServerView(); Controller.ToolStripText(toolStripStatusLabel1, ref statusStrip1, "Ready"); Licensing.LicensingForm(this, menuStrip1, HelpString, OtherText); }
public static async Task ServersFromUrl(ToolStripLabel toolStripLabel, StatusStrip ss, Servers serversInstance, threads threadsInstance, ListView serverView, view baseView) { var sb = new getStringBox(); sb.label1.Text = "Enter URL to extract ip:ports from"; sb.ShowDialog(); String ret = sb.returnvalue; if (ret == "") { return; } ToolStripText(toolStripLabel, ref ss, "Extracting Web Page Text"); var page = await NetExtras.DownloadWebPage(ret); if (page == null) { MessageBox.Show("Not a valid webpage"); return; } threadsInstance.addServerCollectionThread(toolStripLabel, ref ss, page, serversInstance, threadsInstance); ToolStripText(toolStripLabel, ref ss, "Ready"); baseView.allServersToServerView(); }
public static void ServersFromFile(ToolStripLabel toolStripLabel, StatusStrip ss, Servers serversInstance, threads threadsInstance, ListView serverView, view baseView) { var ofd = new OpenFileDialog(); ofd.Title = "Select file to extract ip:ports from"; ofd.ShowDialog(); if (string.IsNullOrEmpty(ofd.FileName)) { return; } var fs = new FileStream(ofd.FileName, FileMode.Open); var sr = new StreamReader(fs); String file = sr.ReadToEnd(); sr.Close(); fs.Close(); threadsInstance.addServerCollectionThread(toolStripLabel, ref ss, file, serversInstance, threadsInstance); ToolStripText(toolStripLabel, ref ss, "Ready"); baseView.allServersToServerView(); }
public void addServerCollectionThread(ToolStripLabel toolStripLabel, ref StatusStrip SS, String file, Servers serversInstance, threads threadsInstance) { int maxthreads = 90; changeCurrThread(0, false); var r = new Regex(@"([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+)|([a-zA-Z][a-zA-Z0-9\-\.]+?:[0-9]+)"); MatchCollection mc; try { mc = r.Matches(file); } catch { Controller.ToolStripText(toolStripLabel, ref SS, "Ready"); return; } int count = 0; foreach (Match m in mc) { retry: if (killThreads) { break; } if (currthreads > maxthreads) { Thread.Sleep(100); goto retry; } Controller.ToolStripText(toolStripLabel, ref SS, "Verifying/Adding Server:" + count.ToString() + "/" + mc.Count); KeyValuePair <String, String> coll = Server.getIpPort(m.ToString()); changeCurrThread(1, true); var t = new Thread(() => addServerThread(coll.Key, int.Parse(coll.Value), serversInstance)); t.Start(); count++; } while (currthreads > 0) { Thread.Sleep(100); } }
public void addServerCollectionThread(ToolStripLabel toolStripLabel, ref StatusStrip SS, String file, Servers serversInstance, threads threadsInstance) { int maxthreads = 90; changeCurrThread(0, false); var r = new Regex(@"([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+)|([a-zA-Z][a-zA-Z0-9\-\.]+?:[0-9]+)"); MatchCollection mc; try { mc = r.Matches(file); } catch { Controller.ToolStripText(toolStripLabel, ref SS, "Ready"); return; } int count = 0; foreach (Match m in mc) { retry: if (killThreads) break; if (currthreads > maxthreads) { Thread.Sleep(100); goto retry; } Controller.ToolStripText(toolStripLabel, ref SS, "Verifying/Adding Server:" + count.ToString() + "/" + mc.Count); KeyValuePair<String, String> coll = Server.getIpPort(m.ToString()); changeCurrThread(1, true); var t = new Thread(() => addServerThread(coll.Key, int.Parse(coll.Value), serversInstance)); t.Start(); count++; } while (currthreads > 0) { Thread.Sleep(100); } }
public static void MasterServerAdd(ToolStripLabel toolStripLabel, StatusStrip SS, Servers serversInstance, threads threadsInstance) { //we need to increase the 15th byte to change the region byte[] gs = Protocol.Protocol.cod4getservers; for (int region = 0; region < 6; region++) { ToolStripText(toolStripLabel, ref SS, "Adding region:" + region + "/6"); byte[] rec = Networking.SendUDPPacketGetBlockingResponse( NetExtras.HostnameToIP(Protocol.Protocol.MasterServer), 20810, gs); gs[15]++; ExtractServers(serversInstance, threadsInstance, rec); } ToolStripText(toolStripLabel, ref SS, "Ready"); }
public static void MasterServerAdd(ToolStripLabel toolStripLabel, StatusStrip SS, Servers serversInstance, threads threadsInstance) { //we need to increase the 15th byte to change the region byte[] gs = Protocol.Protocol.cod4getservers; for (int region = 0; region < 6; region++) { ToolStripText(toolStripLabel, ref SS, "Adding region:" + region + "/6"); byte[] rec = Networking.SendUDPPacketGetBlockingResponse( NetExtras.HostnameToIP(Protocol.Protocol.MasterServer), 20810, gs); gs[15]++; ExtractServers(serversInstance, threadsInstance, rec); } ToolStripText(toolStripLabel, ref SS, "Ready"); }
public static async Task ServersFromUrl(ToolStripLabel toolStripLabel, StatusStrip ss, Servers serversInstance, threads threadsInstance, ListView serverView, view baseView) { var sb = new getStringBox(); sb.label1.Text = "Enter URL to extract ip:ports from"; sb.ShowDialog(); String ret = sb.returnvalue; if (ret == "") return; ToolStripText(toolStripLabel, ref ss, "Extracting Web Page Text"); var page = await NetExtras.DownloadWebPage(ret); if (page == null) { MessageBox.Show("Not a valid webpage"); return; } threadsInstance.addServerCollectionThread(toolStripLabel, ref ss, page, serversInstance, threadsInstance); ToolStripText(toolStripLabel, ref ss, "Ready"); baseView.allServersToServerView(); }
public static void ServersFromFile(ToolStripLabel toolStripLabel, StatusStrip ss, Servers serversInstance, threads threadsInstance, ListView serverView, view baseView) { var ofd = new OpenFileDialog(); ofd.Title = "Select file to extract ip:ports from"; ofd.ShowDialog(); if (string.IsNullOrEmpty(ofd.FileName)) return; var fs = new FileStream(ofd.FileName, FileMode.Open); var sr = new StreamReader(fs); String file = sr.ReadToEnd(); sr.Close(); fs.Close(); threadsInstance.addServerCollectionThread(toolStripLabel, ref ss, file, serversInstance, threadsInstance); ToolStripText(toolStripLabel, ref ss, "Ready"); baseView.allServersToServerView(); }
private void view_Load(object sender, EventArgs e) { serverview.ListViewItemSorter = lvs; //turn off thread safety CheckForIllegalCrossThreadCalls = false; threadsInstance = new threads(this); Application.DoEvents(); //select the first item in the latency filter drop box latencydrop.SelectedIndex = 0; //make sure the current directory is the working directory resetDirectory(); //get config FormConfigRestore.LoadConfig(this, configlocation); //get previous info serversInstance.deserialise(serverlistfile); //get all the columns serverview.Columns.Clear(); foreach (var kvp in protocolInstance.getColumns()) { serverview.Columns.Add(kvp.Key, kvp.Value).Name = kvp.Key; } //apply the loaded filters to all the servers allServersToServerView(); Controller.ToolStripText(toolStripStatusLabel1, ref statusStrip1, "Ready"); Licensing.CreateLicense(this, menuStrip1, new Licensing.SolutionDetails(GetDetails, HelpString, AppTitle, AppVersion, OtherText)); }