10 using namespace swift::config;
12 namespace swift::misc::network
14 bool canPing(
const QString &hostAddress)
16 if (hostAddress.isEmpty()) {
return false; }
18 process.setProgram(
"ping");
23 process.setArguments({
"-c",
"1", hostAddress });
26 process.waitForFinished();
27 const int rc = process.exitCode();
28 if (rc != 0) {
return false; }
30 const QString std = process.readAllStandardOutput();
31 const QString err = process.readAllStandardError();
32 if (std.contains(
"unreachable", Qt::CaseInsensitive)) {
return false; }
33 if (err.contains(
"unreachable", Qt::CaseInsensitive)) {
return false; }
37 bool canPing(
const QUrl &url)
39 if (url.isEmpty()) {
return false; }
40 return canPing(url.host());
static constexpr bool isRunningOnWindowsNtPlatform()
Running on Windows NT platform?