diff --git a/src/api/api.c b/src/api/api.c index 6b44e75f..452bf110 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -164,7 +164,10 @@ int api_handler(struct mg_connection *conn, void *ignored) } // Call the API function and get the return code - log_debug(DEBUG_API, "Sending to %s", api_request[i].uri); + log_debug(DEBUG_API, "Processing %s %s in %s", + api.request->request_method, + api.request->local_uri_raw, + api_request[i].uri); ret = api_request[i].func(&api); log_debug(DEBUG_API, "Done"); break; diff --git a/src/api/auth.c b/src/api/auth.c index 7ef089d7..c32bab02 100644 --- a/src/api/auth.c +++ b/src/api/auth.c @@ -205,7 +205,7 @@ int check_client_auth(struct ftl_conn *api) { char timestr[128]; get_timestr(timestr, auth_data[user_id].valid_until, false, false); - log_debug(DEBUG_API, "Recognized known user: user_id %i valid_until: %s remote_addr %s", + log_debug(DEBUG_API, "Recognized known user: user_id %i, valid_until: %s, remote_addr %s", user_id, timestr, auth_data[user_id].remote_addr); } } diff --git a/src/api/dns.c b/src/api/dns.c index ebe9a448..261e4fdb 100644 --- a/src/api/dns.c +++ b/src/api/dns.c @@ -88,6 +88,8 @@ static int set_blocking(struct ftl_conn *api) // Delete a possibly running timer set_blockingmode_timer(-1, true); + + log_debug(DEBUG_API, "No change in blocking mode, resetting timer"); } else { @@ -96,6 +98,8 @@ static int set_blocking(struct ftl_conn *api) // Start timer (-1 disables all running timers) set_blockingmode_timer(timer, !target_status); + + log_debug(DEBUG_API, "%sd Pi-hole, timer set to %d seconds", target_status ? "Enable" : "Disable", timer); } // Return GET property as result of POST/PUT/PATCH action diff --git a/src/dnsmasq_interface.c b/src/dnsmasq_interface.c index 6c90aa52..312488da 100644 --- a/src/dnsmasq_interface.c +++ b/src/dnsmasq_interface.c @@ -2829,7 +2829,7 @@ void FTL_fork_and_bind_sockets(struct passwd *ent_pw) // Start database thread if database is used if(pthread_create( &threads[DB], &attr, DB_thread, NULL ) != 0) { - log_crit("Unable to open database thread. Exiting..."); + log_crit("Unable to creeate database thread. Exiting..."); exit(EXIT_FAILURE); } @@ -2837,7 +2837,7 @@ void FTL_fork_and_bind_sockets(struct passwd *ent_pw) // collection needs to be done if(pthread_create( &threads[GC], &attr, GC_thread, NULL ) != 0) { - log_crit("Unable to open GC thread. Exiting..."); + log_crit("Unable to create GC thread. Exiting..."); exit(EXIT_FAILURE); } @@ -2846,7 +2846,15 @@ void FTL_fork_and_bind_sockets(struct passwd *ent_pw) // (e.g. on CI builds), the thread is never started) if(resolve_names() && pthread_create( &threads[DNSclient], &attr, DNSclient_thread, NULL ) != 0) { - log_crit("Unable to open DNS client thread. Exiting..."); + log_crit("Unable to create DNS client thread. Exiting..."); + exit(EXIT_FAILURE); + } + + // Start thread that checks various timers, e.g., for automatic changing + // blocking mode (enabled/disabled for a given amount of time) + if(pthread_create( &threads[TIMER], &attr, timer, NULL ) != 0) + { + log_crit("Unable to create timer thread. Exiting..."); exit(EXIT_FAILURE); } diff --git a/src/enums.h b/src/enums.h index 649cc9ce..b520c4fe 100644 --- a/src/enums.h +++ b/src/enums.h @@ -242,6 +242,7 @@ enum thread_types { GC, DNSclient, CONF_READER, + TIMER, THREADS_MAX } __attribute__ ((packed)); diff --git a/src/timers.c b/src/timers.c index 1c79590d..9d90d00f 100644 --- a/src/timers.c +++ b/src/timers.c @@ -92,10 +92,16 @@ void *timer(void *val) { if(timer_delay > 0) { + log_debug(DEBUG_EXTRA, "Pi-hole will be %s in %d seconds...", + timer_target_status ? "enabled" : "disabled", timer_delay); + timer_delay--; } else if(timer_delay == 0) { + log_debug(DEBUG_EXTRA, "Timer expired, setting blocking mode to %s", + timer_target_status ? "enabled" : "disabled"); + set_blockingstatus(timer_target_status); timer_delay = -1; } diff --git a/src/webserver/lua_web.c b/src/webserver/lua_web.c index 34a14ca5..bfb939f0 100644 --- a/src/webserver/lua_web.c +++ b/src/webserver/lua_web.c @@ -75,8 +75,6 @@ int request_handler(struct mg_connection *conn, void *cbdata) api.conn = conn; api.request = req_info; - log_info("Webserver: %s %s vs. %s", req_info->request_method, req_info->local_uri_raw, admin_api_uri); - // Check if the request is for the API under /admin/api // (it is posted at /api) if(strncmp(req_info->local_uri_raw, admin_api_uri, strlen(admin_api_uri)) == 0)