Untitled
plain_text
2 months ago
501 B
4
Indexable
Never
std::string func::GetIP() { std::string ipAddress = ""; CURL* curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://api.ipify.org"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, func::WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ipAddress); CURLcode res = curl_easy_perform(curl); if (res != CURLE_OK) { return "Failed to retrieve IP address: " + std::string(curl_easy_strerror(res)); } curl_easy_cleanup(curl); } return ipAddress; }