private void Change247() { thread247running = true; while (flagstop == false) { if (BitviseHandle.CheckConnect(IP, port)) { Thread.Sleep(5000); } else { threadconnect.Abort(); flagstop = false; threadconnect = new Thread(() => ChangeSSH()); threadconnect.IsBackground = true; threadconnect.Start(); Application.DoEvents(); break; } } }
private void ChangeSSH() { threadrunning = true; if (myform2.changebymanual) { if (thread247running) { thread247.Abort(); thread247running = false; } if (threadscheduledrunning) { threadscheduled.Abort(); threadscheduledrunning = false; } } else if (myform2.changeby247 && threadscheduledrunning) { threadscheduled.Abort(); threadscheduledrunning = false; } else if (myform2.changebyscheduled && thread247running) { thread247.Abort(); thread247running = false; } //if(hasimportsshlink == false && myform2.importsshfromfile == false) //{ // DownloadFile(myform2.linkssh, "SSH_DOWNLOAD.txt"); // LoadSSH("SSH_DOWNLOAD.txt"); //} if (cbChangetimezone.Checked || myform2.location) { if (File.Exists(Path.Combine(Application.StartupPath, "GeoLite2-City.mmdb")) == false) { DialogResult result = MessageBox.Show("File not fund: GeoLite2-City.mmdb\nDo you want to download this file now?", "ERROR File", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { this.Invoke((MethodInvoker) delegate() { lblSshinfo.Text = "Please wait for download database"; }); DownloadFile("http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz", "GeoLite2-City.mmdb.gz"); Ungzip("GeoLite2-City.mmdb.gz"); this.Invoke((MethodInvoker) delegate() { lblSshinfo.Text = "Download completed! Start change ssh"; }); } else { ptbChange.Enabled = true; return; } } } Showstatus("Connecting"); //port = Convert.ToInt32(nmrPort.Value); TimeoutSeconds = Convert.ToInt32(nmrTimeout.Value); try { BitviseHandle.Disconnect(port); } catch { // } string[] _listport = CTLConfig._port.Split(';'); KillALL(); foreach (string strport in _listport) { port = Convert.ToInt32(strport); while (flagstop == false) { ssh = GetSsh(); if (ssh == "") { if (myform2.loopssh) { loop++; //if (myform2.importsshfromfile) //{ // LoadSSH(importsshbyfilepath); //} //else //{ // DownloadFile(myform2.linkssh, "SSH_DOWNLOAD.txt"); // LoadSSH("SSH_DOWNLOAD.txt"); //} } else { Showstatus("Disconnected"); MessageBox.Show("SSH Out Of Stock"); break; } } IP = Regex.Split(ssh, "\\|")[0]; User = Regex.Split(ssh, "\\|")[1]; Pass = Regex.Split(ssh, "\\|")[2]; Thread.Sleep(50); if (BitviseHandle.Connect(IP, User, Pass, port, TimeoutSeconds, myform2.hidebvs)) { Showstatus("Connected"); sshlive++; this.Invoke((MethodInvoker) delegate() { lblLive.Text = sshlive.ToString(); }); if (myform2.location) { GetSSHinfo(IP); } if (myform2.whoershowinfo) { if (Whoer(port) == "BAD") { try { BitviseHandle.Disconnect(port); } catch { // } continue; } } if (myform2.autosave) { AutoSaveSSH(); } break; } else { sshdie++; this.Invoke((MethodInvoker) delegate() { lblDie.Text = sshdie.ToString(); }); Thread.Sleep(50); } } } threadrunning = false; if (myform2.changeby247) { thread247 = new Thread(() => Change247()); thread247.IsBackground = true; thread247.Start(); Application.DoEvents(); } else if (myform2.changebyscheduled) { threadscheduled = new Thread(() => ChangeScheduled(Convert.ToInt32(myform2.scheduleddelay) * 60000)); threadscheduled.IsBackground = true; threadscheduled.Start(); Application.DoEvents(); } }