34 lines
735 B
C++
34 lines
735 B
C++
#include <iostream>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include "version.hpp"
|
|
#include "assert.hpp"
|
|
#include "http_utils.hpp"
|
|
|
|
void crashy() {
|
|
ASSERT(false, "SUCCESS!");
|
|
}
|
|
|
|
int main() {
|
|
std::cout << "ipdemo version: " << ipdemo::VERSION << std::endl;
|
|
std::cout << std::endl;
|
|
std::cout << "Retrieving IP address..." << std::endl;
|
|
|
|
// Use the utility function for HTTP GET
|
|
auto response = http_get("ipinfo.io", "/ip", true, 10.0);
|
|
|
|
ASSERT(response.success && response.status_code == 200, "Failed to get IP");
|
|
|
|
nlohmann::json j;
|
|
j["ip"] = response.body;
|
|
j["status"] = response.status_code;
|
|
|
|
std::cout << j.dump(4) << std::endl;
|
|
|
|
std::cout << "Done" << std::endl;
|
|
|
|
crashy();
|
|
|
|
return 0;
|
|
}
|