those who commit
This commit is contained in:
53
src/Main.c
53
src/Main.c
@@ -7,15 +7,16 @@
|
||||
|
||||
#include "Config.h"
|
||||
#include "Proxy/Proxy.h"
|
||||
#include "Scraping/Scraping.h"
|
||||
#include "Routes/Home.h"
|
||||
#include "Routes/Images.h"
|
||||
#include "Routes/ImageProxy.h"
|
||||
#include "Routes/Images.h"
|
||||
#include "Routes/Search.h"
|
||||
#include "Scraping/Scraping.h"
|
||||
|
||||
int handle_opensearch(UrlParams *params) {
|
||||
(void)params;
|
||||
serve_static_file_with_mime("opensearch.xml", "application/opensearchdescription+xml");
|
||||
serve_static_file_with_mime("opensearch.xml",
|
||||
"application/opensearchdescription+xml");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -30,33 +31,35 @@ int main() {
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
Config config = {
|
||||
.host = "0.0.0.0",
|
||||
.port = 5000,
|
||||
.proxy = "",
|
||||
.proxy_list_file = "",
|
||||
.max_proxy_retries = 3,
|
||||
.randomize_username = 0,
|
||||
.randomize_password = 0
|
||||
};
|
||||
|
||||
Config config = {.host = "0.0.0.0",
|
||||
.port = 5000,
|
||||
.proxy = "",
|
||||
.proxy_list_file = "",
|
||||
.max_proxy_retries = 3,
|
||||
.randomize_username = 0,
|
||||
.randomize_password = 0};
|
||||
|
||||
if (load_config("config.ini", &config) != 0) {
|
||||
fprintf(stderr, "Warning: Could not load config file, using defaults\n");
|
||||
fprintf(stderr, "Warning: Could not load config file, using defaults\n");
|
||||
}
|
||||
|
||||
if (config.proxy_list_file[0] != '\0') {
|
||||
if (load_proxy_list(config.proxy_list_file) < 0) {
|
||||
fprintf(stderr, "Warning: Failed to load proxy list, continuing without proxies\n");
|
||||
}
|
||||
if (load_proxy_list(config.proxy_list_file) < 0) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"Warning: Failed to load proxy list, continuing without proxies\n");
|
||||
}
|
||||
}
|
||||
|
||||
max_proxy_retries = config.max_proxy_retries;
|
||||
set_proxy_config(config.proxy, config.randomize_username, config.randomize_password);
|
||||
set_proxy_config(config.proxy, config.randomize_username,
|
||||
config.randomize_password);
|
||||
|
||||
if (proxy_url[0] != '\0') {
|
||||
fprintf(stderr, "Using proxy: %s\n", proxy_url);
|
||||
fprintf(stderr, "Using proxy: %s\n", proxy_url);
|
||||
} else if (proxy_count > 0) {
|
||||
fprintf(stderr, "Using %d proxies from %s\n", proxy_count, config.proxy_list_file);
|
||||
fprintf(stderr, "Using %d proxies from %s\n", proxy_count,
|
||||
config.proxy_list_file);
|
||||
}
|
||||
|
||||
set_handler("/", home_handler);
|
||||
@@ -70,14 +73,14 @@ int main() {
|
||||
int result = beaker_run(config.host, config.port);
|
||||
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "Error: Beaker server failed to start.\n");
|
||||
curl_global_cleanup();
|
||||
xmlCleanupParser();
|
||||
return EXIT_FAILURE;
|
||||
fprintf(stderr, "Error: Beaker server failed to start.\n");
|
||||
curl_global_cleanup();
|
||||
xmlCleanupParser();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
xmlCleanupParser();
|
||||
free_proxy_list();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user