Skip to content

Commit f5f8e3a

Browse files
move dnsmasq_diagnosis_warning() into FTL_dnsmasq_log()
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
1 parent 3c34fb8 commit f5f8e3a

6 files changed

Lines changed: 10 additions & 19 deletions

File tree

src/database/message-table.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,9 +1456,9 @@ void logg_rate_limit_message(const char *clientIP, const unsigned int rate_limit
14561456

14571457
}
14581458

1459-
void logg_warn_dnsmasq_message(char *message)
1459+
void logg_warn_dnsmasq_message(const char *message)
14601460
{
1461-
// Create message
1461+
// Create message (dnsmasq limits is message length to 1KiB to conform with RFC 3164; See MAX_MESSAGE in dnsmasq/log.c), account for our 'dnsmasq: ' prefix
14621462
char buf[2048];
14631463
format_dnsmasq_warn_message(buf, sizeof(buf), NULL, 0, message);
14641464

src/database/message-table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void logg_subnet_warning(const char *ip, const int matching_count, const char *m
2525
void log_hostname_warning(const char *ip, const char *name, const unsigned int pos);
2626
void logg_fatal_dnsmasq_message(const char *message);
2727
void logg_rate_limit_message(const char *clientIP, const unsigned int rate_limit_count);
28-
void logg_warn_dnsmasq_message(char *message);
28+
void logg_warn_dnsmasq_message(const char *message);
2929
void log_resource_shortage(const double load, const int nprocs, const int shmem, const int disk, const char *path, const char *msg);
3030
void logg_inaccessible_adlist(const int dbindex, const char *address);
3131
void log_certificate_domain_mismatch(const char *certfile, const char *domain);

src/dnsmasq/log.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,6 @@ void my_syslog(int priority, const char *format, ...)
329329
va_end(ap);
330330
FTL_dnsmasq_log(buffer, priority, func, len > MAX_MESSAGE ? MAX_MESSAGE : len);
331331

332-
/* Pi-hole diagnosis system */
333-
if(priority == LOG_WARNING)
334-
{
335-
char *message;
336-
va_start(ap, format);
337-
if(vasprintf(&message, format, ap))
338-
{
339-
dnsmasq_diagnosis_warning(message);
340-
free(message);
341-
}
342-
va_end(ap);
343-
}
344-
345332
/* Pi-hole: FTL owns pihole.log. Bypass dnsmasq's file-write path
346333
and syslog fallback entirely. */
347334
return;

src/dnsmasq_interface.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4145,6 +4145,10 @@ void FTL_dnsmasq_log(const char *payload, const int priority, const char *func,
41454145

41464146
// Write to pihole.log via shared writer (FTL owns this file now)
41474147
FTL_write_dnsmasq_log(payload, func);
4148+
4149+
/* Pi-hole diagnosis system */
4150+
if(priority == LOG_WARNING)
4151+
dnsmasq_diagnosis_warning(payload);
41484152
}
41494153

41504154
static const char *check_dnsmasq_name(const char *name)

src/log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ void print_FTL_version(void)
812812
}
813813

814814
// Skip leading string if found
815-
static char *skipStr(const char *startstr, char *message)
815+
static const char *skipStr(const char *startstr, const char *message)
816816
{
817817
const size_t startlen = strlen(startstr);
818818
if(strncmp(startstr, message, startlen) == 0)
@@ -821,7 +821,7 @@ static char *skipStr(const char *startstr, char *message)
821821
return message;
822822
}
823823

824-
void dnsmasq_diagnosis_warning(char *message)
824+
void dnsmasq_diagnosis_warning(const char *message)
825825
{
826826
// Crop away any existing initial "warning: "
827827
logg_warn_dnsmasq_message(skipStr("warning: ", message));

src/log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const char *priostr(const int priority, const enum debug_flag flag) __attribute
5858
const char *debugstr(const enum debug_flag flag) __attribute__((const));
5959
const char *get_ordinal_suffix(unsigned int number) __attribute__ ((const));
6060
void print_FTL_version(void);
61-
void dnsmasq_diagnosis_warning(char *message);
61+
void dnsmasq_diagnosis_warning(const char *message);
6262

6363
// The actual logging routine can take extra options for specialized logging
6464
// The more general interfaces can be defined here as appropriate shortcuts

0 commit comments

Comments
 (0)