Skip to content

Commit 81214c5

Browse files
move dnsmasq_diagnosis_warning() into FTL_dnsmasq_log()
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
1 parent 6c5bbb8 commit 81214c5

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
@@ -4138,6 +4138,10 @@ void FTL_dnsmasq_log(const char *payload, const int priority, const char *func,
41384138

41394139
// Write to pihole.log via shared writer (FTL owns this file now)
41404140
FTL_write_dnsmasq_log(payload, func);
4141+
4142+
/* Pi-hole diagnosis system */
4143+
if(priority == LOG_WARNING)
4144+
dnsmasq_diagnosis_warning(payload);
41414145
}
41424146

41434147
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
@@ -810,7 +810,7 @@ void print_FTL_version(void)
810810
}
811811

812812
// Skip leading string if found
813-
static char *skipStr(const char *startstr, char *message)
813+
static const char *skipStr(const char *startstr, const char *message)
814814
{
815815
const size_t startlen = strlen(startstr);
816816
if(strncmp(startstr, message, startlen) == 0)
@@ -819,7 +819,7 @@ static char *skipStr(const char *startstr, char *message)
819819
return message;
820820
}
821821

822-
void dnsmasq_diagnosis_warning(char *message)
822+
void dnsmasq_diagnosis_warning(const char *message)
823823
{
824824
// Crop away any existing initial "warning: "
825825
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)