|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2014-2016 Markus Prasser
|
|
|
|
* Copyright 2014-2018 Markus Prasser, Tobias Weiss
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This file is part of Labcontrol.
|
|
|
|
* This file is part of Labcontrol.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -19,33 +19,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "netstatagent.h"
|
|
|
|
#include "netstatagent.h"
|
|
|
|
|
|
|
|
|
|
|
|
lc::NetstatAgent::NetstatAgent( const QString &argNetstatCommand, QObject *argParent ) :
|
|
|
|
lc::NetstatAgent::NetstatAgent(const QString &argNetstatCommand,
|
|
|
|
QObject{ argParent },
|
|
|
|
QObject *argParent) :
|
|
|
|
extractionRegexp{ "\\d+\\.\\d+\\.\\d+\\.\\d+" },
|
|
|
|
QObject{argParent},
|
|
|
|
netstatArguments{ QStringList{} << "-anp" << "--tcp" },
|
|
|
|
netstatCommand{argNetstatCommand}
|
|
|
|
netstatCommand{ argNetstatCommand },
|
|
|
|
|
|
|
|
netstatQueryProcess{ this },
|
|
|
|
|
|
|
|
searchRegexp{ "\\W(ESTABLISHED|VERBUNDEN)( +)(\\d+)(/ztree.exe)\\W", QRegularExpression::CaseInsensitiveOption }
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
|
|
|
netstatQueryProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
|
|
|
netstatQueryProcess.setProcessEnvironment( env );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lc::NetstatAgent::QueryClientConnections() {
|
|
|
|
void lc::NetstatAgent::QueryClientConnections()
|
|
|
|
netstatQueryProcess.start( netstatCommand, netstatArguments );
|
|
|
|
{
|
|
|
|
if ( !netstatQueryProcess.waitForFinished( 400 ) ) {
|
|
|
|
netstatQueryProcess.start(netstatCommand, netstatArguments);
|
|
|
|
emit QueryFinished( nullptr );
|
|
|
|
if (!netstatQueryProcess.waitForFinished(400)) {
|
|
|
|
|
|
|
|
emit QueryFinished(nullptr);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Get all 'netstat_query_process' standard output and store it temporarily in 'temp_strings'
|
|
|
|
// Get all 'netstat_query_process' standard output and store it temporarily in 'temp_strings'
|
|
|
|
QByteArray netstatQueryProcessOutputByteArray = netstatQueryProcess.readAllStandardOutput();
|
|
|
|
const QString netstatQueryProcessOutputString{netstatQueryProcess.readAllStandardOutput()};
|
|
|
|
QString netstatQueryProcessOutputString( netstatQueryProcessOutputByteArray );
|
|
|
|
const QStringList tempStrings{
|
|
|
|
QStringList tempStrings = netstatQueryProcessOutputString.split( '\n', QString::SkipEmptyParts );
|
|
|
|
netstatQueryProcessOutputString.split('\n', QString::SkipEmptyParts)};
|
|
|
|
|
|
|
|
|
|
|
|
QStringList *netstatQueryProcessOutput = new QStringList;
|
|
|
|
const auto netstatQueryProcessOutput = new QStringList;
|
|
|
|
for ( auto s: tempStrings ) {
|
|
|
|
for (const auto &s : tempStrings) {
|
|
|
|
if ( s.contains( searchRegexp ) ) {
|
|
|
|
if (s.contains(searchRegexp)) {
|
|
|
|
QRegularExpressionMatch match = extractionRegexp.match( s, s.indexOf( ':', 0, Qt::CaseInsensitive ) );
|
|
|
|
QRegularExpressionMatch match{extractionRegexp.match(s, s.indexOf(':', 0,
|
|
|
|
netstatQueryProcessOutput->append( match.captured() );
|
|
|
|
Qt::CaseInsensitive))};
|
|
|
|
|
|
|
|
netstatQueryProcessOutput->append(match.captured());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|