summaryrefslogtreecommitdiffstats
path: root/LogReceiver/logreceiver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LogReceiver/logreceiver.cpp')
-rw-r--r--LogReceiver/logreceiver.cpp57
1 files changed, 56 insertions, 1 deletions
diff --git a/LogReceiver/logreceiver.cpp b/LogReceiver/logreceiver.cpp
index 802f442..1256bfe 100644
--- a/LogReceiver/logreceiver.cpp
+++ b/LogReceiver/logreceiver.cpp
@@ -222,6 +222,60 @@ void LogReceiver::checkInternetConnection(QList<QString> &interfaces) {
checkInternetConnection(nI);
}
}
+
+void LogReceiver::checkConnectivity(QString ifName) {
+ QString command("route");
+ QStringList argList;
+ QString gateway(" ");
+
+ // get gateway address
+ QString pathToGatewayFile(DEFAULT_GATEWAY_INFO_LOCATION);
+ pathToGatewayFile += ifName;
+ QFile file(pathToGatewayFile);
+ if(file.exists()) {
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ qDebug() << "couldnt open file:" << pathToGatewayFile;
+ return;
+ }
+ while(!file.atEnd()) {
+ QString line(file.readLine());
+ QStringList gateways = line.split(",");
+ gateway = gateways.first().trimmed();
+ }
+ }
+ else {
+ qDebug() << "file doesn't exist:" << pathToGatewayFile;
+ return;
+ }
+
+ // delete default route
+ argList << "del" << "default";
+ QProcess * p = new QProcess(this);
+ p->start(command, argList);
+ p->waitForFinished();
+
+ // add new default route
+ argList.clear();
+ argList << "add" << "default" << "gw" << gateway << ifName;
+ p = new QProcess(this);
+ p->start(command, argList);
+ p->waitForFinished();
+
+ // check connectivity via tcp connection
+ QTcpSocket *tcpSocket = new QTcpSocket(this);
+ tcpSocket->connectToHost(QString("209.85.148.105"), 80);
+ if (!tcpSocket->waitForConnected(2000)) {
+ qDebug() << "no internet connection with interface" << ifName;
+ qDebug() << tcpSocket->errorString();
+ emit updateStatusLabel(ifName, "connection not possible");
+ } else {
+ qDebug() << "internet: check passed! for interface" << ifName;
+ emit
+ updateStatusLabel(ifName, "connection possible");
+ emit connectionEstablished(ifName);
+ }
+}
+
void LogReceiver::checkInternetConnectionViaTCP(QString ifName) {
const bool canStartIAP = (configurationManager.capabilities()
@@ -418,7 +472,8 @@ void LogReceiver::handleProcessFinished(int exitCode,
emit
updateStatusLabel(ifName, "check connectivity");
//checkInternetConnection(ifName);
- checkInternetConnectionViaTCP(ifName);
+ //checkInternetConnectionViaTCP(ifName);
+ checkConnectivity(ifName);
}
}
QLocalSocket *client = ifNameToClient.value(ifName, 0);