Skip to content

Commit

Permalink
- Fix for dnsoverquic and dnstap to use the correct dnstap
Browse files Browse the repository at this point in the history
  environment.
  • Loading branch information
gthess committed Oct 16, 2024
1 parent 2a28c73 commit f8e45ed
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
4 changes: 4 additions & 0 deletions doc/Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
16 October 2024: Yorgos
- Fix for dnsoverquic and dnstap to use the correct dnstap
environment.

14 October 2024: Wouter
- Fix to display warning if quic-port is set but dnsoverquic is not
enabled when compiled.
Expand Down
47 changes: 37 additions & 10 deletions util/netevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -6624,6 +6624,20 @@ comm_point_delete(struct comm_point* c)
free(c);
}

#ifdef USE_DNSTAP
static void
send_reply_dnstap(struct dt_env* dtenv,
struct sockaddr* addr, socklen_t addrlen,
struct sockaddr_storage* client_addr, socklen_t client_addrlen,
enum comm_point_type type, void* ssl, sldns_buffer* buffer)
{
log_addr(VERB_ALGO, "from local addr", (void*)addr, addrlen);
log_addr(VERB_ALGO, "response to client", client_addr, client_addrlen);
dt_msg_send_client_response(dtenv, client_addr,
(struct sockaddr_storage*)addr, type, ssl, buffer);
}
#endif

void
comm_point_send_reply(struct comm_reply *repinfo)
{
Expand All @@ -6648,24 +6662,37 @@ comm_point_send_reply(struct comm_reply *repinfo)
repinfo->remote_addrlen, 0);
#ifdef USE_DNSTAP
/*
* sending src (client)/dst (local service) addresses over DNSTAP from udp callback
* sending src (client)/dst (local service) addresses over
* DNSTAP from udp callback
*/
if(repinfo->c->dtenv != NULL && repinfo->c->dtenv->log_client_response_messages) {
log_addr(VERB_ALGO, "from local addr", (void*)repinfo->c->socket->addr, repinfo->c->socket->addrlen);
log_addr(VERB_ALGO, "response to client", &repinfo->client_addr, repinfo->client_addrlen);
dt_msg_send_client_response(repinfo->c->dtenv, &repinfo->client_addr, (void*)repinfo->c->socket->addr, repinfo->c->type, repinfo->c->ssl, repinfo->c->buffer);
send_reply_dnstap(repinfo->c->dtenv,
repinfo->c->socket->addr,
repinfo->c->socket->addrlen,
&repinfo->client_addr, repinfo->client_addrlen,
repinfo->c->type, repinfo->c->ssl,
repinfo->c->buffer);
}
#endif
} else {
#ifdef USE_DNSTAP
struct dt_env* dtenv = repinfo->c->doq_socket
?repinfo->c->dtenv
:repinfo->c->tcp_parent->dtenv;
struct sldns_buffer* dtbuffer = repinfo->c->tcp_req_info
?repinfo->c->tcp_req_info->spool_buffer
:repinfo->c->buffer;
/*
* sending src (client)/dst (local service) addresses over DNSTAP from TCP callback
* sending src (client)/dst (local service) addresses over
* DNSTAP from other callbacks
*/
if(repinfo->c->tcp_parent->dtenv != NULL && repinfo->c->tcp_parent->dtenv->log_client_response_messages) {
log_addr(VERB_ALGO, "from local addr", (void*)repinfo->c->socket->addr, repinfo->c->socket->addrlen);
log_addr(VERB_ALGO, "response to client", &repinfo->client_addr, repinfo->client_addrlen);
dt_msg_send_client_response(repinfo->c->tcp_parent->dtenv, &repinfo->client_addr, (void*)repinfo->c->socket->addr, repinfo->c->type, repinfo->c->ssl,
( repinfo->c->tcp_req_info? repinfo->c->tcp_req_info->spool_buffer: repinfo->c->buffer ));
if(dtenv != NULL && dtenv->log_client_response_messages) {
send_reply_dnstap(dtenv,
repinfo->c->socket->addr,
repinfo->c->socket->addrlen,
&repinfo->client_addr, repinfo->client_addrlen,
repinfo->c->type, repinfo->c->ssl,
dtbuffer);
}
#endif
if(repinfo->c->tcp_req_info) {
Expand Down

0 comments on commit f8e45ed

Please sign in to comment.