forked from omniedgeio/omniedge-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tapmanager.cpp
42 lines (36 loc) · 1.31 KB
/
tapmanager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "tapmanager.h"
#include <QSysInfo>
#include <QFileInfo>
#include <QDebug>
#include <QDir>
#include <QProcess>
#include <QNetworkInterface>
#include <QOperatingSystemVersion>
TapManager::TapManager(QObject *parent) : QObject(parent)
{
QNetworkInterface interface;
QStringList interfaceList;
QList<QNetworkInterface> IpList = interface.allInterfaces();
for (int i = 0; i < IpList.size(); i++)
interfaceList.append(IpList.at(i).humanReadableName());
QFileInfo check_file(QDir::currentPath() + "\\tap-windows\\add_tap_device.bat");
if (check_file.exists() && check_file.isFile()) {
qDebug() << "TapManager: " << QDir::currentPath() + "\\tap-windows\\add_tap_device.bat" << " exists.";
if(!interfaceList.contains("OmniEdge",Qt::CaseSensitive))
{
QProcess process;
process.start(QDir::currentPath() + "\\tap-windows\\add_tap_device.bat");
process.waitForFinished();
}
else
qDebug() << "OmniEdge tap device exist";
} else {
qDebug() << "TapManager: " << QDir::currentPath() + "\\tap-windows\\add_tap_device.bat" << " not exists.";
}
}
void TapManager::addTap()
{
QProcess process;
process.start(QDir::currentPath() + "\\tap-windows\\add_tap_device.bat");
process.waitForFinished();
}