diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-02-27 18:32:23 -0500 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-02-27 18:32:23 -0500 |
| commit | 9f2cd561286784fd000eb8a00f1f80db3185062c (patch) | |
| tree | 14216b6d50b34bab1c7f7ae70d628d3560613f9e /src/Main.c | |
| parent | 26e3403e039d1a80f2e62f8efe889ad5f40c8cee (diff) | |
| download | omnisearch-9f2cd561286784fd000eb8a00f1f80db3185062c.tar.gz | |
added proxying
Diffstat (limited to 'src/Main.c')
| -rw-r--r-- | src/Main.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -1,10 +1,13 @@ #include <beaker.h> #include <curl/curl.h> #include <libxml/parser.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include "Config.h" +#include "Proxy/Proxy.h" +#include "Scraping/Scraping.h" #include "Routes/Home.h" #include "Routes/Images.h" #include "Routes/ImageProxy.h" @@ -17,17 +20,45 @@ int handle_opensearch(UrlParams *params) { } int main() { + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGPIPE); + pthread_sigmask(SIG_BLOCK, &mask, NULL); + LIBXML_TEST_VERSION xmlInitParser(); curl_global_init(CURL_GLOBAL_DEFAULT); - Config config = {.host = "0.0.0.0", .port = 5000}; + 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"); } + 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"); + } + } + + max_proxy_retries = config.max_proxy_retries; + set_proxy_config(config.proxy, config.randomize_username, config.randomize_password); + + if (proxy_url[0] != '\0') { + 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); + } + set_handler("/", home_handler); set_handler("/opensearch.xml", handle_opensearch); set_handler("/search", results_handler); @@ -47,5 +78,6 @@ int main() { curl_global_cleanup(); xmlCleanupParser(); + free_proxy_list(); return EXIT_SUCCESS; }
\ No newline at end of file |
