Commit 8d8d9b7e by 郭峰

Merge branch 'feature-1007488' into 'release'

Feature 1007488

See merge request !36
parents 6654fa06 c3dd3878
......@@ -453,7 +453,7 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
// 获取网关地址
QProcess process;
process.start("ip", QStringList() << "route");
process.start("sudo", QStringList() << "/sbin/ip" << "route");
if (!process.waitForStarted()) {
qInfo() << "Failed to start 'ip route' process.";
continue;
......@@ -487,11 +487,13 @@ inline bool pingAddress(const QString &address) {
QProcess process;
QString program = "ping";
QStringList arguments;
#ifdef Q_OS_WIN
// Windows下通常不需要sudo
arguments << "-n" << "1" << address;
#else
arguments << "-c" << "1" << address;
// 使用sudo
program = "sudo";
arguments << "ping" << "-c" << "1" << address;
#endif
process.start(program, arguments);
......@@ -514,6 +516,8 @@ inline bool pingAddress(const QString &address) {
return output.contains("1 packets transmitted, 1 received");
#endif
}
inline QString findReachableIp() {
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
for (const QHostAddress &address : ipAddressesList) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment