+64
-8
@@ -26,6 +26,38 @@ quint32 ipv4str_to_int(const QString& ipstr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trytryping::trytryping()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void trytryping::run()
|
||||||
|
{
|
||||||
|
emit try_one(1);
|
||||||
|
qint16 exitCode;
|
||||||
|
QString ip=this->ipstr;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QString strArg = "ping " + ip + " -n 1 -i 2";
|
||||||
|
exitCode = QProcess::execute(strArg);
|
||||||
|
#else
|
||||||
|
//其他平台(Linux或Mac)
|
||||||
|
exitCode = QProcess::execute("ping", QStringList() << "-c 1" << "-t 2" << ip));
|
||||||
|
#endif
|
||||||
|
if(0 == exitCode)
|
||||||
|
{
|
||||||
|
//it's alive
|
||||||
|
qDebug() << "shell ping " + ip + " sucessed!";
|
||||||
|
emit connect_ok(this->ipstr);
|
||||||
|
//发射该IP在线的信号
|
||||||
|
|
||||||
|
} else {
|
||||||
|
qDebug() << "shell ping " + ip + " failed!";
|
||||||
|
//发射IP离线的信号
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
emit try_one(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
trytry::trytry()
|
trytry::trytry()
|
||||||
@@ -156,8 +188,36 @@ void dispatch::run()
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
quint16 jindu=0,jindu_old=0;
|
||||||
|
|
||||||
|
if(pingonly)
|
||||||
|
{
|
||||||
|
for(quint64 ii=0;ii<ips_num;ii++)
|
||||||
|
{
|
||||||
|
trytry_ping=new trytryping;
|
||||||
|
trytry_ping->timeout=this->timeout;
|
||||||
|
trytry_ping->ipstr=str_ips_list.at(ii);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
connect(trytry_ping,&trytryping::try_one,this,&dispatch::f_one);
|
||||||
|
connect(trytry_ping,&trytryping::connect_ok,[=](QString temp){emit connect_ok(temp);});
|
||||||
|
trytry_ping->start();
|
||||||
|
|
||||||
|
jindu=(quint16)(((qfloat16)(ii)/(qfloat16)(ips_num))*100);
|
||||||
|
if(jindu!=jindu_old)
|
||||||
|
{
|
||||||
|
jindu_old=jindu;
|
||||||
|
//qDebug() <<jindu;
|
||||||
|
|
||||||
|
emit return_jindu(jindu);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while(this->now_thread_num>this->set_thread_num);
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
{
|
||||||
QRegExp ex_port ("^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$");
|
QRegExp ex_port ("^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$");
|
||||||
QRegExp ex_porttoport("^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])-(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$");
|
QRegExp ex_porttoport("^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])-(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$");
|
||||||
//QRegExp ex_portmore ("^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]);$");
|
//QRegExp ex_portmore ("^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]);$");
|
||||||
@@ -211,7 +271,7 @@ void dispatch::run()
|
|||||||
qDebug() << "IP: "<<ips_num;
|
qDebug() << "IP: "<<ips_num;
|
||||||
qDebug() << "port :"<<ports_num;
|
qDebug() << "port :"<<ports_num;
|
||||||
qDebug() << "scan times :"<<scantimes;
|
qDebug() << "scan times :"<<scantimes;
|
||||||
quint16 jindu=0,jindu_old=0;
|
|
||||||
for(quint64 ii=0;ii<ips_num;ii++)
|
for(quint64 ii=0;ii<ips_num;ii++)
|
||||||
{
|
{
|
||||||
for(quint64 iii=0;iii<ports_num;iii++)
|
for(quint64 iii=0;iii<ports_num;iii++)
|
||||||
@@ -230,13 +290,6 @@ void dispatch::run()
|
|||||||
|
|
||||||
connect(connecttry,&trytry::try_one,this,&dispatch::f_one);
|
connect(connecttry,&trytry::try_one,this,&dispatch::f_one);
|
||||||
connect(connecttry,&trytry::connect_ok,[=](QString temp){emit connect_ok(temp);});
|
connect(connecttry,&trytry::connect_ok,[=](QString temp){emit connect_ok(temp);});
|
||||||
/*
|
|
||||||
connect(connecttry,&trytry::finished,[=]{
|
|
||||||
connecttry->disconnect();
|
|
||||||
connecttry->quit();
|
|
||||||
connecttry->wait();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
connecttry->start();
|
connecttry->start();
|
||||||
|
|
||||||
jindu=(quint16)(((qfloat16)(now_scan)/(qfloat16)(scantimes))*100);
|
jindu=(quint16)(((qfloat16)(now_scan)/(qfloat16)(scantimes))*100);
|
||||||
@@ -256,6 +309,9 @@ void dispatch::run()
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+18
-1
@@ -11,6 +11,22 @@
|
|||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
#include <QFloat16>
|
#include <QFloat16>
|
||||||
|
#include <QtCore/QProcess>
|
||||||
|
class trytryping : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
trytryping();
|
||||||
|
|
||||||
|
quint16 timeout;
|
||||||
|
QString ipstr;
|
||||||
|
|
||||||
|
void run();
|
||||||
|
signals:
|
||||||
|
void try_one(qint16);
|
||||||
|
void connect_ok(QString);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class trytry : public QThread
|
class trytry : public QThread
|
||||||
{
|
{
|
||||||
@@ -44,8 +60,9 @@ public:
|
|||||||
QString port_list;
|
QString port_list;
|
||||||
|
|
||||||
trytry *connecttry;
|
trytry *connecttry;
|
||||||
|
trytryping *trytry_ping;
|
||||||
|
|
||||||
|
bool pingonly=false;
|
||||||
void run();
|
void run();
|
||||||
void f_one(qint16 temp);
|
void f_one(qint16 temp);
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
+51
-26
@@ -78,59 +78,84 @@ Widget::Widget(QWidget *parent)
|
|||||||
ui->outputlist->setReadOnly(true);
|
ui->outputlist->setReadOnly(true);
|
||||||
ui->stard_scan->setText("start scan");
|
ui->stard_scan->setText("start scan");
|
||||||
|
|
||||||
connect(this,&Widget::start_scan,[=]{
|
|
||||||
|
|
||||||
|
connect(ui->pushButton_20, &QPushButton::pressed, [=]()
|
||||||
|
{
|
||||||
|
if(scan_flag==0)
|
||||||
|
{
|
||||||
scan_flag=1;
|
scan_flag=1;
|
||||||
keyboard_en(true);
|
keyboard_en(true);
|
||||||
|
ui->stard_scan->setDisabled(true);
|
||||||
ui->stard_scan->setText("stop scan");
|
ui->pushButton_20->setText("Stop Ping");
|
||||||
dispatch_thread = new dispatch;//线程分发
|
dispatch_thread = new dispatch;//线程分发
|
||||||
|
dispatch_thread->pingonly=true;
|
||||||
dispatch_thread->ip_list=ui->IP_list->toPlainText();
|
dispatch_thread->ip_list=ui->IP_list->toPlainText();
|
||||||
dispatch_thread->port_list=ui->port_list->toPlainText();
|
dispatch_thread->port_list=ui->port_list->toPlainText();
|
||||||
dispatch_thread->set_thread_num = ui->threads->value();
|
dispatch_thread->set_thread_num = ui->threads->value();
|
||||||
dispatch_thread->now_thread_num = 0;
|
dispatch_thread->now_thread_num = 0;
|
||||||
dispatch_thread->timeout = ui->timeout->value();
|
dispatch_thread->timeout = ui->timeout->value();
|
||||||
connect(dispatch_thread,&dispatch::dispatch_finish,[=]{
|
connect(dispatch_thread,&dispatch::dispatch_finish,[=]{
|
||||||
emit stop_scan();
|
scan_flag=0;
|
||||||
|
keyboard_en(false);
|
||||||
|
ui->stard_scan->setDisabled(false);
|
||||||
|
ui->pushButton_20->setText("Ping Olny");
|
||||||
|
dispatch_thread->quit();
|
||||||
|
//dispatch_thread->wait();
|
||||||
});
|
});
|
||||||
connect(dispatch_thread,&dispatch::return_jindu,this,&Widget::jindu_chuli,Qt::QueuedConnection);
|
connect(dispatch_thread,&dispatch::return_jindu,this,&Widget::jindu_chuli,Qt::QueuedConnection);
|
||||||
connect(dispatch_thread,&dispatch::connect_ok,this,&Widget::output_chuli,Qt::QueuedConnection);
|
connect(dispatch_thread,&dispatch::connect_ok,this,&Widget::output_chuli,Qt::QueuedConnection);
|
||||||
ui->progressBar->setValue(0);
|
ui->progressBar->setValue(0);
|
||||||
dispatch_thread->start();
|
dispatch_thread->start();
|
||||||
ui->stard_scan->setDisabled(false);
|
}else
|
||||||
});
|
{
|
||||||
|
|
||||||
connect(this,&Widget::stop_scan,[=]{
|
|
||||||
scan_flag=0;
|
scan_flag=0;
|
||||||
keyboard_en(false);
|
keyboard_en(false);
|
||||||
|
|
||||||
ui->stard_scan->setText("start scan");
|
|
||||||
|
|
||||||
//dispatch_thread->disconnect();
|
|
||||||
dispatch_thread->quit();
|
|
||||||
dispatch_thread->wait();
|
|
||||||
//delete dispatch_thread;
|
|
||||||
ui->stard_scan->setDisabled(false);
|
ui->stard_scan->setDisabled(false);
|
||||||
qDebug() << "tray_exit";
|
ui->pushButton_20->setText("Ping Olny");
|
||||||
|
dispatch_thread->terminate();
|
||||||
});
|
dispatch_thread->quit();
|
||||||
|
//dispatch_thread->wait();
|
||||||
connect(ui->pushButton_20, &QPushButton::pressed, [=]()
|
}
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->stard_scan, &QPushButton::pressed, [=]()
|
connect(ui->stard_scan, &QPushButton::pressed, [=]()
|
||||||
{
|
{
|
||||||
ui->stard_scan->setDisabled(true);
|
|
||||||
if(scan_flag==0)
|
if(scan_flag==0)
|
||||||
{
|
{
|
||||||
emit start_scan();
|
scan_flag=1;
|
||||||
|
keyboard_en(true);
|
||||||
|
ui->pushButton_20->setDisabled(true);
|
||||||
|
ui->stard_scan->setText("stop scan");
|
||||||
|
dispatch_thread = new dispatch;//线程分发
|
||||||
|
dispatch_thread->pingonly=false;
|
||||||
|
dispatch_thread->ip_list=ui->IP_list->toPlainText();
|
||||||
|
dispatch_thread->port_list=ui->port_list->toPlainText();
|
||||||
|
dispatch_thread->set_thread_num = ui->threads->value();
|
||||||
|
dispatch_thread->now_thread_num = 0;
|
||||||
|
dispatch_thread->timeout = ui->timeout->value();
|
||||||
|
connect(dispatch_thread,&dispatch::dispatch_finish,[=]{
|
||||||
|
scan_flag=0;
|
||||||
|
keyboard_en(false);
|
||||||
|
ui->pushButton_20->setDisabled(false);
|
||||||
|
ui->stard_scan->setText("start scan");
|
||||||
|
dispatch_thread->quit();
|
||||||
|
//dispatch_thread->wait();
|
||||||
|
});
|
||||||
|
connect(dispatch_thread,&dispatch::return_jindu,this,&Widget::jindu_chuli,Qt::QueuedConnection);
|
||||||
|
connect(dispatch_thread,&dispatch::connect_ok,this,&Widget::output_chuli,Qt::QueuedConnection);
|
||||||
|
ui->progressBar->setValue(0);
|
||||||
|
dispatch_thread->start();
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
scan_flag=0;
|
||||||
|
keyboard_en(false);
|
||||||
|
ui->pushButton_20->setDisabled(false);
|
||||||
|
ui->stard_scan->setText("start scan");
|
||||||
dispatch_thread->terminate();
|
dispatch_thread->terminate();
|
||||||
emit stop_scan();
|
dispatch_thread->quit();
|
||||||
|
//dispatch_thread->wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
});//'scan button pass'
|
});//'scan button pass'
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
<number>999</number>
|
<number>999</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>100</number>
|
<number>80</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
|
|||||||
Reference in New Issue
Block a user