@@ -1664,40 +1664,41 @@ void KeyAuth::api::setDebug(bool value) {
1664
1664
KeyAuth::api::debug = value;
1665
1665
}
1666
1666
1667
- std::string KeyAuth::api::req (std::string data, std::string url) {
1667
+ std::string KeyAuth::api::req (const std::string& data, const std::string& url) {
1668
+
1668
1669
CURL* curl = curl_easy_init ();
1669
- if (!curl)
1670
- return XorStr (" null" );
1670
+ if (!curl) {
1671
+ error (XorStr (" CURL Initialization Failed!" ));
1672
+ }
1671
1673
1672
1674
std::string to_return;
1673
1675
std::string headers;
1674
1676
1677
+ // Set CURL options
1675
1678
curl_easy_setopt (curl, CURLOPT_URL, url.c_str ());
1676
-
1677
- curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 1 );
1678
-
1679
- curl_easy_setopt (curl, CURLOPT_NOPROXY, XorStr ( " keyauth.win" ) );
1680
-
1679
+ curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2L );
1681
1680
curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1L );
1682
1681
curl_easy_setopt (curl, CURLOPT_CERTINFO, 1L );
1683
-
1682
+ curl_easy_setopt (curl, CURLOPT_NOPROXY, XorStr ( " keyauth.win " ). c_str ());
1684
1683
curl_easy_setopt (curl, CURLOPT_POSTFIELDS, data.c_str ());
1685
-
1686
1684
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_callback);
1687
1685
curl_easy_setopt (curl, CURLOPT_WRITEDATA, &to_return);
1688
-
1689
1686
curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, header_callback);
1690
1687
curl_easy_setopt (curl, CURLOPT_HEADERDATA, &headers);
1691
1688
1692
- auto code = curl_easy_perform (curl);
1693
-
1694
- if (code != CURLE_OK)
1695
- error (curl_easy_strerror (code));
1689
+ // Perform the request
1690
+ CURLcode code = curl_easy_perform (curl);
1691
+ if (code != CURLE_OK) {
1692
+ std::string errorMsg = " CURL Error: " + std::string (curl_easy_strerror (code));
1693
+ curl_easy_cleanup (curl);
1694
+ error (errorMsg);
1695
+ }
1696
1696
1697
1697
debugInfo (data, url, to_return, " Sig: " + signature + " \n Timestamp:" + signatureTimestamp);
1698
-
1698
+ curl_easy_cleanup (curl);
1699
1699
return to_return;
1700
1700
}
1701
+
1701
1702
void error (std::string message) {
1702
1703
system ((XorStr (" start cmd /C \" color b && title Error && echo " ).c_str () + message + XorStr (" && timeout /t 5\" " )).c_str ());
1703
1704
LI_FN (__fastfail)(0 );
0 commit comments