This commit is contained in:
2025-02-09 11:14:36 +01:00
parent 8abce2236f
commit 65a0f2447d
5 changed files with 55 additions and 29 deletions
Binary file not shown.
+23 -7
View File
@@ -282,16 +282,14 @@ static void print_query(struct event *s_event){
printf("\n");
}
/*
* This function save to log file the query section in rsylog format
* <time> <hostname> <procname>: <info> <data>
* This function save to rsyslog file the common information
*/
static void query_to_log(struct event *s_event){
static void header_to_log(struct event *s_event){
char t[32];
time_t ts = time(NULL);
char *req_type, *class, *type;
char tid[12];
char src[40];
char s_class[16], s_type[16];
char *req_type;
time_t ts = time(NULL);
if (syslog_time(ts, t, sizeof(t)) == 0)
fwrite(t, strlen(t), 1, f);
@@ -312,6 +310,17 @@ static void query_to_log(struct event *s_event){
snprintf(src, 40, "%s:%d;", inet_ntoa(*(struct in_addr*)&s_event->client), s_event->dport);
fwrite(src, strlen(src), 1, f);
}
/*
* This function save to log file the query section in rsylog format
* <time> <hostname> <procname>: <info> <data>
*/
static void query_to_log(struct event *s_event){
char *class, *type;
char s_class[16], s_type[16];
header_to_log(s_event);
class = mapClass(s_event->class);
snprintf(s_class, 16, "class=%s;", class);
@@ -323,7 +332,10 @@ static void query_to_log(struct event *s_event){
fwrite(s_type, strlen(s_type), 1, f);
free(type);
fwrite("\n", 1, 1, f);
fwrite("domain=", 7, 1, f);
fwrite(s_event->qname, strlen(s_event->qname), 1, f);
fwrite(";\n", 2, 1, f);
}
/*
* This function get labels from DNS answer
@@ -345,7 +357,11 @@ static void get_labels(unsigned char *buf, char *qname){
* This function save to rsyslog format the answer section
*/
static void answer_to_log(struct event *s_event){
for (int i = 0; i < s_event->numAns; i++){
header_to_log(s_event);
fwrite("\n", 1, 1, f);
}
}
/*
* This function print to the stdout the answer section