From: Remi Gacogne Date: Wed, 14 Aug 2019 12:17:51 +0000 (+0200) Subject: dnsdist: Don't end the KVS plain text names with a dot X-Git-Tag: dnsdist-1.4.0-rc2~9^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=752db0de50fb22b2581b13c8665828519d5f1d22;p=pdns dnsdist: Don't end the KVS plain text names with a dot --- diff --git a/pdns/dnsdistdist/dnsdist-kvs.cc b/pdns/dnsdistdist/dnsdist-kvs.cc index d5f743838..814551bfe 100644 --- a/pdns/dnsdistdist/dnsdist-kvs.cc +++ b/pdns/dnsdistdist/dnsdist-kvs.cc @@ -58,7 +58,7 @@ std::vector KeyValueLookupKeySuffix::getKeys(const DNSName& qname) result.reserve(labelsCount); while(!lowerQName.isRoot()) { - result.emplace_back(d_wireFormat ? lowerQName.toDNSString() : lowerQName.toString()); + result.emplace_back(d_wireFormat ? lowerQName.toDNSString() : lowerQName.toStringRootDot()); labelsCount--; if (!lowerQName.chopOff() || labelsCount == 0) { break; diff --git a/pdns/dnsdistdist/dnsdist-kvs.hh b/pdns/dnsdistdist/dnsdist-kvs.hh index 892123f14..c9cd7fc2a 100644 --- a/pdns/dnsdistdist/dnsdist-kvs.hh +++ b/pdns/dnsdistdist/dnsdist-kvs.hh @@ -62,7 +62,7 @@ public: if (d_wireFormat) { return {qname.toDNSStringLC()}; } - return {qname.makeLowerCase().toString()}; + return {qname.makeLowerCase().toStringRootDot()}; } std::vector getKeys(const DNSQuestion& dq) override diff --git a/pdns/dnsdistdist/test-dnsdistkvs_cc.cc b/pdns/dnsdistdist/test-dnsdistkvs_cc.cc index 0b27a31a7..adf093973 100644 --- a/pdns/dnsdistdist/test-dnsdistkvs_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistkvs_cc.cc @@ -146,7 +146,7 @@ static void doKVSChecks(std::unique_ptr& kvs, const ComboAddress& auto keys = lookupKey->getKeys(dq); BOOST_CHECK_EQUAL(keys.size(), dq.qname->countLabels()); BOOST_REQUIRE(!keys.empty()); - BOOST_CHECK_EQUAL(keys.at(0), dq.qname->toString()); + BOOST_CHECK_EQUAL(keys.at(0), dq.qname->toStringRootDot()); std::string value; BOOST_CHECK_EQUAL(kvs->getValue(keys.at(0), value), false); value.clear(); @@ -227,7 +227,7 @@ BOOST_AUTO_TEST_CASE(test_LMDB) { auto dbi = transaction.openDB("db-name", MDB_CREATE); transaction.put(dbi, MDBInVal(std::string(reinterpret_cast(&rem.sin4.sin_addr.s_addr), sizeof(rem.sin4.sin_addr.s_addr))), MDBInVal("this is the value for the remote addr")); transaction.put(dbi, MDBInVal(qname.toDNSStringLC()), MDBInVal("this is the value for the qname")); - transaction.put(dbi, MDBInVal(plaintextDomain.toString()), MDBInVal("this is the value for the plaintext domain")); + transaction.put(dbi, MDBInVal(plaintextDomain.toStringRootDot()), MDBInVal("this is the value for the plaintext domain")); transaction.commit(); } @@ -279,7 +279,7 @@ BOOST_AUTO_TEST_CASE(test_CDB) { CDBWriter writer(fd); BOOST_REQUIRE(writer.addEntry(std::string(reinterpret_cast(&rem.sin4.sin_addr.s_addr), sizeof(rem.sin4.sin_addr.s_addr)), "this is the value for the remote addr")); BOOST_REQUIRE(writer.addEntry(qname.toDNSStringLC(), "this is the value for the qname")); - BOOST_REQUIRE(writer.addEntry(plaintextDomain.toString(), "this is the value for the plaintext domain")); + BOOST_REQUIRE(writer.addEntry(plaintextDomain.toStringRootDot(), "this is the value for the plaintext domain")); writer.close(); } diff --git a/regression-tests.dnsdist/test_LMDB.py b/regression-tests.dnsdist/test_LMDB.py index c074a1f92..7529ddd45 100644 --- a/regression-tests.dnsdist/test_LMDB.py +++ b/regression-tests.dnsdist/test_LMDB.py @@ -63,8 +63,8 @@ class TestLMDB(DNSDistTest): txn.put(socket.inet_aton('127.0.0.1'), b'this is the value of the source address tag') txn.put(b'this is the value of the qname tag', b'this is the value of the second tag') txn.put(b'\x06suffix\x04lmdb\x05tests\x08powerdns\x03com\x00', b'this is the value of the suffix tag') - txn.put(b'qname-plaintext.lmdb.tests.powerdns.com.', b'this is the value of the plaintext tag') - txn.put(b'kvs-rule.lmdb.tests.powerdns.com.', b'the value does not matter') + txn.put(b'qname-plaintext.lmdb.tests.powerdns.com', b'this is the value of the plaintext tag') + txn.put(b'kvs-rule.lmdb.tests.powerdns.com', b'the value does not matter') @classmethod def setUpClass(cls):