Commit c3dd3878 by “liusq”

修改命令为sudo

parent 559f56cf
...@@ -487,11 +487,13 @@ inline bool pingAddress(const QString &address) { ...@@ -487,11 +487,13 @@ inline bool pingAddress(const QString &address) {
QProcess process; QProcess process;
QString program = "ping"; QString program = "ping";
QStringList arguments; QStringList arguments;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// Windows下通常不需要sudo
arguments << "-n" << "1" << address; arguments << "-n" << "1" << address;
#else #else
arguments << "-c" << "1" << address; // 使用sudo
program = "sudo";
arguments << "ping" << "-c" << "1" << address;
#endif #endif
process.start(program, arguments); process.start(program, arguments);
...@@ -514,6 +516,8 @@ inline bool pingAddress(const QString &address) { ...@@ -514,6 +516,8 @@ inline bool pingAddress(const QString &address) {
return output.contains("1 packets transmitted, 1 received"); return output.contains("1 packets transmitted, 1 received");
#endif #endif
} }
inline QString findReachableIp() { inline QString findReachableIp() {
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
for (const QHostAddress &address : ipAddressesList) { 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