updating client to autoupdate the settings db
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -17,11 +17,17 @@
|
||||
#include "settings.h"
|
||||
#include "check_dir.h"
|
||||
#include "virus_ctrl.h"
|
||||
#include "update.h"
|
||||
int main() {
|
||||
log(LOGLEVEL::INFO, "[main()]:Starting main thread.");
|
||||
printf("welcome to the jakach security tool main thread\n");
|
||||
load_settings();//load the settings from the settings file
|
||||
if (update_settings()) { //update the settings from the server
|
||||
log(LOGLEVEL::ERR, "[main()]:Could not update settings from server.");
|
||||
}
|
||||
load_settings();
|
||||
initialize(DB_DIR); //load the hash databases into memory
|
||||
//download_file_from_srv("http://192.168.27.13/api/php/settings/get_settings.php?settings", "c:\\programdata\\jakach\\out12.txt");
|
||||
|
||||
//start a second thread which will scan for new files
|
||||
if (get_setting("rtp_folder_scan:status") == 1) {
|
||||
|
||||
@@ -47,7 +47,7 @@ int download_file_from_srv(const char* url, const char* output_file_path) {
|
||||
CURL* curl;
|
||||
CURLcode res;
|
||||
FILE* output_file;
|
||||
|
||||
char*buf=new char[55];
|
||||
curl = curl_easy_init();
|
||||
if (!curl) {
|
||||
return 1;
|
||||
@@ -60,7 +60,7 @@ int download_file_from_srv(const char* url, const char* output_file_path) {
|
||||
output_file = fopen(output_file_path, "wb");
|
||||
if (!output_file) {
|
||||
curl_easy_cleanup(curl);
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Set the write callback function
|
||||
@@ -70,12 +70,23 @@ int download_file_from_srv(const char* url, const char* output_file_path) {
|
||||
// Perform the download
|
||||
res = curl_easy_perform(curl);
|
||||
if (res != CURLE_OK) {
|
||||
return 1;
|
||||
return 3;
|
||||
}
|
||||
// Cleanup and close the file
|
||||
curl_easy_cleanup(curl);
|
||||
fclose(output_file);
|
||||
|
||||
if ((output_file = fopen(output_file_path, "r")) == 0) {
|
||||
return 4;
|
||||
}
|
||||
else {
|
||||
fscanf(output_file, "%50s", buf);
|
||||
if (strcmp(buf, "no_auth") == 0) {
|
||||
fclose(output_file);
|
||||
return 5;
|
||||
}
|
||||
fclose(output_file);
|
||||
}
|
||||
delete[] buf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ int load_settings() {
|
||||
|
||||
if (fopen_s(&fp, SETTINGS_DB, "r")!=0) {
|
||||
log(LOGLEVEL::ERR, "[load_settings()]: Could not open settings file. ", SETTINGS_DB);
|
||||
strcpy_s(setting_server_server_url, 295, "http://localhost");
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
@@ -63,6 +64,7 @@ int load_settings() {
|
||||
}
|
||||
load_included_folders();
|
||||
load_excluded_folders();
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,15 +40,15 @@ int update_db(const std::string& folder_path) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int update_settings(const std::string& folder_path) {
|
||||
int update_settings() {
|
||||
//create the strings to download the files
|
||||
char* url = new char[300];
|
||||
char* url = new char[500];
|
||||
get_setting("server:server_url", url);
|
||||
strcat_s(url, 295, "/database/");
|
||||
strcat_s(url, 295, "settings_db.txt");
|
||||
strcat_s(url, 500, "/api/php/settings/get_settings.php?settings");
|
||||
int res = download_file_from_srv(url, SETTINGS_DB);
|
||||
//res = 0;
|
||||
if (res != 0) {
|
||||
log(LOGLEVEL::ERR, "[update_db()]: Error downloading settings database file from server", url);
|
||||
log(LOGLEVEL::ERR, "[update_db()]: Error downloading settings database file from server", url, " ERROR:",res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
#include <curl/curl.h>
|
||||
#include<string>
|
||||
int update_db(const std::string& folder_path);
|
||||
int update_settings(const std::string& folder_path);
|
||||
int update_settings();
|
||||
#endif
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
Quellen werden auf Modulabhängigkeiten überprüft...
|
||||
scan.cpp
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\scan.cpp(153,32): warning C4018: ">=": Konflikt zwischen "signed" und "unsigned"
|
||||
connect.cpp
|
||||
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\connect.cpp(103,65): warning C4267: "Argument": Konvertierung von "size_t" nach "int", Datenverlust möglich
|
||||
client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user