Skip to content

Commit 8ccd498

Browse files
no longer switch to tcp mode for truncated NXDOMAIN results
1 parent a56a381 commit 8ccd498

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ INCLUDE_DIR = ${PREFIX}/include
33
LIBRARY_DIR = ${PREFIX}/lib
44
export LIBRARY_NAME = dnscpp
55
export SONAME = 1.3
6-
export VERSION = 1.3.3
6+
export VERSION = 1.3.4
77

88
all:
99
$(MAKE) -C src all

src/remotelookup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,12 @@ bool RemoteLookup::onReceived(const Ip &ip, const Response &response)
261261
if (!_query.matches(response)) return false;
262262

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

267271
// we can unsubscribe from all inbound udp sockets because we're no longer interested in those responses
268272
unsubscribe();

test/lookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ int main(int argc, const char *argv[])
255255
DNS::Context context(&myloop, config);
256256

257257
// set the AD bit (but not the DO and CD bits)
258-
context.bits(DNS::BIT_AD);
258+
//context.bits(DNS::BIT_AD);
259259

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

0 commit comments

Comments
 (0)