+30
-6
@@ -36,11 +36,22 @@ trytry::trytry()
|
||||
|
||||
void trytry::run()
|
||||
{
|
||||
emit try_one(1);
|
||||
QString temp = QString("%1:%2").arg(ipstr).arg(ipint);
|
||||
|
||||
QTcpSocket m_socket;
|
||||
m_socket.connectToHost(ipstr, ipint, QTcpSocket::ReadWrite);
|
||||
if (m_socket.waitForConnected(timeout))
|
||||
{
|
||||
emit connect_ok(temp);
|
||||
}
|
||||
m_socket.disconnectFromHost();
|
||||
m_socket.disconnect();
|
||||
m_socket.deleteLater();
|
||||
|
||||
qDebug()<<this->ipstr<<":"<<this->ipint;
|
||||
sleep(1);
|
||||
qDebug()<<temp;
|
||||
|
||||
emit try_one(-1);
|
||||
|
||||
}
|
||||
|
||||
@@ -202,14 +213,21 @@ void dispatch::run()
|
||||
|
||||
qDebug()<<"now:"<<this->now_thread_num<<" - set:"<<this->set_thread_num;
|
||||
|
||||
while(this->now_thread_num>this->set_thread_num);
|
||||
|
||||
connecttry=new trytry;
|
||||
connecttry->timeout=this->timeout;
|
||||
connecttry->ipstr=str_ips_list.at(ii);
|
||||
connecttry->ipint=ports_list.at(iii);
|
||||
this->now_thread_num+=1;
|
||||
//connect(connecttry,&trytry::started,[=]{this->now_thread_num+=1;});
|
||||
connect(connecttry,&trytry::finished,[=]{this->now_thread_num-=1;});
|
||||
|
||||
|
||||
connect(connecttry,&trytry::try_one,this,&dispatch::f_one);
|
||||
connect(connecttry,&trytry::connect_ok,[=](QString temp){emit connect_ok(temp);});
|
||||
|
||||
connect(connecttry,&trytry::finished,[=]{
|
||||
connecttry->disconnect();
|
||||
connecttry->quit();
|
||||
connecttry->wait();
|
||||
});
|
||||
|
||||
connecttry->start();
|
||||
|
||||
@@ -224,6 +242,8 @@ void dispatch::run()
|
||||
|
||||
now_scan+=1;
|
||||
|
||||
while(this->now_thread_num>this->set_thread_num);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -235,4 +255,8 @@ void dispatch::run()
|
||||
emit dispatch_finish();
|
||||
}
|
||||
|
||||
void dispatch::f_one(qint16 temp)
|
||||
{
|
||||
this->now_thread_num+=temp;
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ public:
|
||||
QString ipstr;
|
||||
quint32 ipint;
|
||||
void run();
|
||||
|
||||
signals:
|
||||
void try_one(qint16);
|
||||
void connect_ok(QString);
|
||||
|
||||
};
|
||||
|
||||
@@ -33,8 +35,8 @@ public:
|
||||
|
||||
dispatch();
|
||||
|
||||
quint16 set_thread_num;
|
||||
quint16 now_thread_num;
|
||||
qint16 set_thread_num;
|
||||
qint16 now_thread_num;
|
||||
quint16 thread_start_lock=0;
|
||||
quint16 timeout;
|
||||
|
||||
@@ -45,11 +47,12 @@ public:
|
||||
|
||||
|
||||
void run();
|
||||
|
||||
void f_one(qint16 temp);
|
||||
signals:
|
||||
void dispatch_finish();
|
||||
void dispatch_one();
|
||||
void return_jindu(quint16);
|
||||
void connect_ok(QString);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
|
||||
|
||||
|
||||
void Widget::output_chuli(QString temp)
|
||||
{
|
||||
ui->outputlist->append(temp);
|
||||
}
|
||||
|
||||
|
||||
void Widget::jindu_chuli(quint16 temp)
|
||||
@@ -40,8 +43,8 @@ Widget::Widget(QWidget *parent)
|
||||
connect(dispatch_thread,&dispatch::dispatch_finish,[=]{
|
||||
emit stop_scan();
|
||||
});
|
||||
connect(dispatch_thread,&dispatch::return_jindu,this,&Widget::jindu_chuli);
|
||||
|
||||
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();
|
||||
ui->stard_scan->setDisabled(false);
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
quint64 t_bar=0;
|
||||
quint64 nt_bar=0;
|
||||
|
||||
void output_chuli(QString temp);
|
||||
void jindu_chuli(quint16 temp);
|
||||
signals:
|
||||
void stop_scan();
|
||||
|
||||
Reference in New Issue
Block a user