@@ -38,14 +38,15 @@ v 4.1.0.1 2020-01-26 Zealot Data compressing using gzip from zlib
3838v 4.1.0.2 2020-01-26 Zealot Filename is stripped from russion symbols and send to webservice, compress is mandatory
3939v 4.1.0.3 2020-01-26 Zealot gz is not include in filename
4040v 4.1.0.4 2020-01-26 Zealot small fixes and optimizations
41+ v 4.1.1.0 2020-01-26 Zealot Actually working )
4142
4243TODO:
4344- чтение запись настроек
4445
4546
4647*/
4748
48- #define CURRENT_VERSION " 4.1.0.4 "
49+ #define CURRENT_VERSION " 4.1.1.0 "
4950
5051#pragma endregion
5152
@@ -176,13 +177,12 @@ namespace {
176177 struct {
177178 std::string dbInsertUrl = " http://ocap.red-bear.ru/data/receive.php?option=dbInsert" ;
178179 std::string addFileUrl = " http://ocap.red-bear.ru/data/receive.php?option=addFile" ;
179- std::string newUrl = " 127.0.0.1:5000 /api/v1/operations/add" ;
180+ std::string newUrl = " https://ocap.red-bear.ru /api/v1/operations/add" ;
180181 std::string newServerGameType = " tvt" ;
181182 std::string newUrlRequestSecret = " pwd1234" ;
182183 int newMode = 0 ;
183184 int httpRequestTimeout = 120 ;
184185 int traceLog = 0 ;
185- // int compress = 0;
186186 } config;
187187}
188188
@@ -398,7 +398,7 @@ pair<string, string> saveCurrentReplayToTempFile() {
398398 LOG (INFO) << " Replay saved:" << tName;
399399 string archive_name;
400400
401- if (true /* config.compress */ ) {
401+ if (true ) {
402402 archive_name = string (tName) + " .gz" ;
403403 if (write_compressed_data (archive_name.c_str (), all_replay.c_str (), all_replay.size ())) {
404404 LOG (INFO) << " Archive saved:" << archive_name;
@@ -446,7 +446,6 @@ void readWriteConfig(HMODULE hModule) {
446446 { " newUrl" , config.newUrl },
447447 { " newServerGameType" , config.newServerGameType },
448448 { " newUrlRequestSecret" , config.newUrlRequestSecret }
449- // { "compress", config.compress}
450449 };
451450 std::ofstream out (path_sample, ofstream::out | ofstream::binary);
452451 out << j.dump (4 ) << endl;
@@ -524,14 +523,6 @@ void readWriteConfig(HMODULE hModule) {
524523 else {
525524 LOG (WARNING) << " newUrlRequestSecret should be string!" ;
526525 }
527- /*
528- if (!jcfg["compress"].is_null() && jcfg["compress"].is_number_integer()) {
529- config.compress = jcfg["compress"].get<int>();
530- LOG(TRACE) << "Read compress=" << config.newMode;
531- }
532- else {
533- LOG(WARNING) << "compress should be integer!";
534- }*/
535526
536527 if (config.traceLog ) {
537528 el::Configurations defaultConf (*el::Loggers::getLogger (" default" )->configurations ());
@@ -573,22 +564,40 @@ void curlDbInsert(string b_url, string worldname, string missionName, string mis
573564 }
574565}
575566
567+
568+ void log_curl_exe_string (const string& b_url, const string& worldname, const string& missionName,
569+ const string& missionDuration, const string& filename, const pair<string, string>& pair_files,
570+ int timeout, const string& gametype, const string& secret) {
571+ stringstream ss;
572+ ss << " curl " ;
573+ ss << " -F file=\" @" << pair_files.second << " \" " ;
574+ ss << " -F filename=\" " << filename << " \" " ;
575+ ss << " -F worldName=\" " << worldname << " \" " ;
576+ ss << " -F missionName=\" " << missionName << " \" " ;
577+ ss << " -F missionDuration=\" " << missionDuration << " \" " ;
578+ ss << " -F type=\" " << gametype << " \" " ;
579+ ss << b_url;
580+ LOG (INFO) << " String for reupload: " ;
581+ LOG (INFO) << ss.str ();
582+ }
583+
576584void curlUploadNew (const string &b_url, const string &worldname,const string &missionName, const string &missionDuration, const string &filename, const pair<string,string> &pair_files, int timeout,const string &gametype, const string &secret) {
577585 LOG (INFO) << b_url << worldname << missionName << missionDuration << filename << pair_files << timeout << gametype;
586+ log_curl_exe_string (b_url, worldname, missionName, missionDuration, filename, pair_files, timeout, gametype, secret);
578587 CURL* curl;
579588 CURLcode res;
580589 bool archive = !pair_files.second .empty ();
581590 string file = archive ? pair_files.second : pair_files.first ;
591+ static const char buf[] = " Expect:" ;
582592 curl = curl_easy_init ();
583593 if (curl) {
584- curl_easy_setopt (curl, CURLOPT_CUSTOMREQUEST, " GET" );
585594 curl_easy_setopt (curl, CURLOPT_URL, b_url.c_str ());
586595 curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L );
587596 curl_easy_setopt (curl, CURLOPT_TIMEOUT, (long )timeout);
588597 curl_easy_setopt (curl, CURLOPT_DEFAULT_PROTOCOL, " https" );
589598 curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1L );
590599 struct curl_slist * headers = NULL ;
591- headers = curl_slist_append (headers, " Content-Type: multipart/form-data; boundary=--------------------------330192537127611670327958 " );
600+ headers = curl_slist_append (headers, buf );
592601 curl_easy_setopt (curl, CURLOPT_HTTPHEADER, headers);
593602 curl_mime* mime;
594603 curl_mimepart* part;
@@ -609,9 +618,6 @@ void curlUploadNew(const string &b_url, const string &worldname,const string &mi
609618 curl_mime_name (part, " missionDuration" );
610619 curl_mime_data (part, missionDuration.c_str (), CURL_ZERO_TERMINATED);
611620 part = curl_mime_addpart (mime);
612- /* curl_mime_name(part, "archive");
613- curl_mime_data(part, archive ? "1" : "0", CURL_ZERO_TERMINATED);
614- part = curl_mime_addpart(mime);*/
615621 curl_mime_name (part, " type" );
616622 curl_mime_data (part, gametype.c_str (), CURL_ZERO_TERMINATED);
617623 part = curl_mime_addpart (mime);
@@ -640,7 +646,6 @@ void curlUploadNew(const string &b_url, const string &worldname,const string &mi
640646 curl_mime_free (mime);
641647 curl_slist_free_all (headers);
642648 }
643-
644649}
645650
646651void curlUploadFile (string url, string file, string fileName, int timeout) {
@@ -698,13 +703,12 @@ void curlUploadFile(string url, string file, string fileName, int timeout) {
698703
699704 curl_mime_free (form);
700705 curl_easy_cleanup (curl);
706+ curl_slist_free_all (headerlist);
701707 }
702708 }
703709 catch (...) {
704710 LOG (ERROR) << " Curl unknown exception!" ;
705711 }
706-
707-
708712}
709713
710714void curlActions (string worldName, string missionName, string duration, string filename, pair<string,string> tfile) {
0 commit comments