SendSystemInfo: Use GET instead of ping to check internet connection

This commit is contained in:
Lukas Matena 2021-10-12 15:34:18 +02:00
parent 692a0dade7
commit 1afa18d719
3 changed files with 12 additions and 16 deletions

View File

@ -6,6 +6,7 @@
#include "slic3r/GUI/format.hpp" #include "slic3r/GUI/format.hpp"
#include "slic3r/Utils/Http.hpp" #include "slic3r/Utils/Http.hpp"
#include "slic3r/Utils/PresetUpdater.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "GUI_Utils.hpp" #include "GUI_Utils.hpp"
@ -151,18 +152,15 @@ static bool should_dialog_be_shown()
if (! new_version) if (! new_version)
return false; return false;
std::cout << "Sending system info was not confirmed/declined in this version yet.\n" // We'll misuse the version check to check internet connection here.
"Pinging prusa3d.com to see if it can be offered now." << std::endl; bool is_internet = false;
bool is_internet = Http::get(wxGetApp().app_config->version_check_url())
#ifdef _WIN32 .size_limit(SLIC3R_VERSION_BODY_MAX)
std::system((std::string("ping /n 1 /w 1 ") + SEND_SYSTEM_INFO_DOMAIN).data()) == 0; // 1 packet, 1 sec timeout .timeout_max(2)
#elif __APPLE__ .on_complete([&](std::string, unsigned) {
std::system((std::string("ping -c 1 -q -t 1 ") + SEND_SYSTEM_INFO_DOMAIN).data()) == 0; // 1 packet, quiet output, 1 sec timeout is_internet = true;
#else // Linux/BSD })
std::system((std::string("ping -c 1 -q -w 1 ") + SEND_SYSTEM_INFO_DOMAIN).data()) == 0; // 1 packet, quiet output, 1 sec timeout .perform_sync();
#endif
std::cout << "Pinging prusa3d.com was " << (is_internet ? "" : "NOT ") << "successful." << std::endl;
return is_internet; return is_internet;
} }

View File

@ -46,10 +46,6 @@ using Slic3r::GUI::Config::SnapshotDB;
namespace Slic3r { namespace Slic3r {
enum {
SLIC3R_VERSION_BODY_MAX = 256,
};
static const char *INDEX_FILENAME = "index.idx"; static const char *INDEX_FILENAME = "index.idx";
static const char *TMP_EXTENSION = ".download"; static const char *TMP_EXTENSION = ".download";

View File

@ -13,6 +13,8 @@ class AppConfig;
class PresetBundle; class PresetBundle;
class Semver; class Semver;
const int SLIC3R_VERSION_BODY_MAX = 256;
class PresetUpdater class PresetUpdater
{ {
public: public: