Skip to content

Commit

Permalink
no longer switch to tcp mode for truncated NXDOMAIN results
Browse files Browse the repository at this point in the history
  • Loading branch information
EmielBruijntjes committed Oct 22, 2024
1 parent a56a381 commit 8ccd498
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ INCLUDE_DIR = ${PREFIX}/include
LIBRARY_DIR = ${PREFIX}/lib
export LIBRARY_NAME = dnscpp
export SONAME = 1.3
export VERSION = 1.3.3
export VERSION = 1.3.4

all:
$(MAKE) -C src all
Expand Down
8 changes: 6 additions & 2 deletions src/remotelookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,12 @@ bool RemoteLookup::onReceived(const Ip &ip, const Response &response)
if (!_query.matches(response)) return false;

// if the response was not truncated, we can report it to userspace, we do this also
// when the response came from a TCP lookup and was still truncated
if (!response.truncated() || _connections > 0) return report(response);
// when the response came from a TCP lookup and was still truncated, or when the response
// contained an error (for error-responses we do not normally inspect the body, so who cares anyway?)
// (note: we ran into a dns-cpp error when switching to tcp-mode, but could not reproduce this
// in a test setup, the extra check for the rcode was added as workaround to avoid switching
// to tcp that often (in our case the switch only happened for truncated NXDOMAIN responses)
if (!response.truncated() || response.rcode() != 0 || _connections > 0) return report(response);

// we can unsubscribe from all inbound udp sockets because we're no longer interested in those responses
unsubscribe();
Expand Down
2 changes: 1 addition & 1 deletion test/lookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int main(int argc, const char *argv[])
DNS::Context context(&myloop, config);

// set the AD bit (but not the DO and CD bits)
context.bits(DNS::BIT_AD);
//context.bits(DNS::BIT_AD);

// check usage
if (argc != 3) throw std::runtime_error(std::string("usage: ") + argv[0] + " type value");
Expand Down

0 comments on commit 8ccd498

Please sign in to comment.