diff options
author | Christian Hesse <mail@eworm.de> | 2019-07-01 14:28:11 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2019-07-01 14:28:11 +0200 |
commit | 5caf5a9b40d5dfbefc48943b8fc9eeec83864188 (patch) | |
tree | cab1d4ac11d430101e12458a3d2a4b38530adf7b /pacredir.c | |
parent | b9497c1626276975800819decb5f1fd96c000151 (diff) | |
parent | d4ca52db773f2e799e84150428bf705bd78d1624 (diff) | |
download | pacredir-5caf5a9b40d5dfbefc48943b8fc9eeec83864188.tar.gz pacredir-5caf5a9b40d5dfbefc48943b8fc9eeec83864188.tar.zst |
Merge branch 'ignore-db-files'
Diffstat (limited to 'pacredir.c')
-rw-r--r-- | pacredir.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -22,7 +22,7 @@ struct hosts * hosts = NULL; struct ignore_interfaces * ignore_interfaces = NULL; int max_threads = 0; static AvahiSimplePoll *simple_poll = NULL; -uint8_t verbose = 0; +uint8_t verbose = 0, ignore_db_files = 0; unsigned int count_redirect = 0, count_not_found = 0; /*** write_log ***/ @@ -409,7 +409,15 @@ static int ahc_echo(void * cls, /* process db file request (*.db and *.files) */ if ((strlen(basename) > 3 && strcmp(basename + strlen(basename) - 3, ".db") == 0) || (strlen(basename) > 6 && strcmp(basename + strlen(basename) - 6, ".files") == 0)) { + dbfile = 1; + + /* return 404 if database file are disabled */ + if (ignore_db_files > 0) { + http_code = MHD_HTTP_NOT_FOUND; + goto response; + } + /* get timestamp of local file */ filename = malloc(strlen(SYNCPATH) + strlen(basename) + 2); sprintf(filename, SYNCPATH "/%s", basename); @@ -546,10 +554,12 @@ response: ret = MHD_queue_response(connection, MHD_HTTP_TEMPORARY_REDIRECT, response); free(url); } else { - if (req_count < 0) + if (dbfile > 0 && ignore_db_files > 0) + write_log(stdout, "Ignoring request for db file %s.\n", basename); + else if (req_count < 0) write_log(stdout, "Currently no servers are available to check for %s.\n", basename); - else if (dbfile == 1) + else if (dbfile > 0) write_log(stdout, "No more recent version of %s found on %d servers.\n", basename, req_count + 1); else @@ -683,6 +693,9 @@ int main(int argc, char ** argv) { if (verbose > 0 && max_threads > 0) write_log(stdout, "Limiting number of threads to a maximum of %d\n", max_threads); + /* whether to ignore db files */ + ignore_db_files = iniparser_getboolean(ini, "general:ignore db files", ignore_db_files); + /* store interfaces to ignore */ if ((inistring = iniparser_getstring(ini, "general:ignore interfaces", NULL)) != NULL) { values = strdup(inistring); |