diff --git a/.github/workflows/build-and-test-all.yml b/.github/workflows/build-and-test-all.yml index 4fa0b42bbad3..b4d7be90b83a 100644 --- a/.github/workflows/build-and-test-all.yml +++ b/.github/workflows/build-and-test-all.yml @@ -139,7 +139,7 @@ jobs: needs: get-runner-container-image strategy: matrix: - sanitizers: [ubsan+asan, tsan] + sanitizers: [asan+ubsan, tsan] features: [least, full] exclude: - sanitizers: tsan @@ -213,11 +213,14 @@ jobs: needs: get-runner-container-image strategy: matrix: - sanitizers: [ubsan+asan, tsan] + builder: [autotools, meson] + sanitizers: [asan+ubsan, tsan] features: [least, full] exclude: - sanitizers: tsan features: least + - sanitizers: tsan + builder: meson container: image: "${{ needs.get-runner-container-image.outputs.id }}:${{ needs.get-runner-container-image.outputs.tag }}" env: @@ -247,25 +250,31 @@ jobs: uses: actions/cache@v4 with: path: ~/.ccache - key: dnsdist-${{ matrix.features }}-${{ matrix.sanitizers }}-ccache-${{ steps.get-stamp.outputs.stamp }} - restore-keys: dnsdist-${{ matrix.features }}-${{ matrix.sanitizers }}-ccache- + key: dnsdist-${{ matrix.features }}-${{ matrix.sanitizers }}-${{ matrix.builder}}-ccache-${{ steps.get-stamp.outputs.stamp }} + restore-keys: dnsdist-${{ matrix.features }}-${{ matrix.sanitizers }}-${{ matrix.builder}}-ccache- + - run: inv ci-install-meson + if: ${{ matrix.builder == 'meson' }} + working-directory: ./pdns/dnsdistdist/ - run: inv ci-install-rust ${{ env.REPO_HOME }} working-directory: ./pdns/dnsdistdist/ - run: inv ci-build-and-install-quiche ${{ env.REPO_HOME }} working-directory: ./pdns/dnsdistdist/ - run: inv ci-autoconf + if: ${{ matrix.builder == 'autotools' }} working-directory: ./pdns/dnsdistdist/ - - run: inv ci-dnsdist-configure ${{ matrix.features }} + - run: inv ci-dnsdist-configure ${{ matrix.features }} ${{ matrix.builder }} dnsdist-${{ env.BUILDER_VERSION }} working-directory: ./pdns/dnsdistdist/ - run: inv ci-make-distdir + if: ${{ matrix.builder == 'autotools' }} working-directory: ./pdns/dnsdistdist/ - - run: inv ci-dnsdist-configure ${{ matrix.features }} - - run: inv ci-dnsdist-make-bear - - run: inv ci-dnsdist-run-unit-tests + - run: inv ci-dnsdist-configure ${{ matrix.features }} ${{ matrix.builder }} dnsdist-${{ env.BUILDER_VERSION }} + if: ${{ matrix.builder == 'autotools' }} + - run: inv ci-dnsdist-make-bear ${{ matrix.builder }} + - run: inv ci-dnsdist-run-unit-tests ${{ matrix.builder }} - run: inv generate-coverage-info ./testrunner $GITHUB_WORKSPACE - if: ${{ env.COVERAGE == 'yes' && matrix.sanitizers != 'tsan' }} + if: ${{ env.COVERAGE == 'yes' && matrix.sanitizers != 'tsan' && matrix.builder == 'autotools'}} - name: Coveralls Parallel dnsdist unit - if: ${{ env.COVERAGE == 'yes' && matrix.sanitizers != 'tsan' }} + if: ${{ env.COVERAGE == 'yes' && matrix.sanitizers != 'tsan' && matrix.builder == 'autotools' }} uses: coverallsapp/github-action@v2 with: flag-name: dnsdist-unit-${{ matrix.features }}-${{ matrix.sanitizers }} @@ -274,12 +283,14 @@ jobs: allow-empty: true fail-on-error: false - run: inv ci-make-install + if: ${{ matrix.builder == 'autotools' }} - run: ccache -s - run: echo "normalized-branch-name=${{ inputs.branch-name || github.ref_name }}" | tr "/" "-" >> "$GITHUB_ENV" - name: Store the binaries + if: ${{ matrix.builder == 'autotools' }} uses: actions/upload-artifact@v4 # this takes 30 seconds, maybe we want to tar with: - name: dnsdist-${{ matrix.features }}-${{ matrix.sanitizers }}-${{ env.normalized-branch-name }} + name: dnsdist-${{ matrix.features }}-${{ matrix.sanitizers }}-${{ matrix.builder}}-${{ env.normalized-branch-name }} path: /opt/dnsdist retention-days: 1 @@ -521,7 +532,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - sanitizers: [ubsan+asan, tsan] + sanitizers: [asan+ubsan, tsan] dist_name: [debian] pdns_repo_version: ['48'] container: @@ -567,7 +578,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - sanitizers: [ubsan+asan, tsan] + sanitizers: [asan+ubsan, tsan] dist_name: [debian] pdns_repo_version: ['48'] container: @@ -616,7 +627,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - sanitizers: [ubsan+asan, tsan] + sanitizers: [asan+ubsan, tsan] threads: [1, 2, 3, 4, 8] mthreads: [2048] shards: [1, 2, 1024] @@ -661,7 +672,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - sanitizers: [ubsan+asan, tsan] + sanitizers: [asan+ubsan, tsan] container: image: "${{ needs.get-runner-container-image.outputs.id }}:${{ needs.get-runner-container-image.outputs.tag }}" env: @@ -685,7 +696,7 @@ jobs: - name: Fetch the binaries uses: actions/download-artifact@v4 with: - name: dnsdist-full-${{ matrix.sanitizers }}-${{ env.normalized-branch-name }} + name: dnsdist-full-${{ matrix.sanitizers }}-autotools-${{ env.normalized-branch-name }} path: /opt/dnsdist - run: inv install-clang-runtime - run: inv install-dnsdist-test-deps $([ "$(. /etc/os-release && echo $VERSION_CODENAME)" = "bullseye" ] && echo "--skipXDP=True") diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 35e2b0af24d0..81aa61c149a3 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -166,12 +166,12 @@ jobs: if: matrix.product == 'dnsdist' working-directory: ./pdns/dnsdistdist/ run: | - inv ci-dnsdist-configure full + inv ci-dnsdist-configure full autotools build-dir - name: Build dnsdist if: matrix.product == 'dnsdist' working-directory: ./pdns/dnsdistdist/ run: | - inv ci-dnsdist-make-bear + inv ci-dnsdist-make-bear autotools - run: ln -s ../../.clang-tidy.full .clang-tidy if: matrix.product == 'dnsdist' working-directory: ./pdns/dnsdistdist/ diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 3c66162722a6..c4dbd2162270 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -79,7 +79,7 @@ jobs: working-directory: ./pdns/dnsdistdist/ - run: inv ci-build-and-install-quiche ${{ env.REPO_HOME }} working-directory: ./pdns/dnsdistdist/ - - run: inv ci-dnsdist-configure full + - run: inv ci-dnsdist-configure full autotools build-dir working-directory: ./pdns/dnsdistdist/ - run: inv coverity-make working-directory: ./pdns/dnsdistdist/ diff --git a/ext/lmdb-safe/lmdb-safe.hh b/ext/lmdb-safe/lmdb-safe.hh index 8190f16ca70d..63878fec1fe9 100644 --- a/ext/lmdb-safe/lmdb-safe.hh +++ b/ext/lmdb-safe/lmdb-safe.hh @@ -594,6 +594,9 @@ private: // * so let's go back } #else /* ifndef DNSDIST */ + (void)key; + (void)data; + (void)op; return rc; #endif } diff --git a/fuzzing/README.md b/fuzzing/README.md index ca26a8b10033..0880ae35f370 100644 --- a/fuzzing/README.md +++ b/fuzzing/README.md @@ -25,12 +25,15 @@ By default the targets are linked against a standalone target, `standalone_fuzz_target_runner.cc`, which does no fuzzing but makes it easy to check a given test file, or just that the fuzzing targets can be built properly. -This behaviour can be changed via the `LIB_FUZZING_ENGINE` variable, for example -by setting it to `-lFuzzer`, building with clang by setting `CC=clang CXX=clang++` -before running the `configure` and adding `-fsanitize=fuzzer-no-link` to `CFLAGS` -and `CXXFLAGS`. Doing so instructs the compiler to instrument the code for -efficient fuzzing but not to link directly with `-lFuzzer`, which would make -the compilation tests done during the configure phase fail. +This behaviour can be changed via: +- either the `LIB_FUZZING_ENGINE` variable when building with `./configure` +- or the `-Dfuzzer_ldflags` option when building with `meson` + +For example, setting `LIB_FUZZING_ENGINE` to `-lFuzzer`, then building with clang +by setting `CC=clang CXX=clang++` before running the `configure`, and adding +`-fsanitize=fuzzer-no-link` to `CFLAGS` and `CXXFLAGS`, instructs the compiler +to instrument the code for efficient fuzzing but not to link directly with +`-lFuzzer`, which would make the compilation tests done during the configure phase fail. Sanitizers ---------- @@ -86,6 +89,15 @@ LIB_FUZZING_ENGINE="/usr/lib/clang/11.0.1/lib/linux/libclang_rt.fuzzer-x86_64.a" make -C pdns -j2 fuzz_targets ``` +or, if you are using `meson` to build the authoritative server instead of `./configure`: + +``` +env CC=clang CXX=clang++ \ + CFLAGS=-fsanitize=fuzzer-no-link CXXFLAGS=-fsanitize=fuzzer-no-link \ + meson setup .. -Dfuzz-targets=true -Dfuzzer_ldflags=/usr/lib/clang/18/lib/linux/libclang_rt.fuzzer-x86_64.a -Db_sanitize=address,undefined +ninja +``` + Now you're ready to run one of the fuzzing targets. First, copy the starting corpus: diff --git a/meson.build b/meson.build index 9afe50adb186..2c4ccf4e3ee9 100644 --- a/meson.build +++ b/meson.build @@ -415,10 +415,6 @@ conditional_sources = { 'sources': [src_dir / 'lua-record.cc'], 'condition': dep_lua_records.found(), }, - 'standalone-fuzz-target-runner': { - 'sources': [src_dir / 'standalone_fuzz_target_runner.cc'], - 'condition': get_option('fuzz-targets'), - }, } foreach name, info: conditional_sources @@ -944,6 +940,15 @@ if get_option('unit-tests') endif if get_option('fuzz-targets') + fuzz_extra_sources = [] + fuzzer_ldflags = [] + # https://github.com/harfbuzz/harfbuzz/pull/2549/files + if get_option('fuzzer_ldflags') == '' + fuzz_extra_sources += src_dir / 'standalone_fuzz_target_runner.cc' + else + fuzzer_ldflags += get_option('fuzzer_ldflags') + endif + fuzz_targets = [ 'moadnsparser', 'packetcache', @@ -956,7 +961,9 @@ if get_option('fuzz-targets') foreach target: fuzz_targets source_file = src_dir / 'fuzz_' + target.underscorify() + '.cc' tools += { - 'fuzz-target-' + target: { 'main': source_file } + 'fuzz-target-' + target: { 'main': source_file, + 'link-args': fuzzer_ldflags, + 'files-extra': fuzz_extra_sources } } endforeach endif @@ -984,6 +991,7 @@ foreach tool, info: tools export_dynamic = 'export-dynamic' in info ? info['export-dynamic'] : false files_extra = 'files-extra' in info ? info['files-extra'] : [] deps_extra = 'deps-extra' in info ? info['deps-extra'] : [] + link_args = 'link-args' in info ? info['link-args'] : [] set_variable( var_name, @@ -993,6 +1001,7 @@ foreach tool, info: tools config_h, files_extra, export_dynamic: export_dynamic, + link_args: link_args, dependencies: [ deps, libpdns_common, diff --git a/meson_options.txt b/meson_options.txt index c33ae9b8db15..72b55b2e5bc8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -16,6 +16,7 @@ option('unit-tests', type: 'boolean', value: false, description: 'Build and run option('unit-tests-backends', type: 'boolean', value: false, description: 'Build and run backend unit tests') option('reproducible', type: 'boolean', value: false, description: 'Reproducible builds (for distro maintainers, makes debugging difficult)') option('fuzz-targets', type: 'boolean', value: false, description: 'Enable fuzzing targets') +option('fuzzer_ldflags', type: 'string', value: '', description: 'Linker flags used for the fuzzing targets (a path to the libFuzzer static library, for example)') option('verbose-logging', type: 'boolean', value: false, description: 'Enable verbose logging') option('experimental-pkcs11', type: 'feature', value: 'disabled', description: 'PKCS11 support') option('experimental-gss-tsig', type: 'feature', value: 'disabled', description: 'GSS-TSIG support') diff --git a/pdns/dnsdistdist/NOTICE b/pdns/dnsdistdist/NOTICE new file mode 120000 index 000000000000..fb376cfaa471 --- /dev/null +++ b/pdns/dnsdistdist/NOTICE @@ -0,0 +1 @@ +../../NOTICE \ No newline at end of file diff --git a/pdns/dnsdistdist/base32.hh b/pdns/dnsdistdist/base32.hh deleted file mode 120000 index ad650d230cdd..000000000000 --- a/pdns/dnsdistdist/base32.hh +++ /dev/null @@ -1 +0,0 @@ -../base32.hh \ No newline at end of file diff --git a/pdns/dnsdistdist/bpf-filter.cc b/pdns/dnsdistdist/bpf-filter.cc index 700f32467dfb..bfed7cfc1119 100644 --- a/pdns/dnsdistdist/bpf-filter.cc +++ b/pdns/dnsdistdist/bpf-filter.cc @@ -900,6 +900,9 @@ uint64_t BPFFilter::getHits(const ComboAddress& requestor) BPFFilter::BPFFilter(std::unordered_map& configs, BPFFilter::MapFormat format, bool external) { + (void)configs; + (void)format; + (void)external; } void BPFFilter::addSocket(int) @@ -972,6 +975,7 @@ bool BPFFilter::supportsMatchAction(MatchAction action) const } return d_mapFormat == BPFFilter::MapFormat::WithActions; #endif /* HAVE_EBPF */ + (void)action; return false; } diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index aa1892f4c1f7..f6964a8febd0 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -16,8 +16,8 @@ AC_DEFINE([DNSDIST], [1], LT_PREREQ([2.2.2]) LT_INIT([disable-static]) -CFLAGS="-g -O3 -Wall -Wextra -Wshadow -Wno-unused-parameter -fvisibility=hidden $CFLAGS" -CXXFLAGS="-g -O3 -Wall -Wextra -Wshadow -Wno-unused-parameter -Wmissing-declarations -Wredundant-decls -fvisibility=hidden $CXXFLAGS" +CFLAGS="-g -O3 -Wall -Wextra -Wshadow -fvisibility=hidden $CFLAGS" +CXXFLAGS="-g -O3 -Wall -Wextra -Wshadow -Wmissing-declarations -Wredundant-decls -fvisibility=hidden $CXXFLAGS" AC_SUBST([pdns_configure_args], ["$ac_configure_args"]) AC_DEFINE_UNQUOTED([DNSDIST_CONFIG_ARGS], diff --git a/pdns/dnsdistdist/dnsdist-carbon.cc b/pdns/dnsdistdist/dnsdist-carbon.cc index 040783b68a95..bd339ed294eb 100644 --- a/pdns/dnsdistdist/dnsdist-carbon.cc +++ b/pdns/dnsdistdist/dnsdist-carbon.cc @@ -362,9 +362,10 @@ void Carbon::run(const std::vector& endpoints) } #endif /* DISABLE_CARBON */ -static time_t s_start = time(nullptr); +static const time_t s_start = time(nullptr); uint64_t uptimeOfProcess(const std::string& str) { + (void)str; return time(nullptr) - s_start; } diff --git a/pdns/dnsdistdist/dnsdist-console.cc b/pdns/dnsdistdist/dnsdist-console.cc index 12926eeedf94..f8c9c72679e5 100644 --- a/pdns/dnsdistdist/dnsdist-console.cc +++ b/pdns/dnsdistdist/dnsdist-console.cc @@ -887,6 +887,7 @@ extern "C" static char** dnsdist_completion_callback(const char* text, int start, int end) { + (void)end; char** matches = nullptr; if (start == 0) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast): readline diff --git a/pdns/dnsdistdist/dnsdist-downstream-connection.hh b/pdns/dnsdistdist/dnsdist-downstream-connection.hh index 8d50de369f2e..aba6cd23c647 100644 --- a/pdns/dnsdistdist/dnsdist-downstream-connection.hh +++ b/pdns/dnsdistdist/dnsdist-downstream-connection.hh @@ -62,7 +62,7 @@ public: const auto& it = d_downstreamConnections.find(backendId); if (it != d_downstreamConnections.end()) { /* first scan idle connections, more recent first */ - auto entry = findUsableConnectionInList(now, freshCutOff, it->second.d_idles, true); + auto entry = findUsableConnectionInList(freshCutOff, it->second.d_idles, true); if (entry) { ++ds->tcpReusedConnections; it->second.d_actives.insert(entry); @@ -70,7 +70,7 @@ public: } /* then scan actives ones, more recent first as well */ - entry = findUsableConnectionInList(now, freshCutOff, it->second.d_actives, false); + entry = findUsableConnectionInList(freshCutOff, it->second.d_actives, false); if (entry) { ++ds->tcpReusedConnections; return entry; @@ -107,8 +107,8 @@ public: idleCutOff.tv_sec -= s_maxIdleTime; for (auto dsIt = d_downstreamConnections.begin(); dsIt != d_downstreamConnections.end();) { - cleanUpList(dsIt->second.d_idles, now, freshCutOff, idleCutOff); - cleanUpList(dsIt->second.d_actives, now, freshCutOff, idleCutOff); + cleanUpList(dsIt->second.d_idles, freshCutOff, idleCutOff); + cleanUpList(dsIt->second.d_actives, freshCutOff, idleCutOff); if (dsIt->second.d_idles.empty() && dsIt->second.d_actives.empty()) { dsIt = d_downstreamConnections.erase(dsIt); @@ -212,7 +212,7 @@ public: } protected: - void cleanUpList(list_t& list, const struct timeval& now, const struct timeval& freshCutOff, const struct timeval& idleCutOff) + void cleanUpList(list_t& list, const struct timeval& freshCutOff, const struct timeval& idleCutOff) { auto& sidx = list.template get(); for (auto connIt = sidx.begin(); connIt != sidx.end();) { @@ -248,7 +248,7 @@ protected: } } - std::shared_ptr findUsableConnectionInList(const struct timeval& now, const struct timeval& freshCutOff, list_t& list, bool removeIfFound) + std::shared_ptr findUsableConnectionInList(const struct timeval& freshCutOff, list_t& list, bool removeIfFound) { auto& sidx = list.template get(); for (auto listIt = sidx.begin(); listIt != sidx.end();) { @@ -258,7 +258,7 @@ protected: } auto& entry = *listIt; - if (isConnectionUsable(entry, now, freshCutOff)) { + if (isConnectionUsable(entry, freshCutOff)) { entry->setReused(); // make a copy since the iterator will be invalidated after erasing auto result = entry; @@ -280,7 +280,7 @@ protected: return nullptr; } - bool isConnectionUsable(const std::shared_ptr& conn, const struct timeval& now, const struct timeval& freshCutOff) + bool isConnectionUsable(const std::shared_ptr& conn, const struct timeval& freshCutOff) { if (!conn->canBeReused()) { return false; diff --git a/pdns/dnsdistdist/dnsdist-healthchecks.cc b/pdns/dnsdistdist/dnsdist-healthchecks.cc index 7f02b24f76d0..647cfa23e49f 100644 --- a/pdns/dnsdistdist/dnsdist-healthchecks.cc +++ b/pdns/dnsdistdist/dnsdist-healthchecks.cc @@ -159,17 +159,22 @@ class HealthCheckQuerySender : public TCPQuerySender void handleResponse(const struct timeval& now, TCPResponse&& response) override { + (void)now; d_data->d_buffer = std::move(response.d_buffer); d_data->d_ds->submitHealthCheckResult(d_data->d_initial, ::handleResponse(d_data)); } void handleXFRResponse(const struct timeval& now, TCPResponse&& response) override { + (void)now; + (void)response; throw std::runtime_error("Unexpected XFR reponse to a health check query"); } void notifyIOError(const struct timeval& now, [[maybe_unused]] TCPResponse&& response) override { + (void)now; + (void)response; ++d_data->d_ds->d_healthCheckMetrics.d_networkErrors; d_data->d_ds->submitHealthCheckResult(d_data->d_initial, false); } @@ -231,6 +236,7 @@ static void healthCheckUDPCallback(int descriptor, FDMultiplexer::funcparam_t& p static void healthCheckTCPCallback(int descriptor, FDMultiplexer::funcparam_t& param) { + (void)descriptor; auto data = boost::any_cast>(param); IOStateGuard ioGuard(data->d_ioState); diff --git a/pdns/dnsdistdist/dnsdist-internal-queries.cc b/pdns/dnsdistdist/dnsdist-internal-queries.cc index 535062227df4..66b327e51ba8 100644 --- a/pdns/dnsdistdist/dnsdist-internal-queries.cc +++ b/pdns/dnsdistdist/dnsdist-internal-queries.cc @@ -29,7 +29,7 @@ std::unique_ptr getUDPCrossProtocolQueryFromDQ(DNSQuestion& namespace dnsdist { -std::unique_ptr getInternalQueryFromDQ(DNSQuestion& dnsQuestion, bool isResponse) +std::unique_ptr getInternalQueryFromDQ(DNSQuestion& dnsQuestion, [[maybe_unused]] bool isResponse) { auto protocol = dnsQuestion.getProtocol(); if (protocol == dnsdist::Protocol::DoUDP || protocol == dnsdist::Protocol::DNSCryptUDP) { diff --git a/pdns/dnsdistdist/dnsdist-kvs.hh b/pdns/dnsdistdist/dnsdist-kvs.hh index 764a45c35c07..5672986e8201 100644 --- a/pdns/dnsdistdist/dnsdist-kvs.hh +++ b/pdns/dnsdistdist/dnsdist-kvs.hh @@ -160,6 +160,8 @@ public: // This requires that the underlying store supports ordered keys, which is true for LMDB but not for CDB, for example. virtual bool getRangeValue(const std::string& key, std::string& value) { + (void)key; + (void)value; throw std::runtime_error("range-based lookups are not implemented for this Key-Value Store"); } virtual bool reload() diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.cc b/pdns/dnsdistdist/dnsdist-lbpolicies.cc index 337a062669d8..f4b1d697ecab 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.cc +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.cc @@ -55,6 +55,7 @@ template static std::shared_ptr getLeastOutstanding(c // get server with least outstanding queries, and within those, with the lowest order, and within those: the fastest shared_ptr leastOutstanding(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq) { + (void)dq; using LeastOutstandingType = std::tuple; if (servers.size() == 1 && servers[0].second->isUp()) { @@ -150,6 +151,7 @@ static shared_ptr valrandom(const unsigned int val, const Serve shared_ptr wrandom(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq) { + (void)dq; return valrandom(dns_random_uint32(), servers); } @@ -230,6 +232,7 @@ shared_ptr chashed(const ServerPolicy::NumberedServerVector& se shared_ptr roundrobin(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq) { + (void)dq; if (servers.empty()) { return shared_ptr(); } diff --git a/pdns/dnsdistdist/dnsdist-lua-actions.cc b/pdns/dnsdistdist/dnsdist-lua-actions.cc index e4f730d77cab..cc7e7b691f3f 100644 --- a/pdns/dnsdistdist/dnsdist-lua-actions.cc +++ b/pdns/dnsdistdist/dnsdist-lua-actions.cc @@ -52,6 +52,8 @@ class DropAction : public DNSAction public: DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)dnsquestion; + (void)ruleresult; return Action::Drop; } [[nodiscard]] std::string toString() const override @@ -65,6 +67,8 @@ class AllowAction : public DNSAction public: DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)dnsquestion; + (void)ruleresult; return Action::Allow; } [[nodiscard]] std::string toString() const override @@ -79,6 +83,8 @@ class NoneAction : public DNSAction // this action does not stop the processing DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)dnsquestion; + (void)ruleresult; return Action::None; } [[nodiscard]] std::string toString() const override @@ -96,6 +102,8 @@ class QPSAction : public DNSAction } DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)dnsquestion; + (void)ruleresult; if (d_qps.lock()->check()) { return Action::None; } @@ -119,6 +127,7 @@ class DelayAction : public DNSAction } DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)dnsquestion; *ruleresult = std::to_string(d_msec); return Action::Delay; } @@ -190,6 +199,7 @@ TeeAction::~TeeAction() DNSAction::Action TeeAction::operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const { + (void)ruleresult; if (dnsquestion->overTCP()) { d_tcpdrops++; return DNSAction::Action::None; @@ -372,6 +382,7 @@ class RCodeAction : public DNSAction d_rcode(rcode) {} DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsdist::PacketMangling::editDNSHeaderFromPacket(dnsquestion->getMutableData(), [this](dnsheader& header) { header.rcode = d_rcode; header.qr = true; // for good measure @@ -401,6 +412,7 @@ class ERCodeAction : public DNSAction d_rcode(rcode) {} DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsdist::PacketMangling::editDNSHeaderFromPacket(dnsquestion->getMutableData(), [this](dnsheader& header) { header.rcode = (d_rcode & 0xF); header.qr = true; // for good measure @@ -451,6 +463,7 @@ class SpoofSVCAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; if (!dnsdist::svc::generateSVCResponse(*dnsquestion, d_payloads, d_additionals4, d_additionals6, d_responseConfig)) { return Action::None; } @@ -480,6 +493,8 @@ class TCAction : public DNSAction public: DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)dnsquestion; + (void)ruleresult; return Action::Truncate; } [[nodiscard]] std::string toString() const override @@ -493,6 +508,8 @@ class TCResponseAction : public DNSResponseAction public: DNSResponseAction::Action operator()(DNSResponse* dnsResponse, std::string* ruleresult) const override { + (void)dnsResponse; + (void)ruleresult; return Action::Truncate; } [[nodiscard]] std::string toString() const override @@ -845,6 +862,7 @@ thread_local std::default_random_engine SpoofAction::t_randomEngine; DNSAction::Action SpoofAction::operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const { + (void)ruleresult; uint16_t qtype = dnsquestion->ids.qtype; // do we even have a response? if (d_cname.empty() && d_rawResponses.empty() && @@ -1025,6 +1043,7 @@ class SetMacAddrAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsdist::MacAddress mac{}; int res = dnsdist::MacAddressesCache::get(dnsquestion->ids.origRemote, mac.data(), mac.size()); if (res != 0) { @@ -1089,6 +1108,7 @@ class SetEDNSOptionAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; setEDNSOption(*dnsquestion, d_code, d_data); return Action::None; } @@ -1109,6 +1129,7 @@ class SetNoRecurseAction : public DNSAction // this action does not stop the processing DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsdist::PacketMangling::editDNSHeaderFromPacket(dnsquestion->getMutableData(), [](dnsheader& header) { header.rd = false; return true; @@ -1141,6 +1162,7 @@ class LogAction : public DNSAction, public boost::noncopyable DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; auto filepointer = std::atomic_load_explicit(&d_fp, std::memory_order_acquire); if (!filepointer) { if (!d_verboseOnly || dnsdist::configuration::getCurrentRuntimeConfiguration().d_verbose) { @@ -1253,6 +1275,7 @@ class LogResponseAction : public DNSResponseAction, public boost::noncopyable DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; auto filepointer = std::atomic_load_explicit(&d_fp, std::memory_order_acquire); if (!filepointer) { if (!d_verboseOnly || dnsdist::configuration::getCurrentRuntimeConfiguration().d_verbose) { @@ -1328,6 +1351,7 @@ class SetDisableValidationAction : public DNSAction // this action does not stop the processing DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsdist::PacketMangling::editDNSHeaderFromPacket(dnsquestion->getMutableData(), [](dnsheader& header) { header.cd = true; return true; @@ -1346,6 +1370,7 @@ class SetSkipCacheAction : public DNSAction // this action does not stop the processing DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsquestion->ids.skipCache = true; return Action::None; } @@ -1360,6 +1385,7 @@ class SetSkipCacheResponseAction : public DNSResponseAction public: DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; response->ids.skipCache = true; return Action::None; } @@ -1379,6 +1405,7 @@ class SetTempFailureCacheTTLAction : public DNSAction } DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsquestion->ids.tempFailureTTL = d_ttl; return Action::None; } @@ -1401,6 +1428,7 @@ class SetECSPrefixLengthAction : public DNSAction } DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsquestion->ecsPrefixLength = dnsquestion->ids.origRemote.sin4.sin_family == AF_INET ? d_v4PrefixLength : d_v6PrefixLength; return Action::None; } @@ -1424,6 +1452,7 @@ class SetECSOverrideAction : public DNSAction } DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsquestion->ecsOverride = d_ecsOverride; return Action::None; } @@ -1442,6 +1471,7 @@ class SetDisableECSAction : public DNSAction // this action does not stop the processing DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsquestion->useECS = false; return Action::None; } @@ -1467,6 +1497,7 @@ class SetECSAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; if (d_hasV6) { dnsquestion->ecs = std::make_unique(dnsquestion->ids.origRemote.isIPv4() ? d_v4 : d_v6); } @@ -1551,6 +1582,7 @@ class DnstapLogAction : public DNSAction, public boost::noncopyable { static thread_local std::string data; data.clear(); + (void)ruleresult; DnstapMessage::ProtocolType protocol = ProtocolToDNSTap(dnsquestion->getProtocol()); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) @@ -1650,6 +1682,7 @@ class RemoteLogAction : public DNSAction, public boost::noncopyable DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; if (!dnsquestion->ids.d_protoBufData) { dnsquestion->ids.d_protoBufData = std::make_unique(); } @@ -1712,6 +1745,7 @@ class SNMPTrapAction : public DNSAction } DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; if (g_snmpAgent != nullptr && dnsdist::configuration::getCurrentRuntimeConfiguration().d_snmpTrapsEnabled) { g_snmpAgent->sendDNSTrap(*dnsquestion, d_reason); } @@ -1737,6 +1771,7 @@ class SetTagAction : public DNSAction } DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsquestion->setTag(d_tag, d_value); return Action::None; @@ -1762,6 +1797,7 @@ class DnstapLogResponseAction : public DNSResponseAction, public boost::noncopya } DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; static thread_local std::string data; struct timespec now = {}; gettime(&now, true); @@ -1803,6 +1839,7 @@ class RemoteLogResponseAction : public DNSResponseAction, public boost::noncopya } DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; if (!response->ids.d_protoBufData) { response->ids.d_protoBufData = std::make_unique(); } @@ -1866,6 +1903,8 @@ class DropResponseAction : public DNSResponseAction public: DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)response; + (void)ruleresult; return Action::Drop; } [[nodiscard]] std::string toString() const override @@ -1879,6 +1918,8 @@ class AllowResponseAction : public DNSResponseAction public: DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)response; + (void)ruleresult; return Action::Allow; } [[nodiscard]] std::string toString() const override @@ -1896,6 +1937,7 @@ class DelayResponseAction : public DNSResponseAction } DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)response; *ruleresult = std::to_string(d_msec); return Action::Delay; } @@ -1919,6 +1961,7 @@ class SNMPTrapResponseAction : public DNSResponseAction } DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; if (g_snmpAgent != nullptr && dnsdist::configuration::getCurrentRuntimeConfiguration().d_snmpTrapsEnabled) { g_snmpAgent->sendDNSTrap(*response, d_reason); } @@ -1945,6 +1988,7 @@ class SetTagResponseAction : public DNSResponseAction } DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; response->setTag(d_tag, d_value); return Action::None; @@ -1969,6 +2013,7 @@ class ClearRecordTypesResponseAction : public DNSResponseAction, public boost::n DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; if (!d_qtypes.empty()) { clearDNSPacketRecordTypes(response->getMutableData(), d_qtypes); } @@ -2030,6 +2075,7 @@ class HTTPStatusAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; if (!dnsquestion->ids.du) { return Action::None; } @@ -2073,6 +2119,7 @@ class KeyValueStoreLookupAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; std::vector keys = d_key->getKeys(*dnsquestion); std::string result; for (const auto& key : keys) { @@ -2108,6 +2155,7 @@ class KeyValueStoreRangeLookupAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; std::vector keys = d_key->getKeys(*dnsquestion); std::string result; for (const auto& key : keys) { @@ -2143,6 +2191,7 @@ class MaxReturnedTTLAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; dnsquestion->ids.ttlCap = d_cap; return DNSAction::Action::None; } @@ -2166,6 +2215,7 @@ class MaxReturnedTTLResponseAction : public DNSResponseAction DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; response->ids.ttlCap = d_cap; return DNSResponseAction::Action::None; } @@ -2198,6 +2248,7 @@ class NegativeAndSOAAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; if (!setNegativeAndAdditionalSOA(*dnsquestion, d_nxd, d_zone, d_ttl, d_mname, d_rname, d_params.serial, d_params.refresh, d_params.retry, d_params.expire, d_params.minimum, d_soaInAuthoritySection)) { return Action::None; } @@ -2245,6 +2296,7 @@ class SetProxyProtocolValuesAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; if (!dnsquestion->proxyProtocolValues) { dnsquestion->proxyProtocolValues = make_unique>(); } @@ -2274,6 +2326,7 @@ class SetAdditionalProxyProtocolValueAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsquestion, std::string* ruleresult) const override { + (void)ruleresult; if (!dnsquestion->proxyProtocolValues) { dnsquestion->proxyProtocolValues = make_unique>(); } @@ -2304,8 +2357,12 @@ class SetReducedTTLResponseAction : public DNSResponseAction, public boost::nonc DNSResponseAction::Action operator()(DNSResponse* response, std::string* ruleresult) const override { + (void)ruleresult; // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) auto visitor = [&](uint8_t section, uint16_t qclass, uint16_t qtype, uint32_t ttl) { + (void)section; + (void)qclass; + (void)qtype; return ttl * d_ratio; }; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) @@ -2334,6 +2391,7 @@ class SetExtendedDNSErrorAction : public DNSAction DNSAction::Action operator()(DNSQuestion* dnsQuestion, std::string* ruleresult) const override { + (void)ruleresult; dnsQuestion->ids.d_extendedError = std::make_unique(d_ede); return DNSAction::Action::None; @@ -2360,6 +2418,7 @@ class SetExtendedDNSErrorResponseAction : public DNSResponseAction DNSResponseAction::Action operator()(DNSResponse* dnsResponse, std::string* ruleresult) const override { + (void)ruleresult; dnsResponse->ids.d_extendedError = std::make_unique(d_ede); return DNSResponseAction::Action::None; diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-dnscrypt.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-dnscrypt.cc index 65eba9e32b8a..5d5573aae085 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-dnscrypt.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-dnscrypt.cc @@ -26,7 +26,7 @@ #include "dolog.hh" -void setupLuaBindingsDNSCrypt(LuaContext& luaCtx, bool client) +void setupLuaBindingsDNSCrypt([[maybe_unused]] LuaContext& luaCtx, [[maybe_unused]] bool client) { #ifdef HAVE_DNSCRYPT /* DNSCryptContext bindings */ diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc index bf6c47361c9e..e15a1532ee90 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc @@ -29,19 +29,19 @@ #include "dnsparser.hh" // NOLINTNEXTLINE(readability-function-cognitive-complexity): this function declares Lua bindings, even with a good refactoring it will likely blow up the threshold -void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) +void setupLuaBindingsDNSQuestion([[maybe_unused]] LuaContext& luaCtx) { #ifndef DISABLE_NON_FFI_DQ_BINDINGS /* DNSQuestion */ /* PowerDNS DNSQuestion compat */ luaCtx.registerMember( - "localaddr", [](const DNSQuestion& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origDest; }, [](DNSQuestion& dnsQuestion, const ComboAddress newLocal) { (void)newLocal; }); + "localaddr", [](const DNSQuestion& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origDest; }, [](DNSQuestion& dnsQuestion, const ComboAddress newLocal) { (void)dnsQuestion; (void)newLocal; }); luaCtx.registerMember( - "qname", [](const DNSQuestion& dnsQuestion) -> DNSName { return dnsQuestion.ids.qname; }, [](DNSQuestion& dnsQuestion, const DNSName& newName) { (void)newName; }); + "qname", [](const DNSQuestion& dnsQuestion) -> DNSName { return dnsQuestion.ids.qname; }, [](DNSQuestion& dnsQuestion, const DNSName& newName) { (void)dnsQuestion; (void)newName; }); luaCtx.registerMember( - "qtype", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qtype; }, [](DNSQuestion& dnsQuestion, uint16_t newType) { (void)newType; }); + "qtype", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qtype; }, [](DNSQuestion& dnsQuestion, uint16_t newType) { (void)dnsQuestion; (void)newType; }); luaCtx.registerMember( - "qclass", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qclass; }, [](DNSQuestion& dnsQuestion, uint16_t newClass) { (void)newClass; }); + "qclass", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qclass; }, [](DNSQuestion& dnsQuestion, uint16_t newClass) { (void)dnsQuestion; (void)newClass; }); luaCtx.registerMember( "rcode", [](const DNSQuestion& dnsQuestion) -> int { @@ -54,7 +54,7 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) }); }); luaCtx.registerMember( - "remoteaddr", [](const DNSQuestion& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origRemote; }, [](DNSQuestion& dnsQuestion, const ComboAddress newRemote) { (void)newRemote; }); + "remoteaddr", [](const DNSQuestion& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origRemote; }, [](DNSQuestion& dnsQuestion, const ComboAddress newRemote) { (void)dnsQuestion; (void)newRemote; }); /* DNSDist DNSQuestion */ luaCtx.registerMember( "dh", @@ -70,9 +70,9 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) luaCtx.registerMember( "len", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.getData().size(); }, [](DNSQuestion& dnsQuestion, uint16_t newlen) { dnsQuestion.getMutableData().resize(newlen); }); luaCtx.registerMember( - "opcode", [](const DNSQuestion& dnsQuestion) -> uint8_t { return dnsQuestion.getHeader()->opcode; }, [](DNSQuestion& dnsQuestion, uint8_t newOpcode) { (void)newOpcode; }); + "opcode", [](const DNSQuestion& dnsQuestion) -> uint8_t { return dnsQuestion.getHeader()->opcode; }, [](DNSQuestion& dnsQuestion, uint8_t newOpcode) { (void)dnsQuestion; (void)newOpcode; }); luaCtx.registerMember( - "tcp", [](const DNSQuestion& dnsQuestion) -> bool { return dnsQuestion.overTCP(); }, [](DNSQuestion& dnsQuestion, bool newTcp) { (void)newTcp; }); + "tcp", [](const DNSQuestion& dnsQuestion) -> bool { return dnsQuestion.overTCP(); }, [](DNSQuestion& dnsQuestion, bool newTcp) { (void)dnsQuestion; (void)newTcp; }); luaCtx.registerMember( "skipCache", [](const DNSQuestion& dnsQuestion) -> bool { return dnsQuestion.ids.skipCache; }, [](DNSQuestion& dnsQuestion, bool newSkipCache) { dnsQuestion.ids.skipCache = newSkipCache; }); luaCtx.registerMember( @@ -168,7 +168,7 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) return dnsQuestion.ids.queryRealTime.getStartTime(); }); - luaCtx.registerFunction("sendTrap", [](const DNSQuestion& dnsQuestion, boost::optional reason) { + luaCtx.registerFunction("sendTrap", []([[maybe_unused]] const DNSQuestion& dnsQuestion, [[maybe_unused]] boost::optional reason) { #ifdef HAVE_NET_SNMP if (g_snmpAgent != nullptr && dnsdist::configuration::getCurrentRuntimeConfiguration().d_snmpTrapsEnabled) { g_snmpAgent->sendDNSTrap(dnsQuestion, reason ? *reason : ""); @@ -377,13 +377,13 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) /* LuaWrapper doesn't support inheritance */ luaCtx.registerMember( - "localaddr", [](const DNSResponse& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origDest; }, [](DNSResponse& dnsQuestion, const ComboAddress newLocal) { (void)newLocal; }); + "localaddr", [](const DNSResponse& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origDest; }, [](DNSResponse& dnsQuestion, const ComboAddress newLocal) { (void)dnsQuestion; (void)newLocal; }); luaCtx.registerMember( - "qname", [](const DNSResponse& dnsQuestion) -> DNSName { return dnsQuestion.ids.qname; }, [](DNSResponse& dnsQuestion, const DNSName& newName) { (void)newName; }); + "qname", [](const DNSResponse& dnsQuestion) -> DNSName { return dnsQuestion.ids.qname; }, [](DNSResponse& dnsQuestion, const DNSName& newName) { (void)dnsQuestion; (void)newName; }); luaCtx.registerMember( - "qtype", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qtype; }, [](DNSResponse& dnsQuestion, uint16_t newType) { (void)newType; }); + "qtype", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qtype; }, [](DNSResponse& dnsQuestion, uint16_t newType) { (void)dnsQuestion; (void)newType; }); luaCtx.registerMember( - "qclass", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qclass; }, [](DNSResponse& dnsQuestion, uint16_t newClass) { (void)newClass; }); + "qclass", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qclass; }, [](DNSResponse& dnsQuestion, uint16_t newClass) { (void)dnsQuestion; (void)newClass; }); luaCtx.registerMember( "rcode", [](const DNSResponse& dnsQuestion) -> int { @@ -396,7 +396,7 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) }); }); luaCtx.registerMember( - "remoteaddr", [](const DNSResponse& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origRemote; }, [](DNSResponse& dnsQuestion, const ComboAddress newRemote) { (void)newRemote; }); + "remoteaddr", [](const DNSResponse& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origRemote; }, [](DNSResponse& dnsQuestion, const ComboAddress newRemote) { (void)dnsQuestion; (void)newRemote; }); luaCtx.registerMember( "dh", [](const DNSResponse& dnsResponse) -> dnsheader* { @@ -411,9 +411,9 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) luaCtx.registerMember( "len", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.getData().size(); }, [](DNSResponse& dnsQuestion, uint16_t newlen) { dnsQuestion.getMutableData().resize(newlen); }); luaCtx.registerMember( - "opcode", [](const DNSResponse& dnsQuestion) -> uint8_t { return dnsQuestion.getHeader()->opcode; }, [](DNSResponse& dnsQuestion, uint8_t newOpcode) { (void)newOpcode; }); + "opcode", [](const DNSResponse& dnsQuestion) -> uint8_t { return dnsQuestion.getHeader()->opcode; }, [](DNSResponse& dnsQuestion, uint8_t newOpcode) { (void)dnsQuestion; (void)newOpcode; }); luaCtx.registerMember( - "tcp", [](const DNSResponse& dnsQuestion) -> bool { return dnsQuestion.overTCP(); }, [](DNSResponse& dnsQuestion, bool newTcp) { (void)newTcp; }); + "tcp", [](const DNSResponse& dnsQuestion) -> bool { return dnsQuestion.overTCP(); }, [](DNSResponse& dnsQuestion, bool newTcp) { (void)dnsQuestion; (void)newTcp; }); luaCtx.registerMember( "skipCache", [](const DNSResponse& dnsQuestion) -> bool { return dnsQuestion.ids.skipCache; }, [](DNSResponse& dnsQuestion, bool newSkipCache) { dnsQuestion.ids.skipCache = newSkipCache; }); luaCtx.registerMember( @@ -495,7 +495,7 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) return dnsResponse.ids.queryRealTime.getStartTime(); }); - luaCtx.registerFunction("sendTrap", [](const DNSResponse& dnsResponse, boost::optional reason) { + luaCtx.registerFunction("sendTrap", []([[maybe_unused]] const DNSResponse& dnsResponse, [[maybe_unused]] boost::optional reason) { #ifdef HAVE_NET_SNMP if (g_snmpAgent != nullptr && dnsdist::configuration::getCurrentRuntimeConfiguration().d_snmpTrapsEnabled) { g_snmpAgent->sendDNSTrap(dnsResponse, reason ? *reason : ""); diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc index e532a568280f..8235f48af91c 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc @@ -128,7 +128,7 @@ void setupLuaBindingsProtoBuf(LuaContext& luaCtx, bool client, bool configCheck) return std::shared_ptr(new RemoteLogger(ComboAddress(remote), timeout ? *timeout : 2, maxQueuedEntries ? (*maxQueuedEntries*100) : 10000, reconnectWaitTime ? *reconnectWaitTime : 1, client)); }); - luaCtx.writeFunction("newFrameStreamUnixLogger", [client,configCheck](const std::string& address, boost::optional> params) { + luaCtx.writeFunction("newFrameStreamUnixLogger", [client,configCheck]([[maybe_unused]] const std::string& address, [[maybe_unused]] boost::optional> params) { #ifdef HAVE_FSTRM if (client || configCheck) { return std::shared_ptr(nullptr); @@ -143,7 +143,7 @@ void setupLuaBindingsProtoBuf(LuaContext& luaCtx, bool client, bool configCheck) #endif /* HAVE_FSTRM */ }); - luaCtx.writeFunction("newFrameStreamTcpLogger", [client,configCheck](const std::string& address, boost::optional> params) { + luaCtx.writeFunction("newFrameStreamTcpLogger", [client,configCheck]([[maybe_unused]] const std::string& address, [[maybe_unused]] boost::optional> params) { #if defined(HAVE_FSTRM) && defined(HAVE_FSTRM_TCP_WRITER_INIT) if (client || configCheck) { return std::shared_ptr(nullptr); diff --git a/pdns/dnsdistdist/dnsdist-lua-ffi.cc b/pdns/dnsdistdist/dnsdist-lua-ffi.cc index 192e8f1cfd10..646352450d4c 100644 --- a/pdns/dnsdistdist/dnsdist-lua-ffi.cc +++ b/pdns/dnsdistdist/dnsdist-lua-ffi.cc @@ -402,7 +402,7 @@ size_t dnsdist_ffi_dnsquestion_get_edns_options(dnsdist_ffi_dnsquestion_t* dq, c return totalCount; } -size_t dnsdist_ffi_dnsquestion_get_http_headers(dnsdist_ffi_dnsquestion_t* dq, const dnsdist_ffi_http_header_t** out) +size_t dnsdist_ffi_dnsquestion_get_http_headers(dnsdist_ffi_dnsquestion_t* dq, [[maybe_unused]] const dnsdist_ffi_http_header_t** out) { if (dq->dq->ids.du == nullptr) { return 0; @@ -469,7 +469,7 @@ void dnsdist_ffi_dnsquestion_set_result(dnsdist_ffi_dnsquestion_t* dq, const cha dq->result = std::string(str, strSize); } -void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* dq, uint16_t statusCode, const char* body, size_t bodyLen, const char* contentType) +void dnsdist_ffi_dnsquestion_set_http_response(dnsdist_ffi_dnsquestion_t* dq, [[maybe_unused]] uint16_t statusCode, [[maybe_unused]] const char* body, [[maybe_unused]] size_t bodyLen, [[maybe_unused]] const char* contentType) { if (dq->dq->ids.du == nullptr) { return; @@ -693,12 +693,14 @@ static size_t dnsdist_ffi_servers_get_index_from_server(const ServerPolicy::Numb size_t dnsdist_ffi_servers_list_chashed(const dnsdist_ffi_servers_list_t* list, const dnsdist_ffi_dnsquestion_t* dq, size_t hash) { + (void)dq; auto server = chashedFromHash(list->servers, hash); return dnsdist_ffi_servers_get_index_from_server(list->servers, server); } size_t dnsdist_ffi_servers_list_whashed(const dnsdist_ffi_servers_list_t* list, const dnsdist_ffi_dnsquestion_t* dq, size_t hash) { + (void)dq; auto server = whashedFromHash(list->servers, hash); return dnsdist_ffi_servers_get_index_from_server(list->servers, server); } @@ -1843,6 +1845,7 @@ void dnsdist_ffi_metric_set(const char* metricName, size_t metricNameLen, double double dnsdist_ffi_metric_get(const char* metricName, size_t metricNameLen, bool isCounter) { + (void)isCounter; auto result = dnsdist::metrics::getCustomMetric(std::string_view(metricName, metricNameLen)); if (std::get_if(&result) != nullptr) { return 0.; diff --git a/pdns/dnsdistdist/dnsdist-lua-hooks.cc b/pdns/dnsdistdist/dnsdist-lua-hooks.cc index 2904cd37926a..4fa41fee839e 100644 --- a/pdns/dnsdistdist/dnsdist-lua-hooks.cc +++ b/pdns/dnsdistdist/dnsdist-lua-hooks.cc @@ -32,6 +32,7 @@ void clearMaintenanceHooks() static void setTicketsKeyAddedHook(const LuaContext& context, const TicketsKeyAddedHook& hook) { + (void)context; TLSCtx::setTicketsKeyAddedHook([hook](const std::string& key) { try { auto lua = g_lua.lock(); diff --git a/pdns/dnsdistdist/dnsdist-lua-inspection.cc b/pdns/dnsdistdist/dnsdist-lua-inspection.cc index 2ad3999f7c2e..d0025d0c246d 100644 --- a/pdns/dnsdistdist/dnsdist-lua-inspection.cc +++ b/pdns/dnsdistdist/dnsdist-lua-inspection.cc @@ -1076,9 +1076,9 @@ void setupLuaInspection(LuaContext& luaCtx) nowRealTime.tv_nsec -= 1000000000; } - return nowRealTime; }, [](DynBlock& block, [[maybe_unused]] timespec until) {}); + return nowRealTime; }, []([[maybe_unused]] DynBlock& block, [[maybe_unused]] timespec until) {}); luaCtx.registerMember( - "blocks", [](const DynBlock& block) { return block.blocks.load(); }, [](DynBlock& block, [[maybe_unused]] unsigned int blocks) {}); + "blocks", [](const DynBlock& block) { return block.blocks.load(); }, []([[maybe_unused]] DynBlock& block, [[maybe_unused]] unsigned int blocks) {}); luaCtx.registerMember("action", &DynBlock::action); luaCtx.registerMember("warning", &DynBlock::warning); luaCtx.registerMember("bpf", &DynBlock::bpf); diff --git a/pdns/dnsdistdist/dnsdist-lua-web.cc b/pdns/dnsdistdist/dnsdist-lua-web.cc index cd7e47f91ed7..a8b169b11954 100644 --- a/pdns/dnsdistdist/dnsdist-lua-web.cc +++ b/pdns/dnsdistdist/dnsdist-lua-web.cc @@ -30,7 +30,7 @@ namespace dnsdist::webserver void registerWebHandler(const std::string& endpoint, std::function handler, bool isLua); } -void setupLuaWeb(LuaContext& luaCtx) +void setupLuaWeb([[maybe_unused]] LuaContext& luaCtx) { #ifndef DISABLE_LUA_WEB_HANDLERS luaCtx.writeFunction("registerWebHandler", [](const std::string& path, std::function handler) { @@ -38,31 +38,31 @@ void setupLuaWeb(LuaContext& luaCtx) dnsdist::webserver::registerWebHandler(path, [handler](const YaHTTP::Request& req, YaHTTP::Response& resp) { handler(&req, &resp); }, true); }); - luaCtx.registerMember("path", [](const YaHTTP::Request& req) -> std::string { return req.url.path; }, [](YaHTTP::Request& req, const std::string& path) { (void) path; }); - luaCtx.registerMember("version", [](const YaHTTP::Request& req) -> int { return req.version; }, [](YaHTTP::Request& req, int version) { (void) version; }); - luaCtx.registerMember("method", [](const YaHTTP::Request& req) -> std::string { return req.method; }, [](YaHTTP::Request& req, const std::string& method) { (void) method; }); - luaCtx.registerMember("body", [](const YaHTTP::Request& req) -> const std::string { return req.body; }, [](YaHTTP::Request& req, const std::string& body) { (void) body; }); + luaCtx.registerMember("path", [](const YaHTTP::Request& req) -> std::string { return req.url.path; }, [](YaHTTP::Request& req, const std::string& path) { (void)req; (void) path; }); + luaCtx.registerMember("version", [](const YaHTTP::Request& req) -> int { return req.version; }, [](YaHTTP::Request& req, int version) { (void)req; (void)version; }); + luaCtx.registerMember("method", [](const YaHTTP::Request& req) -> std::string { return req.method; }, [](YaHTTP::Request& req, const std::string& method) { (void)req; (void) method; }); + luaCtx.registerMember("body", [](const YaHTTP::Request& req) -> const std::string { return req.body; }, [](YaHTTP::Request& req, const std::string& body) { (void)req; (void)body; }); luaCtx.registerMember(YaHTTP::Request::*)>("getvars", [](const YaHTTP::Request& req) { LuaAssociativeTable values; for (const auto& entry : req.getvars) { values.insert({entry.first, entry.second}); } return values; - }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void) values; }); + }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void)req; (void)values; }); luaCtx.registerMember(YaHTTP::Request::*)>("postvars", [](const YaHTTP::Request& req) { LuaAssociativeTable values; for (const auto& entry : req.postvars) { values.insert({entry.first, entry.second}); } return values; - }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void) values; }); + }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void)req; (void)values; }); luaCtx.registerMember(YaHTTP::Request::*)>("headers", [](const YaHTTP::Request& req) { LuaAssociativeTable values; for (const auto& entry : req.headers) { values.insert({entry.first, entry.second}); } return values; - }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void) values; }); + }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void)req; (void)values; }); /* Response */ luaCtx.registerMember("body", [](const YaHTTP::Response& resp) -> const std::string { return resp.body; }, [](YaHTTP::Response& resp, const std::string& body) { resp.body = body; }); diff --git a/pdns/dnsdistdist/dnsdist-lua.cc b/pdns/dnsdistdist/dnsdist-lua.cc index 43adf2066cd1..d3bab06b494d 100644 --- a/pdns/dnsdistdist/dnsdist-lua.cc +++ b/pdns/dnsdistdist/dnsdist-lua.cc @@ -2413,7 +2413,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) }); typedef std::unordered_map tlscertificateopts_t; - luaCtx.writeFunction("newTLSCertificate", [client](const std::string& cert, boost::optional opts) { + luaCtx.writeFunction("newTLSCertificate", [client]([[maybe_unused]] const std::string& cert, [[maybe_unused]] boost::optional opts) { std::shared_ptr result = nullptr; if (client) { return result; @@ -2434,7 +2434,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) return result; }); - luaCtx.writeFunction("addDOHLocal", [client](const std::string& addr, boost::optional, LuaArray, LuaArray>>> certFiles, boost::optional> keyFiles, boost::optional> urls, boost::optional vars) { + luaCtx.writeFunction("addDOHLocal", [client]([[maybe_unused]] const std::string& addr, [[maybe_unused]] boost::optional, LuaArray, LuaArray>>> certFiles, [[maybe_unused]] boost::optional> keyFiles, [[maybe_unused]] boost::optional> urls, [[maybe_unused]] boost::optional vars) { if (client) { return; } @@ -2602,7 +2602,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) }); // NOLINTNEXTLINE(performance-unnecessary-value-param): somehow clang-tidy gets confused about the fact vars could be const while it cannot - luaCtx.writeFunction("addDOH3Local", [client](const std::string& addr, const boost::variant, LuaArray, LuaArray>>& certFiles, const LuaTypeOrArrayOf& keyFiles, boost::optional vars) { + luaCtx.writeFunction("addDOH3Local", [client]([[maybe_unused]] const std::string& addr, [[maybe_unused]] const boost::variant, LuaArray, LuaArray>>& certFiles, [[maybe_unused]] const LuaTypeOrArrayOf& keyFiles, [[maybe_unused]] boost::optional vars) { if (client) { return; } @@ -2679,7 +2679,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) }); // NOLINTNEXTLINE(performance-unnecessary-value-param): somehow clang-tidy gets confused about the fact vars could be const while it cannot - luaCtx.writeFunction("addDOQLocal", [client](const std::string& addr, const boost::variant, LuaArray, LuaArray>>& certFiles, const LuaTypeOrArrayOf& keyFiles, boost::optional vars) { + luaCtx.writeFunction("addDOQLocal", [client]([[maybe_unused]] const std::string& addr, [[maybe_unused]] const boost::variant, LuaArray, LuaArray>>& certFiles, [[maybe_unused]] const LuaTypeOrArrayOf& keyFiles, [[maybe_unused]] boost::optional vars) { if (client) { return; } @@ -2930,7 +2930,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) #endif }); - luaCtx.writeFunction("getDOHFrontend", [client](uint64_t index) { + luaCtx.writeFunction("getDOHFrontend", [client]([[maybe_unused]] uint64_t index) { std::shared_ptr result = nullptr; if (client) { return result; @@ -2968,7 +2968,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) } }); - luaCtx.registerFunction::*)(boost::variant, LuaArray, LuaArray>> certFiles, LuaTypeOrArrayOf keyFiles)>("loadNewCertificatesAndKeys", [](const std::shared_ptr& frontend, const boost::variant, LuaArray, LuaArray>>& certFiles, const LuaTypeOrArrayOf& keyFiles) { + luaCtx.registerFunction::*)(boost::variant, LuaArray, LuaArray>> certFiles, LuaTypeOrArrayOf keyFiles)>("loadNewCertificatesAndKeys", []([[maybe_unused]] const std::shared_ptr& frontend, [[maybe_unused]] const boost::variant, LuaArray, LuaArray>>& certFiles, [[maybe_unused]] const LuaTypeOrArrayOf& keyFiles) { #ifdef HAVE_DNS_OVER_HTTPS if (frontend != nullptr) { if (loadTLSCertificateAndKeys("DOHFrontend::loadNewCertificatesAndKeys", frontend->d_tlsContext.d_tlsConfig.d_certKeyPairs, certFiles, keyFiles)) { @@ -3031,7 +3031,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) } }); - luaCtx.writeFunction("addTLSLocal", [client](const std::string& addr, const boost::variant, LuaArray, LuaArray>>& certFiles, const LuaTypeOrArrayOf& keyFiles, boost::optional vars) { + luaCtx.writeFunction("addTLSLocal", [client]([[maybe_unused]] const std::string& addr, [[maybe_unused]] const boost::variant, LuaArray, LuaArray>>& certFiles, [[maybe_unused]] const LuaTypeOrArrayOf& keyFiles, [[maybe_unused]] boost::optional vars) { if (client) { return; } @@ -3159,7 +3159,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) #endif }); - luaCtx.writeFunction("getTLSContext", [](uint64_t index) { + luaCtx.writeFunction("getTLSContext", []([[maybe_unused]] uint64_t index) { std::shared_ptr result = nullptr; #ifdef HAVE_DNS_OVER_TLS setLuaNoSideEffect(); @@ -3183,7 +3183,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) return result; }); - luaCtx.writeFunction("getTLSFrontend", [](uint64_t index) { + luaCtx.writeFunction("getTLSFrontend", []([[maybe_unused]] uint64_t index) { std::shared_ptr result = nullptr; #ifdef HAVE_DNS_OVER_TLS setLuaNoSideEffect(); @@ -3268,7 +3268,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) frontend->setupTLS(); }); - luaCtx.registerFunction::*)(const boost::variant, LuaArray, LuaArray>>&, const LuaTypeOrArrayOf&)>("loadNewCertificatesAndKeys", [](std::shared_ptr& frontend, const boost::variant, LuaArray, LuaArray>>& certFiles, const LuaTypeOrArrayOf& keyFiles) { + luaCtx.registerFunction::*)(const boost::variant, LuaArray, LuaArray>>&, const LuaTypeOrArrayOf&)>("loadNewCertificatesAndKeys", []([[maybe_unused]] std::shared_ptr& frontend, [[maybe_unused]] const boost::variant, LuaArray, LuaArray>>& certFiles, [[maybe_unused]] const LuaTypeOrArrayOf& keyFiles) { #ifdef HAVE_DNS_OVER_TLS if (loadTLSCertificateAndKeys("TLSFrontend::loadNewCertificatesAndKeys", frontend->d_tlsConfig.d_certKeyPairs, certFiles, keyFiles)) { frontend->setupTLS(); diff --git a/pdns/dnsdistdist/dnsdist-lua.hh b/pdns/dnsdistdist/dnsdist-lua.hh index e2be6dca1e80..1f4ded6c50bd 100644 --- a/pdns/dnsdistdist/dnsdist-lua.hh +++ b/pdns/dnsdistdist/dnsdist-lua.hh @@ -112,9 +112,9 @@ public: { } - DNSResponseAction::Action operator()(DNSResponse* dr, std::string* ruleresult) const override + DNSResponseAction::Action operator()(DNSResponse* dr, [[maybe_unused]] std::string* ruleresult) const override { - auto visitor = [&](uint8_t section, uint16_t qclass, uint16_t qtype, uint32_t ttl) { + auto visitor = [&]([[maybe_unused]] uint8_t section, uint16_t qclass, uint16_t qtype, uint32_t ttl) { if (!d_types.empty() && qclass == QClass::IN && d_types.count(qtype) == 0) { return ttl; } diff --git a/pdns/dnsdistdist/dnsdist-nghttp2-in.cc b/pdns/dnsdistdist/dnsdist-nghttp2-in.cc index 9907938dae43..c80da661fcfb 100644 --- a/pdns/dnsdistdist/dnsdist-nghttp2-in.cc +++ b/pdns/dnsdistdist/dnsdist-nghttp2-in.cc @@ -19,15 +19,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "dnsdist-nghttp2-in.hh" + +#if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2) #include "dnsdist-dnsparser.hh" #include "dnsdist-doh-common.hh" -#include "dnsdist-nghttp2-in.hh" #include "dnsdist-proxy-protocol.hh" #include "dnsparser.hh" -#if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2) - #if 0 class IncomingDoHCrossProtocolContext : public CrossProtocolContext { @@ -480,6 +480,8 @@ void IncomingHTTP2Connection::writeToSocket(bool socketReady) ssize_t IncomingHTTP2Connection::send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); if (conn->d_connectionDied) { return static_cast(length); @@ -550,6 +552,7 @@ void NGHTTP2Headers::addDynamicHeader(std::vector& headers, NGHTTP2H IOState IncomingHTTP2Connection::sendResponse(const struct timeval& now, TCPResponse&& response) { + (void)now; if (response.d_idstate.d_streamID == -1) { throw std::runtime_error("Invalid DoH stream ID while sending response"); } @@ -601,6 +604,7 @@ bool IncomingHTTP2Connection::sendResponse(IncomingHTTP2Connection::StreamID str data_provider.source.ptr = this; data_provider.read_callback = [](nghttp2_session*, IncomingHTTP2Connection::StreamID stream_id, uint8_t* buf, size_t length, uint32_t* data_flags, nghttp2_data_source* source, void* cb_data) -> ssize_t { + (void)source; auto* connection = static_cast(cb_data); auto& obj = connection->d_currentStreams.at(stream_id); size_t toCopy = 0; @@ -907,6 +911,7 @@ void IncomingHTTP2Connection::handleIncomingQuery(IncomingHTTP2Connection::Pendi int IncomingHTTP2Connection::on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; auto* conn = static_cast(user_data); /* is this the last frame for this stream? */ if ((frame->hd.type == NGHTTP2_HEADERS || frame->hd.type == NGHTTP2_DATA) && (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) != 0) { @@ -929,6 +934,8 @@ int IncomingHTTP2Connection::on_frame_recv_callback(nghttp2_session* session, co int IncomingHTTP2Connection::on_stream_close_callback(nghttp2_session* session, IncomingHTTP2Connection::StreamID stream_id, uint32_t error_code, void* user_data) { + (void)session; + (void)error_code; auto* conn = static_cast(user_data); conn->d_currentStreams.erase(stream_id); @@ -937,6 +944,7 @@ int IncomingHTTP2Connection::on_stream_close_callback(nghttp2_session* session, int IncomingHTTP2Connection::on_begin_headers_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; if (frame->hd.type != NGHTTP2_HEADERS || frame->headers.cat != NGHTTP2_HCAT_REQUEST) { return 0; } @@ -973,6 +981,8 @@ static std::string::size_type getLengthOfPathWithoutParameters(const std::string int IncomingHTTP2Connection::on_header_callback(nghttp2_session* session, const nghttp2_frame* frame, const uint8_t* name, size_t nameLen, const uint8_t* value, size_t valuelen, uint8_t flags, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); if (frame->hd.type == NGHTTP2_HEADERS && frame->headers.cat == NGHTTP2_HCAT_REQUEST) { @@ -981,7 +991,7 @@ int IncomingHTTP2Connection::on_header_callback(nghttp2_session* session, const return NGHTTP2_ERR_CALLBACK_FAILURE; } -#ifdef HAVE_NGHTTP2_CHECK_HEADER_VALUE_RFC9113 +#if defined(HAVE_NGHTTP2_CHECK_HEADER_VALUE_RFC9113) if (nghttp2_check_header_value_rfc9113(value, valuelen) == 0) { vinfolog("Invalid header value"); return NGHTTP2_ERR_CALLBACK_FAILURE; @@ -1001,7 +1011,7 @@ int IncomingHTTP2Connection::on_header_callback(nghttp2_session* session, const // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast): nghttp2 API auto valueView = std::string_view(reinterpret_cast(value), valuelen); if (headerMatches(s_pathHeaderName)) { -#ifdef HAVE_NGHTTP2_CHECK_PATH +#if defined(HAVE_NGHTTP2_CHECK_PATH) if (nghttp2_check_path(value, valuelen) == 0) { vinfolog("Invalid path value"); return NGHTTP2_ERR_CALLBACK_FAILURE; @@ -1021,7 +1031,7 @@ int IncomingHTTP2Connection::on_header_callback(nghttp2_session* session, const query.d_scheme = valueView; } else if (headerMatches(s_methodHeaderName)) { -#if HAVE_NGHTTP2_CHECK_METHOD +#if defined(HAVE_NGHTTP2_CHECK_METHOD) if (nghttp2_check_method(value, valuelen) == 0) { vinfolog("Invalid method value"); return NGHTTP2_ERR_CALLBACK_FAILURE; @@ -1054,6 +1064,8 @@ int IncomingHTTP2Connection::on_header_callback(nghttp2_session* session, const int IncomingHTTP2Connection::on_data_chunk_recv_callback(nghttp2_session* session, uint8_t flags, IncomingHTTP2Connection::StreamID stream_id, const uint8_t* data, size_t len, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); auto stream = conn->d_currentStreams.find(stream_id); if (stream == conn->d_currentStreams.end()) { @@ -1073,9 +1085,10 @@ int IncomingHTTP2Connection::on_data_chunk_recv_callback(nghttp2_session* sessio int IncomingHTTP2Connection::on_error_callback(nghttp2_session* session, int lib_error_code, const char* msg, size_t len, void* user_data) { + (void)session; auto* conn = static_cast(user_data); - vinfolog("Error in HTTP/2 connection from %d: %s", conn->d_ci.remote.toStringWithPort(), std::string(msg, len)); + vinfolog("Error in HTTP/2 connection from %s: %s (%d)", conn->d_ci.remote.toStringWithPort(), std::string(msg, len), lib_error_code); conn->d_connectionClosing = true; conn->d_needFlush = true; nghttp2_session_terminate_session(conn->d_session.get(), NGHTTP2_NO_ERROR); diff --git a/pdns/dnsdistdist/dnsdist-nghttp2.cc b/pdns/dnsdistdist/dnsdist-nghttp2.cc index e42ff741af75..03af2b5bba98 100644 --- a/pdns/dnsdistdist/dnsdist-nghttp2.cc +++ b/pdns/dnsdistdist/dnsdist-nghttp2.cc @@ -197,6 +197,7 @@ void DoHConnectionToBackend::handleIOError() void DoHConnectionToBackend::handleTimeout(const struct timeval& now, bool write) { + (void)now; if (write) { if (d_firstWrite) { ++d_ds->tcpConnectTimeouts; @@ -301,6 +302,8 @@ void DoHConnectionToBackend::queueQuery(std::shared_ptr& sender, data_provider.source.ptr = this; data_provider.read_callback = [](nghttp2_session* session, int32_t stream_id, uint8_t* buf, size_t length, uint32_t* data_flags, nghttp2_data_source* source, void* user_data) -> ssize_t { + (void)session; + (void)source; auto* conn = static_cast(user_data); auto& request = conn->d_currentStreams.at(stream_id); size_t toCopy = 0; @@ -513,6 +516,8 @@ void DoHConnectionToBackend::watchForRemoteHostClosingConnection() ssize_t DoHConnectionToBackend::send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data) { + (void)session; + (void)flags; DoHConnectionToBackend* conn = reinterpret_cast(user_data); bool bufferWasEmpty = conn->d_out.empty(); if (!conn->d_proxyProtocolPayloadSent && !conn->d_proxyProtocolPayload.empty()) { @@ -555,6 +560,7 @@ ssize_t DoHConnectionToBackend::send_callback(nghttp2_session* session, const ui int DoHConnectionToBackend::on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; DoHConnectionToBackend* conn = reinterpret_cast(user_data); // cerr<<"Frame type is "<hd.type)<(user_data); // cerr<<"Got data of size "<d_currentStreams.find(stream_id); @@ -676,6 +684,7 @@ int DoHConnectionToBackend::on_data_chunk_recv_callback(nghttp2_session* session int DoHConnectionToBackend::on_stream_close_callback(nghttp2_session* session, int32_t stream_id, uint32_t error_code, void* user_data) { + (void)session; DoHConnectionToBackend* conn = reinterpret_cast(user_data); if (error_code == 0) { @@ -724,6 +733,8 @@ int DoHConnectionToBackend::on_stream_close_callback(nghttp2_session* session, i int DoHConnectionToBackend::on_header_callback(nghttp2_session* session, const nghttp2_frame* frame, const uint8_t* name, size_t namelen, const uint8_t* value, size_t valuelen, uint8_t flags, void* user_data) { + (void)session; + (void)flags; DoHConnectionToBackend* conn = reinterpret_cast(user_data); const std::string status(":status"); @@ -754,7 +765,8 @@ int DoHConnectionToBackend::on_header_callback(nghttp2_session* session, const n int DoHConnectionToBackend::on_error_callback(nghttp2_session* session, int lib_error_code, const char* msg, size_t len, void* user_data) { - vinfolog("Error in HTTP/2 connection: %s", std::string(msg, len)); + (void)session; + vinfolog("Error in HTTP/2 connection: %s (%d)", std::string(msg, len), lib_error_code); DoHConnectionToBackend* conn = reinterpret_cast(user_data); conn->d_connectionDied = true; @@ -821,6 +833,7 @@ DoHConnectionToBackend::DoHConnectionToBackend(const std::shared_ptr(param); std::unique_ptr cpq{nullptr}; @@ -1032,7 +1045,7 @@ bool initDoHWorkers() #endif /* HAVE_DNS_OVER_HTTPS && HAVE_NGHTTP2 */ } -bool sendH2Query(const std::shared_ptr& ds, std::unique_ptr& mplexer, std::shared_ptr& sender, InternalQuery&& query, bool healthCheck) +bool sendH2Query([[maybe_unused]] const std::shared_ptr& ds, [[maybe_unused]] std::unique_ptr& mplexer, [[maybe_unused]] std::shared_ptr& sender, [[maybe_unused]] InternalQuery&& query, [[maybe_unused]] bool healthCheck) { #if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2) struct timeval now @@ -1067,7 +1080,7 @@ size_t clearH2Connections() return cleared; } -size_t handleH2Timeouts(FDMultiplexer& mplexer, const struct timeval& now) +size_t handleH2Timeouts([[maybe_unused]] FDMultiplexer& mplexer, [[maybe_unused]] const struct timeval& now) { size_t got = 0; #if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2) @@ -1094,21 +1107,21 @@ size_t handleH2Timeouts(FDMultiplexer& mplexer, const struct timeval& now) return got; } -void setDoHDownstreamCleanupInterval(uint16_t max) +void setDoHDownstreamCleanupInterval([[maybe_unused]] uint16_t max) { #if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2) DownstreamDoHConnectionsManager::setCleanupInterval(max); #endif /* HAVE_DNS_OVER_HTTPS && HAVE_NGHTTP2 */ } -void setDoHDownstreamMaxIdleTime(uint16_t max) +void setDoHDownstreamMaxIdleTime([[maybe_unused]] uint16_t max) { #if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2) DownstreamDoHConnectionsManager::setMaxIdleTime(max); #endif /* HAVE_DNS_OVER_HTTPS && HAVE_NGHTTP2 */ } -void setDoHDownstreamMaxIdleConnectionsPerBackend(size_t max) +void setDoHDownstreamMaxIdleConnectionsPerBackend([[maybe_unused]] size_t max) { #if defined(HAVE_DNS_OVER_HTTPS) && defined(HAVE_NGHTTP2) DownstreamDoHConnectionsManager::setMaxIdleConnectionsPerDownstream(max); diff --git a/pdns/dnsdistdist/dnsdist-rules.hh b/pdns/dnsdistdist/dnsdist-rules.hh index 129da7c8b96f..18291be07660 100644 --- a/pdns/dnsdistdist/dnsdist-rules.hh +++ b/pdns/dnsdistdist/dnsdist-rules.hh @@ -195,8 +195,9 @@ public: {} - bool matches(const DNSQuestion* qd) const override + bool matches(const DNSQuestion* dq) const override { + (void)dq; return d_qps.check(); } @@ -396,6 +397,7 @@ public: AllRule() {} bool matches(const DNSQuestion* dq) const override { + (void)dq; return true; } @@ -1055,8 +1057,10 @@ public: } bool matches(const DNSQuestion* dq) const override { - if(d_proba == 1.0) + (void)dq; + if (d_proba == 1.0) { return true; + } double rnd = 1.0*dns_random_uint32() / UINT32_MAX; return rnd > (1.0 - d_proba); } @@ -1111,6 +1115,7 @@ public: bool matches(const DNSQuestion* dq) const override { + (void)dq; return (getPool(d_poolname)->countServers(true) > 0); } @@ -1131,6 +1136,7 @@ public: bool matches(const DNSQuestion* dq) const override { + (void)dq; return (getPool(d_poolname)->poolLoad()) > d_limit; } diff --git a/pdns/dnsdistdist/dnsdist-snmp.cc b/pdns/dnsdistdist/dnsdist-snmp.cc index cbd8c619d999..9d4a05c1f051 100644 --- a/pdns/dnsdistdist/dnsdist-snmp.cc +++ b/pdns/dnsdistdist/dnsdist-snmp.cc @@ -80,6 +80,7 @@ static int handleCounter64Stats(netsnmp_mib_handler* handler, netsnmp_agent_request_info* reqinfo, netsnmp_request_info* requests) { + (void)handler; if (reqinfo->mode != MODE_GET) { return SNMP_ERR_GENERR; } @@ -126,6 +127,7 @@ static int handleFloatStats(netsnmp_mib_handler* handler, netsnmp_agent_request_info* reqinfo, netsnmp_request_info* requests) { + (void)handler; if (reqinfo->mode != MODE_GET) { return SNMP_ERR_GENERR; } @@ -177,6 +179,7 @@ static int handleGauge64Stats(netsnmp_mib_handler* handler, netsnmp_agent_request_info* reqinfo, netsnmp_request_info* requests) { + (void)handler; if (reqinfo->mode != MODE_GET) { return SNMP_ERR_GENERR; } @@ -259,6 +262,8 @@ static netsnmp_variable_list* backendStatTable_get_next_data_point(void** loop_c netsnmp_variable_list* put_index_data, netsnmp_iterator_info* mydata) { + (void)loop_context; + (void)mydata; if (s_currentServerIdx >= s_servers.size()) { return nullptr; } @@ -297,6 +302,8 @@ static int backendStatTable_handler(netsnmp_mib_handler* handler, netsnmp_agent_request_info* reqinfo, netsnmp_request_info* requests) { + (void)handler; + (void)reginfo; netsnmp_request_info* request{nullptr}; switch (reqinfo->mode) { @@ -387,7 +394,7 @@ static int backendStatTable_handler(netsnmp_mib_handler* handler, } #endif /* HAVE_NET_SNMP */ -bool DNSDistSNMPAgent::sendBackendStatusChangeTrap(const DownstreamState& dss) +bool DNSDistSNMPAgent::sendBackendStatusChangeTrap([[maybe_unused]] const DownstreamState& dss) { #ifdef HAVE_NET_SNMP const string backendAddress = dss.d_config.remote.toStringWithPort(); @@ -425,7 +432,7 @@ bool DNSDistSNMPAgent::sendBackendStatusChangeTrap(const DownstreamState& dss) #endif /* HAVE_NET_SNMP */ } -bool DNSDistSNMPAgent::sendCustomTrap(const std::string& reason) +bool DNSDistSNMPAgent::sendCustomTrap([[maybe_unused]] const std::string& reason) { #ifdef HAVE_NET_SNMP netsnmp_variable_list* varList = nullptr; @@ -447,7 +454,7 @@ bool DNSDistSNMPAgent::sendCustomTrap(const std::string& reason) #endif /* HAVE_NET_SNMP */ } -bool DNSDistSNMPAgent::sendDNSTrap(const DNSQuestion& dnsQuestion, const std::string& reason) +bool DNSDistSNMPAgent::sendDNSTrap([[maybe_unused]] const DNSQuestion& dnsQuestion, [[maybe_unused]] const std::string& reason) { #ifdef HAVE_NET_SNMP std::string local = dnsQuestion.ids.origDest.toString(); diff --git a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc index 5c269695f689..d23350b4d117 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc +++ b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc @@ -224,17 +224,12 @@ static void editPayloadID(PacketBuffer& payload, uint16_t newId, size_t proxyPro memcpy(&payload.at(startOfHeaderOffset), &id, sizeof(id)); } -enum class QueryState : uint8_t { - hasSizePrepended, - noSize -}; - enum class ConnectionState : uint8_t { needProxy, proxySent }; -static void prepareQueryForSending(TCPQuery& query, uint16_t id, QueryState queryState, ConnectionState connectionState) +static void prepareQueryForSending(TCPQuery& query, uint16_t id, ConnectionState connectionState) { if (connectionState == ConnectionState::needProxy) { if (query.d_proxyProtocolPayload.size() > 0 && !query.d_proxyProtocolPayloadAdded) { @@ -266,7 +261,7 @@ IOState TCPConnectionToBackend::queueNextQuery(std::shared_ptrd_currentQuery = std::move(conn->d_pendingQueries.front()); uint16_t id = conn->d_highestStreamID; - prepareQueryForSending(conn->d_currentQuery.d_query, id, QueryState::hasSizePrepended, conn->needProxyProtocolPayload() ? ConnectionState::needProxy : ConnectionState::proxySent); + prepareQueryForSending(conn->d_currentQuery.d_query, id, conn->needProxyProtocolPayload() ? ConnectionState::needProxy : ConnectionState::proxySent); conn->d_pendingQueries.pop_front(); conn->d_state = State::sendingQueryToBackend; @@ -277,6 +272,7 @@ IOState TCPConnectionToBackend::queueNextQuery(std::shared_ptr& conn, const struct timeval& now) { + (void)now; DEBUGLOG("sending query to backend "<getDS()->getNameWithAddr()<<" over FD "<d_handler->getDescriptor()); IOState state = conn->d_handler->tryWrite(conn->d_currentQuery.d_query.d_buffer, conn->d_currentPos, conn->d_currentQuery.d_query.d_buffer.size()); @@ -428,7 +424,7 @@ void TCPConnectionToBackend::handleIO(std::shared_ptr& c /* we need to edit this query so it has the correct ID */ auto query = std::move(conn->d_currentQuery); uint16_t id = conn->d_highestStreamID; - prepareQueryForSending(query.d_query, id, QueryState::hasSizePrepended, ConnectionState::needProxy); + prepareQueryForSending(query.d_query, id, ConnectionState::needProxy); conn->d_currentQuery = std::move(query); } @@ -542,7 +538,7 @@ void TCPConnectionToBackend::queueQuery(std::shared_ptr& sender, uint16_t id = d_highestStreamID; d_currentQuery = PendingRequest({sender, std::move(query)}); - prepareQueryForSending(d_currentQuery.d_query, id, QueryState::hasSizePrepended, needProxyProtocolPayload() ? ConnectionState::needProxy : ConnectionState::proxySent); + prepareQueryForSending(d_currentQuery.d_query, id, needProxyProtocolPayload() ? ConnectionState::needProxy : ConnectionState::proxySent); struct timeval now; gettimeofday(&now, 0); diff --git a/pdns/dnsdistdist/dnsdist-tcp-upstream.hh b/pdns/dnsdistdist/dnsdist-tcp-upstream.hh index df177c877825..e7c3a1a3b924 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-upstream.hh +++ b/pdns/dnsdistdist/dnsdist-tcp-upstream.hh @@ -165,6 +165,7 @@ public: } virtual std::unique_ptr getDOHUnit(uint32_t streamID) { + (void)streamID; throw std::runtime_error("Getting a DOHUnit state from a generic TCP/DoT connection is not supported"); } virtual void restoreDOHUnit(std::unique_ptr&&) diff --git a/pdns/dnsdistdist/dnsdist-tcp.cc b/pdns/dnsdistdist/dnsdist-tcp.cc index d2516352146c..5454a156a8ec 100644 --- a/pdns/dnsdistdist/dnsdist-tcp.cc +++ b/pdns/dnsdistdist/dnsdist-tcp.cc @@ -288,6 +288,7 @@ void IncomingTCPConnectionState::registerOwnedDownstreamConnection(std::shared_p /* called when the buffer has been set and the rules have been processed, and only from handleIO (sometimes indirectly via handleQuery) */ IOState IncomingTCPConnectionState::sendResponse(const struct timeval& now, TCPResponse&& response) { + (void)now; d_state = State::sendingResponse; const auto responseSize = static_cast(response.d_buffer.size()); @@ -1208,7 +1209,7 @@ void IncomingTCPConnectionState::notifyIOError(const struct timeval& now, TCPRes } } -static bool processXFRResponse(PacketBuffer& response, DNSResponse& dnsResponse) +static bool processXFRResponse(DNSResponse& dnsResponse) { const auto& chains = dnsdist::configuration::getCurrentRuntimeConfiguration().d_ruleChains; const auto& xfrRespRuleActions = dnsdist::rules::getResponseRuleChain(chains, dnsdist::rules::ResponseRuleChain::XFRResponseRules); @@ -1242,7 +1243,7 @@ void IncomingTCPConnectionState::handleXFRResponse(const struct timeval& now, TC dnsResponse.d_incomingTCPState = state; memcpy(&response.d_cleartextDH, dnsResponse.getHeader().get(), sizeof(response.d_cleartextDH)); - if (!processXFRResponse(response.d_buffer, dnsResponse)) { + if (!processXFRResponse(dnsResponse)) { state->terminateClientConnection(); return; } @@ -1270,6 +1271,7 @@ void IncomingTCPConnectionState::handleTimeout(std::shared_ptr(param); std::unique_ptr citmp{nullptr}; @@ -1303,6 +1305,7 @@ static void handleIncomingTCPQuery(int pipefd, FDMultiplexer::funcparam_t& param static void handleCrossProtocolQuery(int pipefd, FDMultiplexer::funcparam_t& param) { + (void)pipefd; auto* threadData = boost::any_cast(param); std::unique_ptr cpq{nullptr}; @@ -1340,6 +1343,7 @@ static void handleCrossProtocolQuery(int pipefd, FDMultiplexer::funcparam_t& par static void handleCrossProtocolResponse(int pipefd, FDMultiplexer::funcparam_t& param) { + (void)pipefd; auto* threadData = boost::any_cast(param); std::unique_ptr cpr{nullptr}; @@ -1509,6 +1513,7 @@ static void tcpClientThread(pdns::channel::Receiver&& queryRecei } auto acceptCallback = [&data](int socket, FDMultiplexer::funcparam_t& funcparam) { + (void)socket; const auto* acceptorParam = boost::any_cast(funcparam); acceptNewConnection(*acceptorParam, &data); }; @@ -1671,6 +1676,7 @@ void tcpAcceptorThread(const std::vector& states) } else { auto acceptCallback = [](int socket, FDMultiplexer::funcparam_t& funcparam) { + (void)socket; const auto* acceptorParam = boost::any_cast(funcparam); acceptNewConnection(*acceptorParam, nullptr); }; diff --git a/pdns/dnsdistdist/dnsdist-web.cc b/pdns/dnsdistdist/dnsdist-web.cc index 5cdfead09cd0..1b43ed0fe160 100644 --- a/pdns/dnsdistdist/dnsdist-web.cc +++ b/pdns/dnsdistdist/dnsdist-web.cc @@ -213,7 +213,7 @@ class WebClientConnection Socket d_socket; }; -bool addMetricDefinition(const dnsdist::prometheus::PrometheusMetricDefinition& def) +bool addMetricDefinition([[maybe_unused]] const dnsdist::prometheus::PrometheusMetricDefinition& def) { #ifndef DISABLE_PROMETHEUS return MetricDefinitionStorage::addMetricDefinition(def); @@ -1729,7 +1729,7 @@ void clearWebHandlers() #ifndef DISABLE_BUILTIN_HTML #include "htmlfiles.h" -static void redirectToIndex(const YaHTTP::Request& req, YaHTTP::Response& resp) +static void redirectToIndex([[maybe_unused]] const YaHTTP::Request& req, YaHTTP::Response& resp) { const string charset = "; charset=utf-8"; resp.body.assign(s_urlmap.at("index.html")); diff --git a/pdns/dnsdistdist/dnsdist.cc b/pdns/dnsdistdist/dnsdist.cc index 75ec0dd29a63..27f538fb5002 100644 --- a/pdns/dnsdistdist/dnsdist.cc +++ b/pdns/dnsdistdist/dnsdist.cc @@ -481,7 +481,7 @@ bool applyRulesToResponse(const std::vector& return true; } -bool processResponseAfterRules(PacketBuffer& response, DNSResponse& dnsResponse, bool muted) +bool processResponseAfterRules(PacketBuffer& response, DNSResponse& dnsResponse, [[maybe_unused]] bool muted) { bool zeroScope = false; if (!fixUpResponse(response, dnsResponse.ids.qname, dnsResponse.ids.origFlags, dnsResponse.ids.ednsAdded, dnsResponse.ids.ecsAdded, dnsResponse.ids.useZeroScope ? &zeroScope : nullptr)) { @@ -581,7 +581,7 @@ static size_t getMaximumIncomingPacketSize(const ClientState& clientState) return dnsdist::configuration::s_udpIncomingBufferSize + runtimeConfig.d_proxyProtocolMaximumSize; } -bool sendUDPResponse(int origFD, const PacketBuffer& response, const int delayMsec, const ComboAddress& origDest, const ComboAddress& origRemote) +bool sendUDPResponse(int origFD, const PacketBuffer& response, [[maybe_unused]] const int delayMsec, const ComboAddress& origDest, const ComboAddress& origRemote) { #ifndef DISABLE_DELAY_PIPE if (delayMsec > 0 && g_delay != nullptr) { @@ -1266,7 +1266,7 @@ static bool isUDPQueryAcceptable(ClientState& clientState, const struct msghdr* return true; } -bool checkDNSCryptQuery(const ClientState& clientState, PacketBuffer& query, std::unique_ptr& dnsCryptQuery, time_t now, bool tcp) +bool checkDNSCryptQuery(const ClientState& clientState, [[maybe_unused]] PacketBuffer& query, [[maybe_unused]] std::unique_ptr& dnsCryptQuery, [[maybe_unused]] time_t now, [[maybe_unused]] bool tcp) { if (clientState.dnscryptCtx) { #ifdef HAVE_DNSCRYPT @@ -1310,7 +1310,7 @@ bool checkQueryHeaders(const struct dnsheader& dnsHeader, ClientState& clientSta } #if !defined(DISABLE_RECVMMSG) && defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) -static void queueResponse(const ClientState& clientState, const PacketBuffer& response, const ComboAddress& dest, const ComboAddress& remote, struct mmsghdr& outMsg, struct iovec* iov, cmsgbuf_aligned* cbuf) +static void queueResponse(const PacketBuffer& response, const ComboAddress& dest, const ComboAddress& remote, struct mmsghdr& outMsg, struct iovec* iov, cmsgbuf_aligned* cbuf) { outMsg.msg_len = 0; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-pro-type-reinterpret-cast): API @@ -1332,7 +1332,7 @@ struct mmsghdr #endif /* self-generated responses or cache hits */ -static bool prepareOutgoingResponse(const ClientState& clientState, DNSQuestion& dnsQuestion, bool cacheHit) +static bool prepareOutgoingResponse([[maybe_unused]] const ClientState& clientState, DNSQuestion& dnsQuestion, bool cacheHit) { std::shared_ptr backend{nullptr}; DNSResponse dnsResponse(dnsQuestion.ids, dnsQuestion.getMutableData(), backend); @@ -1579,6 +1579,7 @@ class UDPTCPCrossQuerySender : public TCPQuerySender void handleResponse(const struct timeval& now, TCPResponse&& response) override { + (void)now; if (!response.d_ds && !response.d_idstate.selfGenerated) { throw std::runtime_error("Passing a cross-protocol answer originated from UDP without a valid downstream"); } @@ -1833,7 +1834,7 @@ static void processUDPQuery(ClientState& clientState, const struct msghdr* msgh, #ifndef DISABLE_RECVMMSG #if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) if (dnsQuestion.ids.delayMsec == 0 && responsesVect != nullptr) { - queueResponse(clientState, query, dest, remote, (*responsesVect)[*queuedResponses], respIOV, respCBuf); + queueResponse(query, dest, remote, (*responsesVect)[*queuedResponses], respIOV, respCBuf); (*queuedResponses)++; handleResponseSent(dnsQuestion.ids.qname, dnsQuestion.ids.qtype, 0., remote, ComboAddress(), query.size(), *dnsHeader, dnsdist::Protocol::DoUDP, dnsdist::Protocol::DoUDP, false); return; @@ -2173,6 +2174,7 @@ static void udpClientThread(std::vector states) } else { auto callback = [&remote, &msgh, &iov, &packet, &handleOnePacket, initialBufferSize](int socket, FDMultiplexer::funcparam_t& funcparam) { + (void)socket; const auto* param = boost::any_cast(funcparam); try { remote.sin4.sin_family = param->cs->local.sin4.sin_family; @@ -2366,7 +2368,7 @@ static void healthChecksThread() } } -static void bindAny(int addressFamily, int sock) +static void bindAny([[maybe_unused]] int addressFamily, int sock) { __attribute__((unused)) int one = 1; diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc index 6fb5b2939cdc..4b551d441932 100644 --- a/pdns/dnsdistdist/doh.cc +++ b/pdns/dnsdistdist/doh.cc @@ -485,6 +485,7 @@ class DoHTCPCrossQuerySender final : public TCPQuerySender void handleResponse(const struct timeval& now, TCPResponse&& response) override { + (void)now; if (!response.d_idstate.du) { return; } @@ -546,6 +547,7 @@ class DoHTCPCrossQuerySender final : public TCPQuerySender void notifyIOError(const struct timeval& now, TCPResponse&& response) override { + (void)now; auto& query = response.d_idstate; if (!query.du) { return; @@ -856,6 +858,7 @@ static void processDOHQuery(DOHUnitUniquePtr&& unit, bool inMainThread = false) /* called when a HTTP response is about to be sent, from the main DoH thread */ static void on_response_ready_cb(struct st_h2o_filter_t *self, h2o_req_t *req, h2o_ostream_t **slot) { + (void)self; if (req == nullptr) { return; } @@ -1294,6 +1297,7 @@ static void dnsdistclient(pdns::channel::Receiver&& receiver) */ static void on_dnsdist(h2o_socket_t *listener, const char *err) { + (void)err; /* we want to read as many responses from the pipe as possible before giving up. Even if we are overloaded and fighting with the DoH connections for the CPU, the first thing we need to do is to send responses to free slots diff --git a/pdns/dnsdistdist/doh3.cc b/pdns/dnsdistdist/doh3.cc index 661e9c618223..5aef638df571 100644 --- a/pdns/dnsdistdist/doh3.cc +++ b/pdns/dnsdistdist/doh3.cc @@ -755,7 +755,7 @@ static void processH3HeaderEvent(ClientState& clientState, DOH3Frontend& fronten handleImmediateError("Unsupported HTTP method"); } -static void processH3DataEvent(ClientState& clientState, DOH3Frontend& frontend, H3Connection& conn, const ComboAddress& client, const PacketBuffer& serverConnID, const uint64_t streamID, quiche_h3_event* event, PacketBuffer& buffer) +static void processH3DataEvent(ClientState& clientState, DOH3Frontend& frontend, H3Connection& conn, const ComboAddress& client, const PacketBuffer& serverConnID, const uint64_t streamID, PacketBuffer& buffer) { auto handleImmediateError = [&clientState, &frontend, &conn, streamID](const char* msg) { DEBUGLOG(msg); @@ -829,7 +829,7 @@ static void processH3Events(ClientState& clientState, DOH3Frontend& frontend, H3 break; } case QUICHE_H3_EVENT_DATA: { - processH3DataEvent(clientState, frontend, conn, client, serverConnID, streamID, event, buffer); + processH3DataEvent(clientState, frontend, conn, client, serverConnID, streamID, buffer); break; } case QUICHE_H3_EVENT_FINISHED: diff --git a/pdns/dnsdistdist/doh3.hh b/pdns/dnsdistdist/doh3.hh index 954ea4aab2ea..18b3fe7f9d03 100644 --- a/pdns/dnsdistdist/doh3.hh +++ b/pdns/dnsdistdist/doh3.hh @@ -29,13 +29,13 @@ #include "libssl.hh" #include "noinitvector.hh" #include "stat_t.hh" -#include "dnsdist-idstate.hh" struct DOH3ServerConfig; struct DownstreamState; #ifdef HAVE_DNS_OVER_HTTP3 +#include "dnsdist-idstate.hh" #include "doq-common.hh" struct DOH3Frontend diff --git a/pdns/dnsdistdist/doq.hh b/pdns/dnsdistdist/doq.hh index 258194177a6e..c9ae812f2299 100644 --- a/pdns/dnsdistdist/doq.hh +++ b/pdns/dnsdistdist/doq.hh @@ -30,13 +30,13 @@ #include "noinitvector.hh" #include "doq.hh" #include "stat_t.hh" -#include "dnsdist-idstate.hh" struct DOQServerConfig; struct DownstreamState; #ifdef HAVE_DNS_OVER_QUIC +#include "dnsdist-idstate.hh" #include "doq-common.hh" struct DOQFrontend diff --git a/pdns/dnsdistdist/ext/arc4random/meson.build b/pdns/dnsdistdist/ext/arc4random/meson.build new file mode 120000 index 000000000000..fc307228eee0 --- /dev/null +++ b/pdns/dnsdistdist/ext/arc4random/meson.build @@ -0,0 +1 @@ +../../../../ext/arc4random/meson.build \ No newline at end of file diff --git a/pdns/dnsdistdist/ext/ipcrypt/meson.build b/pdns/dnsdistdist/ext/ipcrypt/meson.build new file mode 100644 index 000000000000..3af7415c3334 --- /dev/null +++ b/pdns/dnsdistdist/ext/ipcrypt/meson.build @@ -0,0 +1,12 @@ +lib_ipcrypt = static_library( + 'ipcrypt', + 'ipcrypt.c', + extra_files: [ + 'ipcrypt.h', + ], +) + +dep_ipcrypt = declare_dependency( + link_with: lib_ipcrypt, + include_directories: include_directories('.'), +) diff --git a/pdns/dnsdistdist/ext/json11/meson.build b/pdns/dnsdistdist/ext/json11/meson.build new file mode 120000 index 000000000000..ad335bb7b939 --- /dev/null +++ b/pdns/dnsdistdist/ext/json11/meson.build @@ -0,0 +1 @@ +../../../../ext/json11/meson.build \ No newline at end of file diff --git a/pdns/dnsdistdist/ext/lmdb-safe/meson.build b/pdns/dnsdistdist/ext/lmdb-safe/meson.build new file mode 100644 index 000000000000..dc9bc6c50b00 --- /dev/null +++ b/pdns/dnsdistdist/ext/lmdb-safe/meson.build @@ -0,0 +1,16 @@ +lib_lmdb_safe = static_library( + 'lmdb-safe', + 'lmdb-safe.cc', + extra_files: [ + 'lmdb-safe.hh', + ], + dependencies: [ + dep_pdns, + dep_lmdb, + ], +) + +dep_lmdb_safe = declare_dependency( + link_with: lib_lmdb_safe, + include_directories: include_directories('.'), +) diff --git a/pdns/dnsdistdist/ext/luawrapper/meson.build b/pdns/dnsdistdist/ext/luawrapper/meson.build new file mode 120000 index 000000000000..97a1b5e9bfa4 --- /dev/null +++ b/pdns/dnsdistdist/ext/luawrapper/meson.build @@ -0,0 +1 @@ +../../../../ext/luawrapper/meson.build \ No newline at end of file diff --git a/pdns/dnsdistdist/ext/yahttp/meson.build b/pdns/dnsdistdist/ext/yahttp/meson.build new file mode 120000 index 000000000000..89a718d91606 --- /dev/null +++ b/pdns/dnsdistdist/ext/yahttp/meson.build @@ -0,0 +1 @@ +../../../../ext/yahttp/meson.build \ No newline at end of file diff --git a/pdns/dnsdistdist/ext/yahttp/yahttp/meson.build b/pdns/dnsdistdist/ext/yahttp/yahttp/meson.build new file mode 120000 index 000000000000..471962bc04b3 --- /dev/null +++ b/pdns/dnsdistdist/ext/yahttp/yahttp/meson.build @@ -0,0 +1 @@ +../../../../../ext/yahttp/yahttp/meson.build \ No newline at end of file diff --git a/pdns/dnsdistdist/generate-ffi-interface.sh b/pdns/dnsdistdist/generate-ffi-interface.sh new file mode 100644 index 000000000000..365d2df55506 --- /dev/null +++ b/pdns/dnsdistdist/generate-ffi-interface.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo 'R"FFIContent(' +cat $1 $2 +echo ')FFIContent"' diff --git a/pdns/dnsdistdist/m4/dnsdist_with_cdb.m4 b/pdns/dnsdistdist/m4/dnsdist_with_cdb.m4 index d874e2ee5b28..fbc2cd64a690 100644 --- a/pdns/dnsdistdist/m4/dnsdist_with_cdb.m4 +++ b/pdns/dnsdistdist/m4/dnsdist_with_cdb.m4 @@ -1,5 +1,5 @@ AC_DEFUN([DNSDIST_WITH_CDB], [ - AC_MSG_CHECKING([whether we will we liniking with libcdb]) + AC_MSG_CHECKING([whether we will we linking with libcdb]) HAVE_CDB=0 AC_ARG_WITH([cdb], AS_HELP_STRING([--with-cdb], [use CDB @<:@default=auto@:>@]), diff --git a/pdns/dnsdistdist/meson.build b/pdns/dnsdistdist/meson.build new file mode 100644 index 000000000000..a62e50b523aa --- /dev/null +++ b/pdns/dnsdistdist/meson.build @@ -0,0 +1,556 @@ +project( + 'dnsdist', + ['c', 'cpp'], + version: run_command('../../builder-support' / 'gen-version', check: true).stdout().strip(), + license: 'GPLv2', + license_files: 'NOTICE', + meson_version: '>= 1.2.1', + default_options: [ + 'buildtype=debugoptimized', + 'warning_level=2', # TODO Move this to 3 to enable -Wpedantic + 'cpp_std=c++17', + 'b_pie=true', + ], +) +add_project_arguments('-DDNSDIST', language: 'cpp') + + +product_source_dir = meson.current_source_dir() +product_build_dir = meson.current_build_dir() +summary('Source Dir', product_source_dir, section: 'Build') +summary('Build Dir', product_build_dir, section: 'Build') + +# Create the configuration object and dependencies list. +conf = configuration_data() +conf.set_quoted('PACKAGE_STRING', 'dnsdist ' + meson.project_version(), description: 'dnsdist version') +conf.set_quoted('PACKAGE_VERSION', meson.project_version(), description: 'version') + +# Feature detection and system configuration +subdir('meson' / 'config') # Config +subdir('meson' / 'version') # Generate version define +subdir('meson' / 'compiler-setup') # Common compiler setup +subdir('meson' / 'summary') # Print a system/project summary +subdir('meson' / 'sysconfdir') # Sysconfdir +subdir('meson' / 'platform') # Platform detection +subdir('meson' / 'timet-size') # Check the size of time_t +subdir('meson' / 'timet-sign') # Check the sign of time_t +subdir('meson' / 'atomics') # Check atomics support +subdir('meson' / 'pthread-headers') # Check pthread headers +subdir('meson' / 'pthread-setname') # Pthread setname madness +subdir('meson' / 'pthread-np') # Pthread _np functions +subdir('meson' / 'strerror') # Strerror_r +subdir('meson' / 'lua') # Lua +subdir('meson' / 'hardening') # Hardening +subdir('meson' / 'net-libs') # Network Libraries +subdir('meson' / 'tm-gmtoff') # Check for tm_gmtoff field in struct tm +subdir('meson' / 'mmap') # Check for mmap +subdir('meson' / 'libcap') # Libcap to drop capabilities +subdir('meson' / 'libedit') # Libedit +subdir('meson' / 'libsodium') # Libsodium +subdir('meson' / 'libcrypto') # OpenSSL libcrypto +subdir('meson' / 'libssl') # OpenSSL libssl +subdir('meson' / 'libssl-providers') # OpenSSL libssl providers +subdir('meson' / 'libsnmp') # SNMP +subdir('meson' / 'clock-gettime') # Clock_gettime +subdir('meson' / 'boost') # Boost +subdir('meson' / 'boost-test') # Boost Testing Library +subdir('meson' / 'reproducible') # Reproducible Builds +subdir('meson' / 'libsystemd') # Systemd notification +subdir('meson' / 'systemd') # Systemd and unit file handling +subdir('meson' / 'code-coverage') # Code coverage +subdir('meson' / 'auto-var-init') # Automatic Variable Initialization +subdir('meson' / 'sanitizers') # Sanitizers +subdir('meson' / 'various-functions') # Various Functions +subdir('meson' / 'various-headers') # Various Headers +subdir('meson' / 'dnstap') # DNSTAP through libfstream +subdir('meson' / 'dnscrypt') # DNSCrypt through libsodium +subdir('meson' / 'ipcipher') # IPCipher (requires libcrypto) +subdir('meson' / 'cdb') # CDB +subdir('meson' / 'ebpf') # eBPF +subdir('meson' / 'gnutls') # GNUTLS +subdir('meson' / 'h2o') # H2O +subdir('meson' / 'lmdb') # LMDB +subdir('meson' / 'nghttp2') # NGHTTP2 +subdir('meson' / 'quiche') # Quiche +subdir('meson' / 're2') # RE2 +subdir('meson' / 'xsk') # BPF and XDP for XSK +subdir('meson' / 'dot') # DNS over TLS +subdir('meson' / 'doh2') # DNS over HTTP/2 +subdir('meson' / 'doq') # DNS over QUIC +subdir('meson' / 'doh3') # DNS over HTTP/3 + +common_sources = [] + +fs = import('fs') +src_dir = fs.is_dir('.') ? '.' : '' +docs_dir = 'docs' +# Toplevel includes +dep_pdns = declare_dependency(include_directories: include_directories('.', src_dir)) + +# Ext +subdir('ext' / 'arc4random') +subdir('ext' / 'ipcrypt') +subdir('ext' / 'json11') +subdir('ext' / 'luawrapper') +subdir('ext' / 'protozero') +subdir('ext' / 'yahttp') + +if get_option('lmdb').allowed() + subdir('ext' / 'lmdb-safe') +else + dep_lmdb_safe = declare_dependency() +endif + +common_sources += files( + src_dir / 'bpf-filter.cc', + src_dir / 'capabilities.cc', + src_dir / 'channel.cc', + src_dir / 'coverage.cc', + src_dir / 'credentials.cc', + src_dir / 'dns.cc', + src_dir / 'dnscrypt.cc', + src_dir / 'dnsdist-async.cc', + src_dir / 'dnsdist-backend.cc', + src_dir / 'dnsdist-cache.cc', + src_dir / 'dnsdist-carbon.cc', + src_dir / 'dnsdist-configuration.cc', + src_dir / 'dnsdist-console.cc', + src_dir / 'dnsdist-crypto.cc', + src_dir / 'dnsdist-discovery.cc', + src_dir / 'dnsdist-dnscrypt.cc', + src_dir / 'dnsdist-dnsparser.cc', + src_dir / 'dnsdist-dnsquestion.cc', + src_dir / 'dnsdist-doh-common.cc', + src_dir / 'dnsdist-dynblocks.cc', + src_dir / 'dnsdist-dynbpf.cc', + src_dir / 'dnsdist-ecs.cc', + src_dir / 'dnsdist-edns.cc', + src_dir / 'dnsdist-frontend.cc', + src_dir / 'dnsdist-healthchecks.cc', + src_dir / 'dnsdist-idstate.cc', + src_dir / 'dnsdist-internal-queries.cc', + src_dir / 'dnsdist-kvs.cc', + src_dir / 'dnsdist-lbpolicies.cc', + src_dir / 'dnsdist-lua-actions.cc', + src_dir / 'dnsdist-lua-bindings.cc', + src_dir / 'dnsdist-lua-bindings-dnscrypt.cc', + src_dir / 'dnsdist-lua-bindings-dnsparser.cc', + src_dir / 'dnsdist-lua-bindings-dnsquestion.cc', + src_dir / 'dnsdist-lua-bindings-kvs.cc', + src_dir / 'dnsdist-lua-bindings-network.cc', + src_dir / 'dnsdist-lua-bindings-packetcache.cc', + src_dir / 'dnsdist-lua-bindings-protobuf.cc', + src_dir / 'dnsdist-lua-bindings-rings.cc', + src_dir / 'dnsdist-lua.cc', + src_dir / 'dnsdist-lua-ffi.cc', + src_dir / 'dnsdist-lua-hooks.cc', + src_dir / 'dnsdist-lua-inspection.cc', + src_dir / 'dnsdist-lua-inspection-ffi.cc', + src_dir / 'dnsdist-lua-network.cc', + src_dir / 'dnsdist-lua-rules.cc', + src_dir / 'dnsdist-lua-vars.cc', + src_dir / 'dnsdist-lua-web.cc', + src_dir / 'dnsdist-mac-address.cc', + src_dir / 'dnsdist-metrics.cc', + src_dir / 'dnsdist-nghttp2.cc', + src_dir / 'dnsdist-nghttp2-in.cc', + src_dir / 'dnsdist-protobuf.cc', + src_dir / 'dnsdist-protocols.cc', + src_dir / 'dnsdist-proxy-protocol.cc', + src_dir / 'dnsdist-query-count.cc', + src_dir / 'dnsdist-random.cc', + src_dir / 'dnsdist-resolver.cc', + src_dir / 'dnsdist-rings.cc', + src_dir / 'dnsdist-rule-chains.cc', + src_dir / 'dnsdist-rules.cc', + src_dir / 'dnsdist-secpoll.cc', + src_dir / 'dnsdist-session-cache.cc', + src_dir / 'dnsdist-snmp.cc', + src_dir / 'dnsdist-svc.cc', + src_dir / 'dnsdist-systemd.cc', + src_dir / 'dnsdist-tcp.cc', + src_dir / 'dnsdist-tcp-downstream.cc', + src_dir / 'dnsdist-web.cc', + src_dir / 'dnsdist-xsk.cc', + src_dir / 'dnsname.cc', + src_dir / 'dnsparser.cc', + src_dir / 'dnswriter.cc', + src_dir / 'dolog.cc', + src_dir / 'ednscookies.cc', + src_dir / 'ednsextendederror.cc', + src_dir / 'ednsoptions.cc', + src_dir / 'ednssubnet.cc', + src_dir / 'gettime.cc', + src_dir / 'ipcipher.cc', + src_dir / 'iputils.cc', + src_dir / 'libssl.cc', + src_dir / 'misc.cc', + src_dir / 'protozero.cc', + src_dir / 'proxy-protocol.cc', + src_dir / 'qtype.cc', + src_dir / 'remote_logger.cc', + src_dir / 'snmp-agent.cc', + src_dir / 'statnode.cc', + src_dir / 'svc-records.cc', + src_dir / 'tcpiohandler.cc', + src_dir / 'threadname.cc', + src_dir / 'uuid-utils.cc', + src_dir / 'xsk.cc', +) + +conditional_sources = { + 'cdb': { + 'sources': [ + src_dir / 'cdb.cc', + ], + 'condition': dep_cdb.found(), + }, + 'doh': { + 'sources': [ + src_dir / 'doh.cc', + ], + 'condition': dep_libh2o_evloop.found(), + }, + 'doh3': { + 'sources': [ + src_dir / 'doh3.cc', + ], + 'condition': get_option('dns-over-http3'), + }, + 'doq': { + 'sources': [ + src_dir / 'doq.cc', + ], + 'condition': get_option('dns-over-quic'), + }, + 'ipcipher': { + 'sources': [ + src_dir / 'ipcipher.cc', + ], + 'condition': dep_libcrypto.found(), + }, + 'quiche': { + 'sources': [ + src_dir / 'doq-common.cc', + ], + 'condition': dep_libquiche.found(), + }, +} + +foreach name, info: conditional_sources + if info['condition'] + common_sources += files(info['sources']) + endif +endforeach + +mplexer_sources = [src_dir / 'pollmplexer.cc'] +if have_linux + mplexer_sources += src_dir / 'epollmplexer.cc' +endif +if have_darwin + mplexer_sources += src_dir / 'kqueuemplexer.cc' +endif +if have_openbsd + mplexer_sources += src_dir / 'kqueuemplexer.cc' +endif +if have_freebsd + mplexer_sources += src_dir / 'kqueuemplexer.cc' +endif +if have_sunos + mplexer_sources += src_dir / 'devpollmplexer.cc' + mplexer_sources += src_dir / 'portsmplexer.cc' +endif + +# Generate config.h +config_h = configure_file(configuration: conf, output: 'config.h') + +sh_program = find_program('sh') +dep_no_config_in_source_check = custom_target( + input: [], + output: ['check absense of config.h file in source directory'], + command: [sh_program, '-c', 'test ! -e @SOURCE_ROOT@/config.h'], + build_always_stale: true, +) +dep_no_config_in_source = declare_dependency( + sources: dep_no_config_in_source_check +) + +html_sources = [ + src_dir / 'html/index.html', + src_dir / 'html/local.js', + src_dir / 'html/js/moment.min.js', + src_dir / 'html/js/rickshaw.min.js', + src_dir / 'html/js/d3.min.js', + src_dir / 'html/js/moment.min.js', + src_dir / 'html/lines.css', + src_dir / 'html/legend.css', + src_dir / 'html/detail.css', + src_dir / 'html/graph.css', + src_dir / 'html/powerdns-logo-220px.png', +] + +incfiles = find_program('incfiles') + +htmlfiles = custom_target( + command: [incfiles, '@SOURCE_ROOT@'], + input: html_sources, + output: 'htmlfiles.h', + capture: true +) + +dep_htmlfiles = declare_dependency( + sources: [htmlfiles], +) + +generate_ffi_interface = find_program('generate-ffi-interface.sh') +ffi_interface = custom_target( + command: [generate_ffi_interface, '@INPUT@'], + input: ['dnsdist-lua-ffi-interface.h', 'dnsdist-lua-inspection-ffi.h'], + output: 'dnsdist-lua-ffi-interface.inc', + capture: true +) + +dep_ffi_interface = declare_dependency( + sources: [ffi_interface], +) + +deps = [ + dep_pdns, + dep_no_config_in_source, + dep_arc4random, + dep_boost, + dep_cdb, + dep_dnstap, + dep_ffi_interface, + dep_htmlfiles, + dep_ipcrypt, + dep_libcap, + dep_libcrypto, + dep_gnutls, + dep_libedit, + dep_libh2o_evloop, + dep_json11, + dep_libnghttp2, + dep_libquiche, + dep_libsnmp, + dep_libsodium, + dep_libssl, + dep_lmdb, + dep_lmdb_safe, + dep_lua, + dep_protozero, + dep_yahttp, + dep_libre2, + dep_threads, + dep_libbpf, + dep_libxdp, +] + +libdnsdist_dnslabeltext_source = src_dir / 'dnslabeltext.rl' +libdnsdist_dnslabeltext_gen = src_dir / 'dnslabeltext.cc' +if not fs.is_file(libdnsdist_dnslabeltext_gen) + ragel = find_program('ragel', required: true) + + summary('Ragel', ragel.found(), bool_yn: ragel.found(), section: 'DNS Labels') + summary('Ragel Path', ragel.full_path(), section: 'DNS Labels') + summary('Ragel Version', ragel.version(), section: 'DNS Labels') + + ragel_generator = generator( + ragel, + output: '@BASENAME@.cc', + arguments: ['@INPUT@', '-o', '@OUTPUT@'], + ) + + libdnsdist_dnslabeltext_gen = ragel_generator.process(libdnsdist_dnslabeltext_source) +endif + +libdnsdist_dnslabeltext = declare_dependency( + link_with: static_library( + 'dnsdist-dnslabeltext', + libdnsdist_dnslabeltext_gen, + dependencies: deps, + ) +) + +libdnsdist_common = declare_dependency( + link_with: static_library( + 'dnsdist-common', + common_sources, + config_h, + dependencies: [ + deps, + libdnsdist_dnslabeltext, + ], + ) +) + +tools = { + 'dnsdist': { + 'main': src_dir / 'dnsdist.cc', + 'files-extra': [ + src_dir / 'dnstap.cc', + src_dir / 'fstrm_logger.cc', + mplexer_sources, + ], + 'manpages': ['dnsdist.1'], + 'deps-extra': [ + dep_pdns, + dep_boost, + dep_lua, + dep_protozero, + dep_yahttp, + dep_json11, + dep_systemd, + ], + }, +} + +if get_option('fuzz-targets') + fuzz_extra_sources = [] + fuzzer_ldflags = [] + # https://github.com/harfbuzz/harfbuzz/pull/2549/files + if get_option('fuzzer_ldflags') == '' + fuzz_extra_sources += src_dir / 'standalone_fuzz_target_runner.cc' + else + fuzzer_ldflags += get_option('fuzzer_ldflags') + endif + tools += { + 'fuzz-target-dnsdistcache' : { + 'main': src_dir / 'fuzz_dnsdistcache.cc', + 'link-args': fuzzer_ldflags, + 'files-extra': fuzz_extra_sources + }, + } + if get_option('xsk').allowed() and dep_libbpf.found() and dep_libxdp.found() + tools += { + 'fuzz-target-xsk' : { + 'main': src_dir / 'fuzz_xsk.cc', + 'link-args': fuzzer_ldflags, + 'files-extra': fuzz_extra_sources + [ + src_dir / 'dnsname.cc', + src_dir / 'gettime.cc', + src_dir / 'iputils.cc', + src_dir / 'misc.cc', + src_dir / 'xsk.cc' + ] + }, + } + endif +endif + +test_sources = [] +test_sources += files( + src_dir / 'test-base64_cc.cc', + src_dir / 'test-channel.cc', + src_dir / 'test-connectionmanagement_hh.cc', + src_dir / 'test-credentials_cc.cc', + src_dir / 'test-delaypipe_hh.cc', + src_dir / 'test-dnscrypt_cc.cc', + src_dir / 'test-dnsdistasync.cc', + src_dir / 'test-dnsdistbackend_cc.cc', + src_dir / 'test-dnsdistbackoff.cc', + src_dir / 'test-dnsdist_cc.cc', + src_dir / 'test-dnsdist-connections-cache.cc', + src_dir / 'test-dnsdist-dnsparser.cc', + src_dir / 'test-dnsdistdynblocks_hh.cc', + src_dir / 'test-dnsdistedns.cc', + src_dir / 'test-dnsdistkvs_cc.cc', + src_dir / 'test-dnsdistlbpolicies_cc.cc', + src_dir / 'test-dnsdist-lua-ffi.cc', + src_dir / 'test-dnsdistluanetwork.cc', + src_dir / 'test-dnsdistnghttp2_cc.cc', + src_dir / 'test-dnsdistnghttp2-in_cc.cc', + src_dir / 'test-dnsdistpacketcache_cc.cc', + src_dir / 'test-dnsdistrings_cc.cc', + src_dir / 'test-dnsdistrules_cc.cc', + src_dir / 'test-dnsdistsvc_cc.cc', + src_dir / 'test-dnsdisttcp_cc.cc', + src_dir / 'test-dnsparser_cc.cc', + src_dir / 'test-iputils_hh.cc', + src_dir / 'test-luawrapper.cc', + src_dir / 'test-mplexer.cc', + src_dir / 'test-proxy_protocol_cc.cc', + src_dir / 'test-sholder_hh.cc', +) + +if get_option('unit-tests') + libdnsdist_test = declare_dependency( + link_whole: static_library( + 'dnsdist-test', + config_h, + test_sources, + dependencies: [ + dep_boost, + dep_boost_test, + dep_lua, + ], + ) + ) + tools += { + 'testrunner': { + 'main': [ + src_dir / 'testrunner.cc', + mplexer_sources, + ], + 'deps-extra': [ + libdnsdist_test, + dep_boost_test, + ], + } + } +endif + +man_pages = [] +foreach tool, info: tools + var_name = tool.underscorify() + main = files(info['main']) + + export_dynamic = 'export-dynamic' in info ? info['export-dynamic'] : false + files_extra = 'files-extra' in info ? info['files-extra'] : [] + deps_extra = 'deps-extra' in info ? info['deps-extra'] : [] + link_args = 'link-args' in info ? info['link-args'] : [] + + set_variable( + var_name, + executable( + tool, + main, + config_h, + files_extra, + export_dynamic: export_dynamic, + link_args: link_args, + dependencies: [ + libdnsdist_common, + deps_extra, + ], + ) + ) + + if 'manpages' in info + foreach man_page: info['manpages'] + man_pages += docs_dir / 'manpages' / (man_page + '.rst') + endforeach + endif +endforeach + +# Man-pages. +py = import('python') +python = py.find_installation('python3', modules: 'venv', required: false) + +summary('Python', python.found(), bool_yn: true, section: 'Manual Pages') +summary('Path', python.full_path(), section: 'Manual Pages') +summary('Version', python.version(), section: 'Manual Pages') + +if python.found() + run_target( + 'man-pages', + command: [ + python, + product_source_dir / docs_dir / 'generate-man-pages.py', + '--venv-name', 'venv-dnsdist-man-pages', + '--requirements-file', docs_dir / 'requirements.txt', + '--source-directory', docs_dir, + '--target-directory', 'dnsdist-man-pages', + ] + man_pages, + ) +endif diff --git a/pdns/dnsdistdist/meson/atomics b/pdns/dnsdistdist/meson/atomics new file mode 120000 index 000000000000..f66584baf518 --- /dev/null +++ b/pdns/dnsdistdist/meson/atomics @@ -0,0 +1 @@ +../../../meson/atomics \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/auto-var-init b/pdns/dnsdistdist/meson/auto-var-init new file mode 120000 index 000000000000..4dd250152f3b --- /dev/null +++ b/pdns/dnsdistdist/meson/auto-var-init @@ -0,0 +1 @@ +../../../meson/auto-var-init \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/boost b/pdns/dnsdistdist/meson/boost new file mode 120000 index 000000000000..35cc45495bb4 --- /dev/null +++ b/pdns/dnsdistdist/meson/boost @@ -0,0 +1 @@ +../../../meson/boost \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/boost-test/meson.build b/pdns/dnsdistdist/meson/boost-test/meson.build new file mode 100644 index 000000000000..5dd97525aa00 --- /dev/null +++ b/pdns/dnsdistdist/meson/boost-test/meson.build @@ -0,0 +1,5 @@ +dep_boost_test = dependency('', required: false) +if get_option('unit-tests') + dep_boost_test = dependency('boost', modules: ['unit_test_framework'], required: true) + summary('Test', dep_boost_test.found(), bool_yn: true, section: 'Boost') +endif diff --git a/pdns/dnsdistdist/meson/cdb/meson.build b/pdns/dnsdistdist/meson/cdb/meson.build new file mode 100644 index 000000000000..461677317558 --- /dev/null +++ b/pdns/dnsdistdist/meson/cdb/meson.build @@ -0,0 +1,17 @@ +dep_cdb = dependency('libcdb', required: false) + +if not dep_cdb.found() + if cxx.has_header('cdb.h', required: false) + if cxx.has_function('cdb_find', args: ['-lcdb']) + dep_cdb = declare_dependency(link_args: ['-lcdb']) + endif + endif +endif + +conf.set('HAVE_CDB', dep_cdb.found(), description: 'Whether we have CDB') + +summary('CDB', dep_cdb.found(), bool_yn: true, section: 'Key-Value') + +if dep_cdb.found() + summary('CDB version', dep_cdb.version(), bool_yn: true, section: 'Key-Value') +endif diff --git a/pdns/dnsdistdist/meson/clock-gettime b/pdns/dnsdistdist/meson/clock-gettime new file mode 120000 index 000000000000..a88e7f3e9b6c --- /dev/null +++ b/pdns/dnsdistdist/meson/clock-gettime @@ -0,0 +1 @@ +../../../meson/clock-gettime \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/code-coverage b/pdns/dnsdistdist/meson/code-coverage new file mode 120000 index 000000000000..dc72803d46d7 --- /dev/null +++ b/pdns/dnsdistdist/meson/code-coverage @@ -0,0 +1 @@ +../../../meson/code-coverage \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/compiler-setup/meson.build b/pdns/dnsdistdist/meson/compiler-setup/meson.build new file mode 100644 index 000000000000..be76040b0ebe --- /dev/null +++ b/pdns/dnsdistdist/meson/compiler-setup/meson.build @@ -0,0 +1,17 @@ +# Don't limit the number of errors when using clang. This is useful to not cut out the +# error output when using an LSP server like clangd. +if meson.get_compiler('cpp').get_id() == 'clang' + add_project_arguments('-ferror-limit=0', language: ['c', 'cpp']) +endif + +add_project_arguments( + '-Wshadow', + '-Wmissing-declarations', + '-Wredundant-decls', + '-Wno-ignored-attributes', + '-fvisibility=hidden', + language: ['c', 'cpp'], +) + +cxx = meson.get_compiler('cpp') +system = target_machine.system() diff --git a/pdns/dnsdistdist/meson/config b/pdns/dnsdistdist/meson/config new file mode 120000 index 000000000000..97b0070df2c1 --- /dev/null +++ b/pdns/dnsdistdist/meson/config @@ -0,0 +1 @@ +../../../meson/config \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/dlopen b/pdns/dnsdistdist/meson/dlopen new file mode 120000 index 000000000000..0b2f1067f0fa --- /dev/null +++ b/pdns/dnsdistdist/meson/dlopen @@ -0,0 +1 @@ +../../../meson/dlopen \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/dnscrypt/meson.build b/pdns/dnsdistdist/meson/dnscrypt/meson.build new file mode 100644 index 000000000000..59da40c9d543 --- /dev/null +++ b/pdns/dnsdistdist/meson/dnscrypt/meson.build @@ -0,0 +1,8 @@ +opt_dnscrypt = get_option('dnscrypt') + +if opt_dnscrypt.enabled() and not dep_libsodium.found() + error('DNSCrypt support requested but libsodium is not available') +endif + +conf.set('HAVE_DNSCRYPT', opt_dnscrypt.allowed() and dep_libsodium.found(), description: 'DNSCrypt support') +summary('DNSCrypt support', opt_dnscrypt.allowed() and dep_libsodium.found(), bool_yn: true, section: 'Crypto') diff --git a/pdns/dnsdistdist/meson/dnstap b/pdns/dnsdistdist/meson/dnstap new file mode 120000 index 000000000000..46d9991cef83 --- /dev/null +++ b/pdns/dnsdistdist/meson/dnstap @@ -0,0 +1 @@ +../../../meson/dnstap \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/doh2/meson.build b/pdns/dnsdistdist/meson/doh2/meson.build new file mode 100644 index 000000000000..b74d835c7f01 --- /dev/null +++ b/pdns/dnsdistdist/meson/doh2/meson.build @@ -0,0 +1,13 @@ +opt_doh2 = get_option('dns-over-https') +conf.set('HAVE_DNS_OVER_HTTPS', opt_doh2, description: 'DNS over HTTP/2 (DoH)') + +if opt_doh2 + if not dep_libssl.found() and not dep_gnutls.found() + error('DNS over HTTP/2 support was requested but neither OpenSSL libssl nor GnuTLS support is enabled') + endif + if not dep_libnghttp2.found() and not dep_libh2o_evloop.found() + error('DNS over HTTP/2 support was requested but neither nghttp2 not libh2o-evloop support is enabled') + endif +endif + +summary('DNS over HTTP/2', opt_doh2, bool_yn: true, section: 'Configuration') diff --git a/pdns/dnsdistdist/meson/doh3/meson.build b/pdns/dnsdistdist/meson/doh3/meson.build new file mode 100644 index 000000000000..e2cb1f137b4e --- /dev/null +++ b/pdns/dnsdistdist/meson/doh3/meson.build @@ -0,0 +1,10 @@ +opt_doh3 = get_option('dns-over-http3') +conf.set('HAVE_DNS_OVER_HTTP3', opt_doh3, description: 'DNS over HTTP/3 (DoH3)') + +if opt_doh3 + if not dep_libquiche.found() + error('DNS over HTTP/3 support was requested but Quiche support is not enabled') + endif +endif + +summary('DNS over HTTP/3', opt_doh3, bool_yn: true, section: 'Configuration') diff --git a/pdns/dnsdistdist/meson/doq/meson.build b/pdns/dnsdistdist/meson/doq/meson.build new file mode 100644 index 000000000000..9924f9bbf2d0 --- /dev/null +++ b/pdns/dnsdistdist/meson/doq/meson.build @@ -0,0 +1,10 @@ +opt_doq = get_option('dns-over-quic') +conf.set('HAVE_DNS_OVER_QUIC', opt_doq, description: 'DNS over QUIC (DoQ)') + +if opt_doq + if not dep_libquiche.found() + error('DNS over QUIC support was requested but Quiche support is not enabled') + endif +endif + +summary('DNS over QUIC', opt_doq, bool_yn: true, section: 'Configuration') diff --git a/pdns/dnsdistdist/meson/dot b/pdns/dnsdistdist/meson/dot new file mode 120000 index 000000000000..125641e9b6ef --- /dev/null +++ b/pdns/dnsdistdist/meson/dot @@ -0,0 +1 @@ +../../../meson/dot \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/ebpf/meson.build b/pdns/dnsdistdist/meson/ebpf/meson.build new file mode 100644 index 000000000000..eae610b5ef0f --- /dev/null +++ b/pdns/dnsdistdist/meson/ebpf/meson.build @@ -0,0 +1,8 @@ +if get_option('ebpf').allowed() + if cxx.check_header('linux/bpf.h') and cxx.get_define('SO_ATTACH_BPF', prefix: '#include "sys/socket.h"') != '' + conf.set('HAVE_EBPF', true, description: 'eBPF') + summary('eBPF', true, bool_yn: true, section: 'eBPF') + else + summary('eBPF', false, bool_yn: true, section: 'eBPF') + endif +endif diff --git a/pdns/dnsdistdist/meson/gnutls b/pdns/dnsdistdist/meson/gnutls new file mode 120000 index 000000000000..896dade75da8 --- /dev/null +++ b/pdns/dnsdistdist/meson/gnutls @@ -0,0 +1 @@ +../../../meson/gnutls \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/h2o/meson.build b/pdns/dnsdistdist/meson/h2o/meson.build new file mode 100644 index 000000000000..4c758f04c843 --- /dev/null +++ b/pdns/dnsdistdist/meson/h2o/meson.build @@ -0,0 +1,16 @@ +opt_h2o = get_option('h2o') +dep_libh2o_evloop = dependency('libh2o-evloop', required: opt_h2o) + +if dep_libh2o_evloop.found() + funcs = [ + 'h2o_socket_get_ssl_server_name', + ] + + foreach func: funcs + has = cxx.has_function(func, dependencies: dep_libh2o_evloop) + conf.set('HAVE_' + func.to_upper(), has, description: 'Have h2o ' + func) + endforeach +endif + +conf.set('HAVE_LIBH2OEVLOOP', dep_libh2o_evloop.found(), description: 'H2O library with event loop support for DNS over HTTP/2') +summary('H2O library with event loop support for DNS over HTTP/2', dep_libh2o_evloop.found(), bool_yn: true, section: 'DNS over HTTP/2') diff --git a/pdns/dnsdistdist/meson/hardening b/pdns/dnsdistdist/meson/hardening new file mode 120000 index 000000000000..d1b676de8568 --- /dev/null +++ b/pdns/dnsdistdist/meson/hardening @@ -0,0 +1 @@ +../../../meson/hardening \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/ipcipher b/pdns/dnsdistdist/meson/ipcipher new file mode 120000 index 000000000000..ecd1d7045880 --- /dev/null +++ b/pdns/dnsdistdist/meson/ipcipher @@ -0,0 +1 @@ +../../../meson/ipcipher \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/kiss-rng b/pdns/dnsdistdist/meson/kiss-rng new file mode 120000 index 000000000000..268370c5fad5 --- /dev/null +++ b/pdns/dnsdistdist/meson/kiss-rng @@ -0,0 +1 @@ +../../../meson/kiss-rng \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/libcap/meson.build b/pdns/dnsdistdist/meson/libcap/meson.build new file mode 100644 index 000000000000..9c1e0282bb22 --- /dev/null +++ b/pdns/dnsdistdist/meson/libcap/meson.build @@ -0,0 +1,5 @@ +opt_libcap = get_option('libcap') +dep_libcap = dependency('libcap', required: opt_libcap) + +conf.set('HAVE_LIBCAP', dep_libcap.found(), description: 'libcap support') +summary('libcap support', dep_libcap.found(), bool_yn: true, section: 'Capabilities') diff --git a/pdns/dnsdistdist/meson/libcrypto/bn_new.cc b/pdns/dnsdistdist/meson/libcrypto/bn_new.cc new file mode 100644 index 000000000000..194d9a66dfc0 --- /dev/null +++ b/pdns/dnsdistdist/meson/libcrypto/bn_new.cc @@ -0,0 +1,7 @@ +#include + +int main() +{ + BN_new(); + return 0; +} diff --git a/pdns/dnsdistdist/meson/libcrypto/ecdsa/meson.build b/pdns/dnsdistdist/meson/libcrypto/ecdsa/meson.build new file mode 100644 index 000000000000..69419a89088b --- /dev/null +++ b/pdns/dnsdistdist/meson/libcrypto/ecdsa/meson.build @@ -0,0 +1,33 @@ +prefix = ''' +#include +#include +''' +found = cxx.has_header( + 'openssl/ecdsa.h', + dependencies: dep_libcrypto, + prefix: prefix, + required: false +) + +if found + syms = [ + 'NID_X9_62_prime256v1', + 'NID_secp384r1', + ] + + foreach sym: syms + found = cxx.has_header_symbol( + 'openssl/evp.h', + sym, + dependencies: dep_libcrypto, + required: false + ) + + if not found + break + endif + endforeach +endif + +conf.set('HAVE_LIBCRYPTO_ECDSA', found, description: 'OpenSSL libcrypto ECDSA') +summary('OpenSSL libcrypto ECDSA', found, bool_yn: true, section: 'Crypto') diff --git a/pdns/dnsdistdist/meson/libcrypto/eddsa/meson.build b/pdns/dnsdistdist/meson/libcrypto/eddsa/meson.build new file mode 100644 index 000000000000..95157ab44e67 --- /dev/null +++ b/pdns/dnsdistdist/meson/libcrypto/eddsa/meson.build @@ -0,0 +1,24 @@ +syms = [ + 'ED25519', + 'ED448', +] + +found = false +foreach sym: syms + has = cxx.has_header_symbol( + 'openssl/evp.h', + 'NID_' + sym, + dependencies: dep_libcrypto, + required: false, + ) + + conf.set('HAVE_LIBCRYPTO_' + sym, has, description: 'OpenSSL libcrypto ' + sym) + summary('OpenSSL libcrypto ' + sym, has, bool_yn: true, section: 'Crypto') + + if has + found = true + endif +endforeach + +conf.set('HAVE_LIBCRYPTO_EDDSA', found, description: 'OpenSSL EdDSA support') +summary('OpenSSL libcrypto EdDSA', found, bool_yn: true, section: 'Crypto') diff --git a/pdns/dnsdistdist/meson/libcrypto/meson.build b/pdns/dnsdistdist/meson/libcrypto/meson.build new file mode 100644 index 000000000000..9bb2d1ff7ac3 --- /dev/null +++ b/pdns/dnsdistdist/meson/libcrypto/meson.build @@ -0,0 +1,119 @@ +opt_libcrypto = get_option('libcrypto') +opt_libcrypto_path = get_option('libcrypto-path') +dep_libcrypto = dependency('', required: false) + +ssldirs = [] + +if opt_libcrypto.disabled() + if opt_libcrypto_path != '' + warning('The libcrypto option is set to `disabled` ' + + 'but a path (' + opt_libcrypto_path + ') was given ' + + 'for libcrypto-path: It is going to be ignored.') + endif + + summary('OpenSSL libcrypto', false, bool_yn: true, section: 'Crypto') + subdir_done() +endif + +# Give precedence to the custom path passed in by the user. If not, the try to find +# libcrypto using the mechanisms provided by meson (e.g. pkg-config). If that cannot be +# found, then look in some hard-coded paths below. +if opt_libcrypto_path == '' + dep_libcrypto = dependency('libcrypto', required: false) +else + ssldirs = [opt_libcrypto_path] +endif + +if not dep_libcrypto.found() + warning('Could not find the libcrypto dependency, going to try to find it manually') + + if ssldirs.length() == 0 + # Could not find libcrypto through pkg-config and no custom directory was passed to + # find the library and its headers, so try to find it in some default locations. + ssldirs = [ + '/usr/local/ssl', + '/usr/lib/ssl', + '/usr/ssl', + '/usr/pkg', + '/usr/local', + '/usr' + ] + endif + + foreach dir: ssldirs + have = cxx.has_header(dir / 'include/openssl/crypto.h') + if have + dep_libcrypto = declare_dependency( + compile_args: ['-L' + dir / 'lib'], + link_args: ['-lcrypto'], + include_directories: include_directories(dir / 'include', is_system: false), + ) + break + endif + endforeach +endif + +if not dep_libcrypto.found() + err_msg = 'Could not find libcrypto in ' + ', '.join(ssldirs) + + if opt_libcrypto == 'auto' + # We could not find libcrypto anywhere, and the user did not require it. + warning(err_msg) + summary('OpenSSL libcrypto', false, bool_yn: true, section: 'Crypto') + subdir_done() + endif + + error(err_msg) +endif + +if not cxx.links(fs.read('bn_new.cc'), name: 'libcrypto test program', dependencies: dep_libcrypto) + err_msg = 'Cannot link against libcrypto' + + if opt_libcrypto == 'auto' + # We could not link against libcrypto, and the user did not require it. + warning(err_msg) + summary('OpenSSL libcrypto', false, bool_yn: true, section: 'Crypto') + subdir_done() + endif + + error(err_msg) +endif + +funcs = [ + 'RAND_bytes', + 'RAND_pseudo_bytes', + 'CRYPTO_memcmp', + 'OPENSSL_init_crypto', + 'EVP_MD_CTX_new', + 'EVP_MD_CTX_free', + 'RSA_get0_key', + 'OCSP_basic_sign', +] + +foreach func: funcs + has = cxx.has_function(func, dependencies: dep_libcrypto) + conf.set('HAVE_' + func.to_upper(), has, description: 'Have libcrypto ' + func) +endforeach + +prefix = ''' +#include +#include +''' +has = cxx.has_header_symbol( + 'openssl/kdf.h', + 'EVP_PKEY_CTX_set1_scrypt_salt', + dependencies: dep_libcrypto, + prefix: prefix, + required: false, +) +conf.set( + 'HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT', + has, + description: 'Have libcrypto EVP_PKEY_CTX_set1_scrypt_salt', +) + +conf.set('HAVE_LIBCRYPTO', dep_libcrypto.found(), description: 'OpenSSL libcrypto') +summary('OpenSSL libcrypto', dep_libcrypto.found(), bool_yn: true, section: 'Crypto') + +subdir('ecdsa') # ECDSA +subdir('eddsa') # EDDSA diff --git a/pdns/dnsdistdist/meson/libdir b/pdns/dnsdistdist/meson/libdir new file mode 120000 index 000000000000..9edafc7f6eef --- /dev/null +++ b/pdns/dnsdistdist/meson/libdir @@ -0,0 +1 @@ +../../../meson/libdir \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/libedit/meson.build b/pdns/dnsdistdist/meson/libedit/meson.build new file mode 100644 index 000000000000..55c2e298873f --- /dev/null +++ b/pdns/dnsdistdist/meson/libedit/meson.build @@ -0,0 +1,9 @@ +opt_libedit = get_option('libedit') +dep_libedit = dependency('libedit', required: false) + +if not dep_libedit.found() + dep_libedit = cxx.find_library('edit', required: opt_libedit) +endif + +conf.set('HAVE_LIBEDIT', dep_libedit.found(), description: 'libedit support') +summary('libedit support', dep_libedit.found(), bool_yn: true, section: 'Edit') diff --git a/pdns/dnsdistdist/meson/libsnmp/meson.build b/pdns/dnsdistdist/meson/libsnmp/meson.build new file mode 100644 index 000000000000..cdf26a9e5bee --- /dev/null +++ b/pdns/dnsdistdist/meson/libsnmp/meson.build @@ -0,0 +1,33 @@ +opt_libsnmp = get_option('snmp') + +dep_libsnmp = dependency('', required: false) + +if opt_libsnmp + snmp_config = find_program('net-snmp-config', required: true) + snmp_ldflags_res = run_command(snmp_config, '--netsnmp-agent-libs', check: true) + snmp_ldflags = snmp_ldflags_res.stdout().strip().split() + + dep_libsnmp = declare_dependency( + link_args: snmp_ldflags, + ) + + if dep_libsnmp.found() + funcs = [ + 'snmp_select_info2', + ] + + foreach func: funcs + define = 'HAVE_' + func.to_upper() + have_func = cxx.has_function(func, dependencies: dep_libsnmp, prefix: '''#include + #include + #include + #include + #include + #include ''') + conf.set(define, have_func, description: 'Have libsnmp ' + func) + endforeach + endif +endif + +conf.set('HAVE_NET_SNMP', dep_libsnmp.found(), description: 'libsnmp') +summary('SNMP', dep_libsnmp.found(), bool_yn: true, section: 'Configuration') diff --git a/pdns/dnsdistdist/meson/libsodium/meson.build b/pdns/dnsdistdist/meson/libsodium/meson.build new file mode 100644 index 000000000000..661030d47b23 --- /dev/null +++ b/pdns/dnsdistdist/meson/libsodium/meson.build @@ -0,0 +1,21 @@ +opt_libsodium = get_option('libsodium') +dep_libsodium = dependency('libsodium', required: opt_libsodium) + +if dep_libsodium.found() + funcs = [ + 'crypto_box_easy_afternm', + 'crypto_box_curve25519xchacha20poly1305_easy', + 'randombytes_stir', + 'sodium_memcmp', + 'crypto_shorthash' + ] + + foreach func: funcs + define = 'HAVE_' + func.to_upper() + have_func = cxx.has_function(func, dependencies: dep_libsodium) + conf.set(define, have_func, description: 'Have libsodium ' + func) + endforeach +endif + +conf.set('HAVE_LIBSODIUM', dep_libsodium.found(), description: 'libsodium support') +summary('libsodium support', dep_libsodium.found(), bool_yn: true, section: 'Crypto') diff --git a/pdns/dnsdistdist/meson/libssl b/pdns/dnsdistdist/meson/libssl new file mode 120000 index 000000000000..c594bbd4141b --- /dev/null +++ b/pdns/dnsdistdist/meson/libssl @@ -0,0 +1 @@ +../../../meson/libssl \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/libssl-providers/meson.build b/pdns/dnsdistdist/meson/libssl-providers/meson.build new file mode 100644 index 000000000000..6bd3f24b0a60 --- /dev/null +++ b/pdns/dnsdistdist/meson/libssl-providers/meson.build @@ -0,0 +1,16 @@ +opt_libssl_providers = get_option('tls-libssl-providers') + +if opt_libssl_providers + opt_libssl = get_option('tls-libssl') + if not opt_libssl.allowed() + error('OpenSSL TLS providers requested but libssl is not enabled') + endif + dep_libssl_3_later = dependency('libssl >= 3.0', required: false) + + if not dep_libssl_3_later.found() + error('OpenSSL TLS providers requested but libssl is not >= 3.0') + endif + + conf.set('HAVE_TLS_PROVIDERS', dep_libssl_3_later.found(), description: 'OpenSSL libssl providers') + summary('OpenSSL libssl providers', dep_libssl_3_later.found(), bool_yn: true, section: 'Crypto') +endif diff --git a/pdns/dnsdistdist/meson/libsystemd b/pdns/dnsdistdist/meson/libsystemd new file mode 120000 index 000000000000..a2be793ee754 --- /dev/null +++ b/pdns/dnsdistdist/meson/libsystemd @@ -0,0 +1 @@ +../../../meson/libsystemd \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/lmdb/meson.build b/pdns/dnsdistdist/meson/lmdb/meson.build new file mode 100644 index 000000000000..56eb8a852f3f --- /dev/null +++ b/pdns/dnsdistdist/meson/lmdb/meson.build @@ -0,0 +1,8 @@ +opt_lmdb = get_option('lmdb') +dep_lmdb = dependency('lmdb', required: opt_lmdb) + +conf.set('HAVE_LMDB', dep_lmdb.found(), description: 'Whether we have LMDB') +summary('LMDB', dep_lmdb.found(), bool_yn: true, section: 'Key-Value') +if dep_lmdb.found() + summary('LMDB version', dep_lmdb.version(), bool_yn: true, section: 'Key-Value') +endif diff --git a/pdns/dnsdistdist/meson/lua/meson.build b/pdns/dnsdistdist/meson/lua/meson.build new file mode 100644 index 000000000000..f1cd312155b6 --- /dev/null +++ b/pdns/dnsdistdist/meson/lua/meson.build @@ -0,0 +1,52 @@ +opt_lua = get_option('lua') +dep_lua = dependency('', required: false) + +if opt_lua == 'auto' or opt_lua == 'luajit' + dep_lua = dependency( + 'luajit', + version: '>= 2.0.2', + required: opt_lua == 'luajit', + not_found_message: 'LuaJIT not found', + ) +endif + +if not dep_lua.found() and (opt_lua == 'auto' or opt_lua == 'lua') + variants = [ + 'lua5.3', + 'lua-5.3', + 'lua53', + 'lua5.2', + 'lua-5.2', + 'lua52', + 'lua5.1', + 'lua-5.1', + 'lua51', + 'lua', + ] + + foreach variant: variants + dep_lua = dependency(variant, version: '>= 5.1', required: false) + if dep_lua.found() + break + endif + endforeach +endif + +if not dep_lua.found() + error('No Lua implementation was found') +endif + +have_luahpp = cxx.has_header('lua.hpp', dependencies: dep_lua) + +conf.set('HAVE_LUA', dep_lua.found(), description: 'Lua') +conf.set('HAVE_LUA_HPP', have_luahpp, description: 'Have ') + +if dep_lua.found() and dep_lua.name() == 'luajit' + # export all symbols with default visibility, to be able to use the Lua FFI interface + add_project_link_arguments('-rdynamic', language: ['c', 'cpp']) +endif + +summary('Lua', dep_lua.found(), bool_yn: true, section: 'Lua') +summary('Implementation', dep_lua.name(), section: 'Lua') +summary('Version', dep_lua.version(), section: 'Lua') +summary('Have ', have_luahpp, bool_yn: true, section: 'Lua') diff --git a/pdns/dnsdistdist/meson/mmap b/pdns/dnsdistdist/meson/mmap new file mode 120000 index 000000000000..e8c0d478dff5 --- /dev/null +++ b/pdns/dnsdistdist/meson/mmap @@ -0,0 +1 @@ +../../../meson/mmap \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/net-libs b/pdns/dnsdistdist/meson/net-libs new file mode 120000 index 000000000000..537e40d4c672 --- /dev/null +++ b/pdns/dnsdistdist/meson/net-libs @@ -0,0 +1 @@ +../../../meson/net-libs \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/nghttp2/meson.build b/pdns/dnsdistdist/meson/nghttp2/meson.build new file mode 100644 index 000000000000..6a3d3d090cd6 --- /dev/null +++ b/pdns/dnsdistdist/meson/nghttp2/meson.build @@ -0,0 +1,18 @@ +opt_libnghttp2 = get_option('nghttp2') +dep_libnghttp2 = dependency('libnghttp2', required: opt_libnghttp2) + +if dep_libnghttp2.found() + funcs = [ + 'nghttp2_check_header_value_rfc9113', + 'nghttp2_check_method', + 'nghttp2_check_path' + ] + + foreach func: funcs + has = cxx.has_function(func, dependencies: dep_libnghttp2) + conf.set('HAVE_' + func.to_upper(), has, description: 'Have nghttp2 ' + func) + endforeach +endif + +conf.set('HAVE_NGHTTP2', dep_libnghttp2.found(), description: 'nghttp2') +summary('nghttp2', dep_libnghttp2.found(), bool_yn: true, section: 'DNS over HTTP/2') diff --git a/pdns/dnsdistdist/meson/platform b/pdns/dnsdistdist/meson/platform new file mode 120000 index 000000000000..89e25b3c21e5 --- /dev/null +++ b/pdns/dnsdistdist/meson/platform @@ -0,0 +1 @@ +../../../meson/platform \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/pthread-headers b/pdns/dnsdistdist/meson/pthread-headers new file mode 120000 index 000000000000..509fbec999ad --- /dev/null +++ b/pdns/dnsdistdist/meson/pthread-headers @@ -0,0 +1 @@ +../../../meson/pthread-headers \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/pthread-np b/pdns/dnsdistdist/meson/pthread-np new file mode 120000 index 000000000000..268e4f6166e8 --- /dev/null +++ b/pdns/dnsdistdist/meson/pthread-np @@ -0,0 +1 @@ +../../../meson/pthread-np \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/pthread-setname b/pdns/dnsdistdist/meson/pthread-setname new file mode 120000 index 000000000000..275555d5d037 --- /dev/null +++ b/pdns/dnsdistdist/meson/pthread-setname @@ -0,0 +1 @@ +../../../meson/pthread-setname \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/quiche/meson.build b/pdns/dnsdistdist/meson/quiche/meson.build new file mode 100644 index 000000000000..0774c1a58dd8 --- /dev/null +++ b/pdns/dnsdistdist/meson/quiche/meson.build @@ -0,0 +1,15 @@ +dep_libquiche = dependency('', required: false) +opt_libquiche = get_option('quiche') + +if (get_option('dns-over-quic') or get_option('dns-over-http3')) and opt_libquiche.allowed() + dep_libquiche = dependency('quiche', version: '>= 0.22.0', required: opt_libquiche) + + if dep_libquiche.found() + conf.set('HAVE_QUICHE_STREAM_ERROR_CODES', dep_libquiche.found(), description: 'if the Quiche API includes error code in quiche_conn_stream_recv and quiche_conn_stream_send') + else + dep_libquiche = dependency('quiche', version: '>= 0.15.0', required: opt_libquiche) + endif +endif + +conf.set('HAVE_QUICHE', dep_libquiche.found(), description: 'quiche') +summary('Quiche', dep_libquiche.found(), bool_yn: true, section: 'DNS over QUIC / HTTP3') diff --git a/pdns/dnsdistdist/meson/re2/meson.build b/pdns/dnsdistdist/meson/re2/meson.build new file mode 100644 index 000000000000..f85c297fb571 --- /dev/null +++ b/pdns/dnsdistdist/meson/re2/meson.build @@ -0,0 +1,5 @@ +opt_libre2 = get_option('re2') +dep_libre2 = dependency('re2', required: opt_libre2) + +conf.set('HAVE_RE2', dep_libre2.found(), description: 're2') +summary('Re2', dep_libre2.found(), bool_yn: true, section: 're2') diff --git a/pdns/dnsdistdist/meson/reproducible b/pdns/dnsdistdist/meson/reproducible new file mode 120000 index 000000000000..d9edaa090781 --- /dev/null +++ b/pdns/dnsdistdist/meson/reproducible @@ -0,0 +1 @@ +../../../meson/reproducible \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/sanitizers b/pdns/dnsdistdist/meson/sanitizers new file mode 120000 index 000000000000..0a784a7d50ea --- /dev/null +++ b/pdns/dnsdistdist/meson/sanitizers @@ -0,0 +1 @@ +../../../meson/sanitizers \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/strerror b/pdns/dnsdistdist/meson/strerror new file mode 120000 index 000000000000..598b9f379ca1 --- /dev/null +++ b/pdns/dnsdistdist/meson/strerror @@ -0,0 +1 @@ +../../../meson/strerror \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/summary b/pdns/dnsdistdist/meson/summary new file mode 120000 index 000000000000..3f61f3e4e449 --- /dev/null +++ b/pdns/dnsdistdist/meson/summary @@ -0,0 +1 @@ +../../../meson/summary \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/sysconfdir b/pdns/dnsdistdist/meson/sysconfdir new file mode 120000 index 000000000000..a44a2e4927e5 --- /dev/null +++ b/pdns/dnsdistdist/meson/sysconfdir @@ -0,0 +1 @@ +../../../meson/sysconfdir \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/systemd b/pdns/dnsdistdist/meson/systemd new file mode 120000 index 000000000000..11db1eb97ea6 --- /dev/null +++ b/pdns/dnsdistdist/meson/systemd @@ -0,0 +1 @@ +../../../meson/systemd \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/timet-sign b/pdns/dnsdistdist/meson/timet-sign new file mode 120000 index 000000000000..c0fb86f7298d --- /dev/null +++ b/pdns/dnsdistdist/meson/timet-sign @@ -0,0 +1 @@ +../../../meson/timet-sign \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/timet-size b/pdns/dnsdistdist/meson/timet-size new file mode 120000 index 000000000000..c4662a456829 --- /dev/null +++ b/pdns/dnsdistdist/meson/timet-size @@ -0,0 +1 @@ +../../../meson/timet-size \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/tm-gmtoff b/pdns/dnsdistdist/meson/tm-gmtoff new file mode 120000 index 000000000000..e0b0dbcf6cd4 --- /dev/null +++ b/pdns/dnsdistdist/meson/tm-gmtoff @@ -0,0 +1 @@ +../../../meson/tm-gmtoff \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/various-functions b/pdns/dnsdistdist/meson/various-functions new file mode 120000 index 000000000000..9c14861d7b5b --- /dev/null +++ b/pdns/dnsdistdist/meson/various-functions @@ -0,0 +1 @@ +../../../meson/various-functions \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/various-headers b/pdns/dnsdistdist/meson/various-headers new file mode 120000 index 000000000000..3ab83415d651 --- /dev/null +++ b/pdns/dnsdistdist/meson/various-headers @@ -0,0 +1 @@ +../../../meson/various-headers \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/version b/pdns/dnsdistdist/meson/version new file mode 120000 index 000000000000..39c9fdfdd11a --- /dev/null +++ b/pdns/dnsdistdist/meson/version @@ -0,0 +1 @@ +../../../meson/version \ No newline at end of file diff --git a/pdns/dnsdistdist/meson/xsk/meson.build b/pdns/dnsdistdist/meson/xsk/meson.build new file mode 100644 index 000000000000..95f2c0beef8e --- /dev/null +++ b/pdns/dnsdistdist/meson/xsk/meson.build @@ -0,0 +1,13 @@ +opt_xsk = get_option('xsk') +if opt_xsk.allowed() + dep_libbpf = dependency('libbpf', required: opt_xsk) + dep_libxdp = dependency('libxdp', required: opt_xsk) + + conf.set('HAVE_BPF', dep_libbpf.found(), description: 'BPF library') + conf.set('HAVE_XDP', dep_libxdp.found(), description: 'XDP library') + conf.set('HAVE_XSK', dep_libbpf.found() and dep_libxdp.found(), description: 'AF_XDP (XSK) support enabled') + summary('AF_XDP (XSK)', dep_libbpf.found() and dep_libxdp.found(), bool_yn: true, section: 'XSK') +else + dep_libpf = declare_dependency() + dep_libxdp = declare_dependency() +endif diff --git a/pdns/dnsdistdist/meson_options.txt b/pdns/dnsdistdist/meson_options.txt new file mode 100644 index 000000000000..7798899149c5 --- /dev/null +++ b/pdns/dnsdistdist/meson_options.txt @@ -0,0 +1,38 @@ +option('dnscrypt', type: 'feature', value: 'disabled', description: 'Enable DNSCrypt') +option('libcap', type: 'feature', value: 'auto', description: 'Enable libcap for capabilities handling') +option('libedit', type: 'feature', value: 'enabled', description: 'Enable libedit') +option('libsodium', type: 'feature', value: 'auto', description: 'Enable libsodium') +option('libcrypto', type: 'feature', value: 'auto', description: 'Enable OpenSSL libcrypto)') +option('libcrypto-path', type: 'string', value: '', description: 'Custom path to find OpenSSL libcrypto') +option('tls-gnutls', type: 'feature', value: 'auto', description: 'GnuTLS-based TLS') +option('lua', type: 'combo', choices: ['auto', 'luajit', 'lua'], value: 'auto', description: 'Lua implementation to use') +option('hardening', type: 'feature', value: 'auto', description: 'Compiler security checks') +option('hardening-experimental-cf', type: 'combo', choices: ['disabled', 'full', 'branch', 'return', 'check'], value: 'disabled', description: 'Control Flow hardening') +option('hardening-experimental-scp', type: 'feature', value: 'disabled', description: 'Stack Clash Protection') +option('hardening-fortify-source', type: 'combo', choices: ['auto', 'disabled', '1', '2', '3'], value: '2', description: 'Source fortification level') +option('ipcipher', type: 'feature', value: 'auto', description: 'IPCipher') +#option('rng-kiss', type: 'boolean', value: false, description: 'Use the unsafe KISS RNG') +option('tls-libssl', type: 'feature', value: 'auto', description: 'OpenSSL-based TLS') +option('tls-libssl-providers', type: 'boolean', value: false, description: 'OpenSSL-based TLS with TLS providers') +option('dns-over-tls', type: 'boolean', value: false, description: 'DNS over TLS (requires GnuTLS or OpenSSL)') +option('dns-over-https', type: 'boolean', value: false, description: 'DNS over HTTP/2 (requires GnuTLS or OpenSSL)') +option('dns-over-http3', type: 'boolean', value: false, description: 'Enable DNS over HTTP/3') +option('dns-over-quic', type: 'boolean', value: false, description: 'Enable DNS over QUIC') +option('unit-tests', type: 'boolean', value: false, description: 'Build and run unit tests') +option('reproducible', type: 'boolean', value: false, description: 'Reproducible builds (for distro maintainers, makes debugging difficult)') +option('systemd', type: 'feature', value: 'auto', description: 'Systemd notification (requires libsystemd)') +option('systemd-service-user', type: 'string', value: 'dnsdist', description: 'Systemd service user (setuid and unit file; user is not created)') +option('systemd-service-group', type: 'string', value: 'dnsdist', description: 'Systemd service group (setgid and unit file; group is not created)') +option('auto-var-init', type: 'combo', value: 'disabled', choices: ['zero', 'pattern', 'disabled'], description: 'Enable initialization of automatic variables') +option('snmp', type: 'boolean', value: false, description: 'Enable SNMP') +option('dnstap', type: 'feature', value: 'auto', description: 'Enable DNSTAP support through libfstrm') +option('h2o', type: 'feature', value: 'disabled', description: 'Enable H2O library with event loop support for DNS over HTTP/2') +option('nghttp2', type: 'feature', value: 'auto', description: 'Enable nghttp2 library support for DNS over HTTP/2') +option('cdb', type: 'feature', value: 'auto', description: 'CDB key-value store support') +option('lmdb', type: 'feature', value: 'auto', description: 'LMDB key-value store support') +option('quiche', type: 'feature', value: 'auto', description: 'Enable Quiche library support for DNS over QUIC and DNS over HTTP/3') +option('re2', type: 'feature', value: 'auto', description: 'Enable re2 for regular expressions') +option('xsk', type: 'feature', value: 'auto', description: 'Enable AF_XDP / XSK') +option('fuzz-targets', type: 'boolean', value: false, description: 'Enable fuzzing targets') +option('ebpf', type: 'feature', value: 'disabled', description: 'Enable eBPF support') +option('fuzzer_ldflags', type: 'string', value: '', description: 'Linker flags used for the fuzzing targets (a path to the libFuzzer static library, for example)') diff --git a/pdns/dnsdistdist/test-dnsdist-connections-cache.cc b/pdns/dnsdistdist/test-dnsdist-connections-cache.cc index fa113aa83a0f..00e879af2d44 100644 --- a/pdns/dnsdistdist/test-dnsdist-connections-cache.cc +++ b/pdns/dnsdistdist/test-dnsdist-connections-cache.cc @@ -71,8 +71,9 @@ class MockupConnection { } - void release(bool removeFomCache) + void release(bool removeFromCache) { + (void)removeFromCache; } std::shared_ptr getDS() const diff --git a/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc b/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc index 3de6749da9f5..11a22e2f463a 100644 --- a/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc +++ b/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc @@ -37,6 +37,7 @@ bool dnsdist::webserver::addMetricDefinition(const dnsdist::prometheus::PrometheusMetricDefinition& def) { + (void)def; return true; } diff --git a/pdns/dnsdistdist/test-dnsdist_cc.cc b/pdns/dnsdistdist/test-dnsdist_cc.cc index 1cca05f66c40..9e1a81f44925 100644 --- a/pdns/dnsdistdist/test-dnsdist_cc.cc +++ b/pdns/dnsdistdist/test-dnsdist_cc.cc @@ -45,26 +45,43 @@ ProcessQueryResult processQueryAfterRules(DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) { + (void)dnsQuestion; + (void)selectedBackend; return ProcessQueryResult::Drop; } bool processResponseAfterRules(PacketBuffer& response, DNSResponse& dnsResponse, bool muted) { + (void)response; + (void)dnsResponse; + (void)muted; return false; } bool applyRulesToResponse(const std::vector& respRuleActions, DNSResponse& dnsResponse) { + (void)respRuleActions; + (void)dnsResponse; return true; } bool sendUDPResponse(int origFD, const PacketBuffer& response, const int delayMsec, const ComboAddress& origDest, const ComboAddress& origRemote) { + (void)origFD; + (void)response; + (void)delayMsec; + (void)origDest; + (void)origRemote; return false; } bool assignOutgoingUDPQueryToBackend(std::shared_ptr& downstream, uint16_t queryID, DNSQuestion& dnsQuestion, PacketBuffer& query, bool actuallySend) { + (void)downstream; + (void)queryID; + (void)dnsQuestion; + (void)query; + (void)actuallySend; return true; } @@ -72,6 +89,8 @@ namespace dnsdist { std::unique_ptr getInternalQueryFromDQ(DNSQuestion& dnsQuestion, bool isResponse) { + (void)dnsQuestion; + (void)isResponse; return nullptr; } } @@ -87,6 +106,8 @@ namespace dnsdist::xsk { bool XskProcessQuery(ClientState& clientState, XskPacket& packet) { + (void)clientState; + (void)packet; return false; } } @@ -94,6 +115,9 @@ bool XskProcessQuery(ClientState& clientState, XskPacket& packet) bool processResponderPacket(std::shared_ptr& dss, PacketBuffer& response, InternalQueryState&& ids) { + (void)dss; + (void)response; + (void)ids; return false; } diff --git a/pdns/dnsdistdist/test-dnsdistbackoff.cc b/pdns/dnsdistdist/test-dnsdistbackoff.cc index 173d102694d4..236b43884d59 100644 --- a/pdns/dnsdistdist/test-dnsdistbackoff.cc +++ b/pdns/dnsdistdist/test-dnsdistbackoff.cc @@ -20,7 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef BOOST_TEST_DYN_LINK #define BOOST_TEST_DYN_LINK +#endif #define BOOST_TEST_NO_MAIN #include diff --git a/pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc b/pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc index 388389f66fba..4038655e10ac 100644 --- a/pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc +++ b/pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc @@ -1295,6 +1295,8 @@ BOOST_FIXTURE_TEST_CASE(test_DynBlockRulesMetricsCache_GetTopN, TestFixture) { { DynBlockRulesGroup::DynBlockRule rule(reason, blockDuration, 0, 0, numberOfSeconds, action); dbrg.setSuffixMatchRule(std::move(rule), [](const StatNode& node, const StatNode::Stat& self, const StatNode::Stat& children) { + (void)node; + (void)children; if (self.queries > 0) { return std::tuple, boost::optional>(true, boost::none, boost::none); } @@ -1355,6 +1357,8 @@ BOOST_FIXTURE_TEST_CASE(test_DynBlockRulesMetricsCache_GetTopN, TestFixture) { { DynBlockRulesGroup::DynBlockRule rule(reason, blockDuration, 0, 0, numberOfSeconds, action); dbrg.setSuffixMatchRule(std::move(rule), [](const StatNode& node, const StatNode::Stat& self, const StatNode::Stat& children) { + (void)node; + (void)children; if (self.queries > 0) { return std::tuple, boost::optional>(true, "blocked for a different reason", static_cast(DNSAction::Action::Truncate)); } diff --git a/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc b/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc index e641dc637154..93babba6d281 100644 --- a/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc @@ -35,6 +35,8 @@ bool TLSFrontend::setupTLS() // NOLINTNEXTLINE(readability-convert-member-functions-to-static): this is a stub, the real one is not that simple.. bool DNSDistSNMPAgent::sendDNSTrap(const DNSQuestion& dnsQuestion, const std::string& reason) { + (void)dnsQuestion; + (void)reason; return false; } @@ -44,6 +46,8 @@ void setLuaNoSideEffect() DNSAction::Action SpoofAction::operator()(DNSQuestion* dnsQuestion, std::string* ruleresult) const { + (void)dnsQuestion; + (void)ruleresult; return DNSAction::Action::None; } @@ -56,6 +60,7 @@ bool setupDoTProtocolNegotiation(std::shared_ptr& tlsCtx) // NOLINTNEXTLINE(performance-unnecessary-value-param): this is a stub, the real one is not that simple and the performance does not matter void responderThread(std::shared_ptr dss) { + (void)dss; } string g_outputBuffer; @@ -104,6 +109,8 @@ static void benchPolicy(const ServerPolicy& pol) } } cerr << pol.name << " took " << std::to_string(sw.udiff()) << " us for " << names.size() << endl; +#else + (void)pol; #endif /* BENCH_POLICIES */ } diff --git a/pdns/dnsdistdist/test-dnsdistluanetwork.cc b/pdns/dnsdistdist/test-dnsdistluanetwork.cc index 6ddc4a200587..e84b524dfe6e 100644 --- a/pdns/dnsdistdist/test-dnsdistluanetwork.cc +++ b/pdns/dnsdistdist/test-dnsdistluanetwork.cc @@ -42,6 +42,7 @@ BOOST_AUTO_TEST_CASE(test_Basic) BOOST_REQUIRE(fd >= 0); listener.addUnixListeningEndpoint(socketPath, 0, [&received, payload](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)from; BOOST_CHECK_EQUAL(endpoint, 0U); BOOST_CHECK(dgram == payload); received = true; @@ -76,7 +77,11 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) /* invalid path */ dnsdist::NetworkListener listener; BOOST_CHECK_THROW(listener.addUnixListeningEndpoint(std::string(), 0, - [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) {}), + [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; + }), std::runtime_error); bool caught = false; @@ -94,6 +99,9 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) dnsdist::NetworkListener listener; bool received = false; listener.addUnixListeningEndpoint(socketPath, 0, [&received](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; received = true; }); @@ -109,7 +117,11 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) bool raised = false; try { listener.addUnixListeningEndpoint(otherSocketPath, 0, - [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) {}); + [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; + }); } catch (const std::runtime_error& e) { raised = true; @@ -122,6 +134,9 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) dnsdist::NetworkListener listener; bool received = false; listener.addUnixListeningEndpoint(socketPath, 0, [&received](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; received = true; throw std::runtime_error("Test exception"); }); @@ -142,6 +157,9 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) dnsdist::NetworkListener listener; bool received = false; listener.addUnixListeningEndpoint(socketPath, 0, [&received](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; received = true; throw UnexpectedException(); }); @@ -169,6 +187,7 @@ BOOST_AUTO_TEST_CASE(test_Abstract) socketPath.insert(0, 1, 0); listener.addUnixListeningEndpoint(socketPath, 0, [&received, payload](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)from; BOOST_CHECK_EQUAL(endpoint, 0U); BOOST_CHECK(dgram == payload); received = true; @@ -189,13 +208,20 @@ BOOST_AUTO_TEST_CASE(test_Abstract_Exceptions) socketPath.insert(0, 1, 0); bool received = false; listener.addUnixListeningEndpoint(socketPath, 0, [&received](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; received = true; }); /* try binding twice to the same path */ bool raised = false; try { - listener.addUnixListeningEndpoint(socketPath, 0, [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) {}); + listener.addUnixListeningEndpoint(socketPath, 0, [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; + }); } catch (const std::runtime_error& e) { raised = true; diff --git a/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc b/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc index a24341f13ab6..d67288fe5737 100644 --- a/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc @@ -143,6 +143,9 @@ class DOHConnection nghttp2_data_provider data_provider; data_provider.source.ptr = this; data_provider.read_callback = [](nghttp2_session* session, int32_t stream_id, uint8_t* buf, size_t length, uint32_t* data_flags, nghttp2_data_source* source, void* user_data) -> ssize_t { + (void)session; + (void)stream_id; + (void)source; auto* conn = static_cast(user_data); auto& pos = conn->d_position; const auto& currentQuery = conn->d_currentQuery; @@ -197,6 +200,8 @@ class DOHConnection private: static ssize_t send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): nghttp2 API conn->d_clientOutBuffer.insert(conn->d_clientOutBuffer.end(), data, data + length); @@ -205,6 +210,7 @@ class DOHConnection static int on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; auto* conn = static_cast(user_data); if ((frame->hd.type == NGHTTP2_HEADERS || frame->hd.type == NGHTTP2_DATA) && (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) != 0) { const auto& response = conn->d_responses.at(frame->hd.stream_id); @@ -231,6 +237,8 @@ class DOHConnection static int on_data_chunk_recv_callback(nghttp2_session* session, uint8_t flags, int32_t stream_id, const uint8_t* data, size_t len, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); auto& response = conn->d_responses[stream_id]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): nghttp2 API @@ -240,6 +248,8 @@ class DOHConnection static int on_header_callback(nghttp2_session* session, const nghttp2_frame* frame, const uint8_t* name, size_t namelen, const uint8_t* value, size_t valuelen, uint8_t flags, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); const std::string status(":status"); if (frame->hd.type == NGHTTP2_HEADERS && frame->headers.cat == NGHTTP2_HCAT_RESPONSE) { @@ -266,6 +276,10 @@ class DOHConnection static int on_stream_close_callback(nghttp2_session* session, int32_t stream_id, uint32_t error_code, void* user_data) { + (void)session; + (void)stream_id; + (void)error_code; + (void)user_data; return 0; } }; @@ -361,6 +375,8 @@ class MockupTLSConnection : public TLSConnection IOState tryConnect(bool fastOpen, const ComboAddress& remote) override { + (void)fastOpen; + (void)remote; throw std::runtime_error("Should not happen"); } @@ -402,6 +418,7 @@ class MockupTLSConnection : public TLSConnection void setSession(std::unique_ptr& session) override { + (void)session; } [[nodiscard]] std::vector getAsyncFDs() override @@ -416,15 +433,26 @@ class MockupTLSConnection : public TLSConnection void connect(bool fastOpen, const ComboAddress& remote, const struct timeval& timeout) override { + (void)fastOpen; + (void)remote; + (void)timeout; } size_t read(void* buffer, size_t bufferSize, const struct timeval& readTimeout, const struct timeval& totalTimeout = {0, 0}, bool allowIncomplete = false) override { + (void)buffer; + (void)bufferSize; + (void)readTimeout; + (void)totalTimeout; + (void)allowIncomplete; return 0; } size_t write(const void* buffer, size_t bufferSize, const struct timeval& writeTimeout) override { + (void)buffer; + (void)bufferSize; + (void)writeTimeout; return 0; } @@ -560,6 +588,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { /* dnsdist sends a response right away, client closes the connection after getting the response */ s_processQuery = [response](DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)selectedBackend; /* self answered */ dnsQuestion.getMutableData() = response; return ProcessQueryResult::SendAnswer; @@ -591,6 +620,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { /* dnsdist sends a response right away, but the client closes the connection without even reading the response */ s_processQuery = [response](DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)selectedBackend; /* self answered */ dnsQuestion.getMutableData() = response; return ProcessQueryResult::SendAnswer; @@ -626,6 +656,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { /* dnsdist sends a response right away, client closes the connection while getting the response */ s_processQuery = [response](DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)selectedBackend; /* self answered */ dnsQuestion.getMutableData() = response; return ProcessQueryResult::SendAnswer; @@ -675,9 +706,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendTimeout, TestFixture) auto backend = std::make_shared(getBackendAddress("42", 53)); - struct timeval now - { - }; + timeval now{}; gettimeofday(&now, nullptr); size_t counter = 0; @@ -700,6 +729,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendTimeout, TestFixture) { /* dnsdist forwards the query to the backend, which does not answer -> timeout */ s_processQuery = [backend](DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dnsQuestion; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; diff --git a/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc b/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc index 98c37243e334..60e0fca09981 100644 --- a/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc @@ -168,6 +168,9 @@ class DOHConnection nghttp2_data_provider dataProvider; dataProvider.source.ptr = &data; dataProvider.read_callback = [](nghttp2_session* session, int32_t stream_id, uint8_t* buf, size_t length, uint32_t* data_flags, nghttp2_data_source* source, void* user_data) -> ssize_t { + (void)session; + (void)stream_id; + (void)user_data; auto buffer = reinterpret_cast(source->ptr); size_t toCopy = 0; if (buffer->size() > 0) { @@ -193,6 +196,7 @@ class DOHConnection void submitError(uint32_t streamId, uint16_t status, const std::string& msg) { + (void)msg; const std::string statusStr = std::to_string(status); const nghttp2_nv hdrs[] = {{(uint8_t*)":status", (uint8_t*)statusStr.c_str(), sizeof(":status") - 1, statusStr.size(), NGHTTP2_NV_FLAG_NONE}}; @@ -215,6 +219,8 @@ class DOHConnection private: static ssize_t send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data) { + (void)session; + (void)flags; DOHConnection* conn = reinterpret_cast(user_data); // cerr<<"inserting "<d_serverOutBuffer.size()<d_idMapping.empty() && length > 9) { @@ -240,6 +246,7 @@ class DOHConnection static int on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; DOHConnection* conn = reinterpret_cast(user_data); // cerr<<"Frame type is "<hd.type)<hd.type == NGHTTP2_HEADERS || frame->hd.type == NGHTTP2_DATA) && frame->hd.flags & NGHTTP2_FLAG_END_STREAM) { @@ -295,6 +302,8 @@ class DOHConnection static int on_data_chunk_recv_callback(nghttp2_session* session, uint8_t flags, int32_t stream_id, const uint8_t* data, size_t len, void* user_data) { + (void)session; + (void)flags; DOHConnection* conn = reinterpret_cast(user_data); auto& query = conn->d_queries[stream_id]; query.insert(query.end(), data, data + len); @@ -303,6 +312,9 @@ class DOHConnection static int on_stream_close_callback(nghttp2_session* session, int32_t stream_id, uint32_t error_code, void* user_data) { + (void)session; + (void)stream_id; + (void)user_data; if (error_code == 0) { return 0; } @@ -397,6 +409,8 @@ class MockupTLSConnection : public TLSConnection IOState tryConnect(bool fastOpen, const ComboAddress& remote) override { + (void)fastOpen; + (void)remote; auto step = getStep(); BOOST_REQUIRE_EQUAL(step.request, ExpectedStep::ExpectedRequest::connectToBackend); @@ -441,6 +455,7 @@ class MockupTLSConnection : public TLSConnection void setSession(std::unique_ptr& session) override { + (void)session; } std::vector getAsyncFDs() override @@ -455,15 +470,26 @@ class MockupTLSConnection : public TLSConnection void connect(bool fastOpen, const ComboAddress& remote, const struct timeval& timeout) override { + (void)fastOpen; + (void)remote; + (void)timeout; } size_t read(void* buffer, size_t bufferSize, const struct timeval& readTimeout, const struct timeval& totalTimeout = {0, 0}, bool allowIncomplete = false) override { + (void)buffer; + (void)bufferSize; + (void)readTimeout; + (void)totalTimeout; + (void)allowIncomplete; return 0; } size_t write(const void* buffer, size_t bufferSize, const struct timeval& writeTimeout) override { + (void)buffer; + (void)bufferSize; + (void)writeTimeout; return 0; } @@ -780,10 +806,12 @@ BOOST_FIXTURE_TEST_CASE(test_ConnectionReuse, TestFixture) {ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, std::numeric_limits::max()}, /* acknowledge settings */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max(), [&firstQueryDone](int desc) { + (void)desc; firstQueryDone = true; }}, /* headers */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max(), [](int desc) { + (void)desc; }}, /* data */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max(), [](int desc) { @@ -794,6 +822,7 @@ BOOST_FIXTURE_TEST_CASE(test_ConnectionReuse, TestFixture) {ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, std::numeric_limits::max()}, /* later the backend sends a go away frame */ {ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, std::numeric_limits::max(), [](int desc) { + (void)desc; s_connectionBuffers.at(desc)->submitGoAway(); }}, {ExpectedStep::ExpectedRequest::closeBackend, IOState::Done}, @@ -867,6 +896,7 @@ BOOST_FIXTURE_TEST_CASE(test_InvalidDNSAnswer, TestFixture) auto sender = std::make_shared(); sender->d_id = counter; sender->d_customHandler = [](uint16_t id, const struct timeval&, TCPResponse&& resp) { + (void)id; BOOST_CHECK_EQUAL(resp.d_buffer.size(), 11U); /* simulate an exception, since DoH and UDP frontends will process the query right away, while TCP and DoT will first pass it back to the TCP worker thread */ @@ -966,6 +996,7 @@ BOOST_FIXTURE_TEST_CASE(test_TimeoutWhileWriting, TestFixture) {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max()}, /* data */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::NeedWrite, std::numeric_limits::max(), [&timeout](int desc) { + (void)desc; timeout = true; }}, {ExpectedStep::ExpectedRequest::closeBackend, IOState::Done}, @@ -1053,6 +1084,7 @@ BOOST_FIXTURE_TEST_CASE(test_TimeoutWhileReading, TestFixture) {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max()}, /* data */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max(), [&timeout](int desc) { + (void)desc; /* set the timeout flag now, since the timeout occurs while waiting for the descriptor to become readable */ timeout = true; }}, @@ -1717,6 +1749,7 @@ BOOST_FIXTURE_TEST_CASE(test_WrongStreamID, TestFixture) {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max()}, /* read ends up as a time out since nghttp2 filters the frame with the wrong stream ID */ {ExpectedStep::ExpectedRequest::readFromBackend, IOState::NeedRead, 0, [&timeout](int desc) { + (void)desc; /* set the timeout flag now, since the timeout occurs while waiting for the descriptor to become readable */ timeout = true; }}, diff --git a/pdns/dnsdistdist/test-dnsdistnghttp2_common.hh b/pdns/dnsdistdist/test-dnsdistnghttp2_common.hh index b6f9bdd10bb2..afcdc38d26eb 100644 --- a/pdns/dnsdistdist/test-dnsdistnghttp2_common.hh +++ b/pdns/dnsdistdist/test-dnsdistnghttp2_common.hh @@ -30,16 +30,22 @@ public: std::unique_ptr getConnection(int socket, const struct timeval& timeout, time_t now) override { + (void)timeout; + (void)now; return std::make_unique(socket); } std::unique_ptr getClientConnection(const std::string& host, bool hostIsAddr, int socket, const struct timeval& timeout) override { + (void)host; + (void)hostIsAddr; + (void)timeout; return std::make_unique(socket, true, d_needProxyProtocol); } void rotateTicketsKey(time_t now) override { + (void)now; } size_t getTicketsKeysCount() override @@ -68,6 +74,7 @@ public: int run(struct timeval* tv, int timeout = 500) override { + (void)timeout; int ret = 0; gettimeofday(tv, nullptr); // MANDATORY @@ -97,14 +104,19 @@ public: void getAvailableFDs(std::vector& fds, int timeout) override { + (void)fds; + (void)timeout; } void addFD(int fd, FDMultiplexer::EventKind kind) override { + (void)fd; + (void)kind; } void removeFD(int fd, FDMultiplexer::EventKind) override { + (void)fd; } string getName() const override diff --git a/pdns/dnsdistdist/test-dnsdisttcp_cc.cc b/pdns/dnsdistdist/test-dnsdisttcp_cc.cc index bcf6ea10aa21..0fdb04b1ed59 100644 --- a/pdns/dnsdistdist/test-dnsdisttcp_cc.cc +++ b/pdns/dnsdistdist/test-dnsdisttcp_cc.cc @@ -38,21 +38,37 @@ const bool TCPIOHandler::s_disableConnectForUnitTests = true; bool checkDNSCryptQuery(const ClientState& cs, PacketBuffer& query, std::unique_ptr& dnsCryptQuery, time_t now, bool tcp) { + (void)cs; + (void)query; + (void)dnsCryptQuery; + (void)now; + (void)tcp; return false; } bool checkQueryHeaders(const struct dnsheader& dnsHeader, ClientState& clientState) { + (void)dnsHeader; + (void)clientState; return true; } uint64_t uptimeOfProcess(const std::string& str) { + (void)str; return 0; } void handleResponseSent(const InternalQueryState& ids, double udiff, const ComboAddress& client, const ComboAddress& backend, unsigned int size, const dnsheader& cleartextDH, dnsdist::Protocol protocol, bool fromBackend) { + (void)ids; + (void)udiff; + (void)client; + (void)backend; + (void)size; + (void)cleartextDH; + (void)protocol; + (void)fromBackend; } std::function& selectedBackend)> s_processQuery; @@ -68,6 +84,12 @@ ProcessQueryResult processQuery(DNSQuestion& dnsQuestion, std::shared_ptr& remote, bool allowEmptyResponse) { + (void)response; + (void)qname; + (void)qtype; + (void)qclass; + (void)remote; + (void)allowEmptyResponse; return true; } @@ -160,6 +182,7 @@ class MockupTLSConnection : public TLSConnection IOState tryRead(PacketBuffer& buffer, size_t& pos, size_t toRead, bool allowIncomplete=false) override { + (void)allowIncomplete; auto step = getStep(); BOOST_REQUIRE_EQUAL(step.request, !d_client ? ExpectedStep::ExpectedRequest::readFromClient : ExpectedStep::ExpectedRequest::readFromBackend); @@ -189,6 +212,8 @@ class MockupTLSConnection : public TLSConnection IOState tryConnect(bool fastOpen, const ComboAddress& remote) override { + (void)fastOpen; + (void)remote; auto step = getStep(); BOOST_REQUIRE_EQUAL(step.request, ExpectedStep::ExpectedRequest::connectToBackend); @@ -238,6 +263,7 @@ class MockupTLSConnection : public TLSConnection void setSession(std::unique_ptr& session) override { + (void)session; } /* unused in that context, don't bother */ @@ -247,15 +273,26 @@ class MockupTLSConnection : public TLSConnection void connect(bool fastOpen, const ComboAddress& remote, const struct timeval& timeout) override { + (void)fastOpen; + (void)remote; + (void)timeout; } size_t read(void* buffer, size_t bufferSize, const struct timeval&readTimeout, const struct timeval& totalTimeout={0,0}, bool allowIncomplete=false) override { + (void)buffer; + (void)bufferSize; + (void)readTimeout; + (void)totalTimeout; + (void)allowIncomplete; return 0; } size_t write(const void* buffer, size_t bufferSize, const struct timeval& writeTimeout) override { + (void)buffer; + (void)bufferSize; + (void)writeTimeout; return 0; } private: @@ -285,16 +322,22 @@ class MockupTLSCtx : public TLSCtx std::unique_ptr getConnection(int socket, const struct timeval& timeout, time_t now) override { + (void)timeout; + (void)now; return std::make_unique(socket); } std::unique_ptr getClientConnection(const std::string& host, bool hostIsAddr, int socket, const struct timeval& timeout) override { + (void)host; + (void)hostIsAddr; + (void)timeout; return std::make_unique(socket, true); } void rotateTicketsKey(time_t now) override { + (void)now; } size_t getTicketsKeysCount() override @@ -321,6 +364,7 @@ class MockupFDMultiplexer : public FDMultiplexer int run(struct timeval* tv, int timeout=500) override { + (void)timeout; int ret = 0; gettimeofday(tv, nullptr); // MANDATORY @@ -351,14 +395,19 @@ class MockupFDMultiplexer : public FDMultiplexer void getAvailableFDs(std::vector& fds, int timeout) override { + (void)fds; + (void)timeout; } void addFD(int fd, FDMultiplexer::EventKind kind) override { + (void)fd; + (void)kind; } void removeFD(int fd, FDMultiplexer::EventKind) override { + (void)fd; } string getName() const override @@ -510,6 +559,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::Drop; }; @@ -532,6 +583,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; // Would be nicer to actually turn it into a response return ProcessQueryResult::SendAnswer; }; @@ -564,6 +617,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; // Would be nicer to actually turn it into a response return ProcessQueryResult::SendAnswer; }; @@ -592,6 +647,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; throw std::runtime_error("Something unexpected happened"); }; @@ -619,6 +676,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) s_steps.push_back({ ExpectedStep::ExpectedRequest::closeClient, IOState::Done }); s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; // Would be nicer to actually turn it into a response return ProcessQueryResult::SendAnswer; }; @@ -641,6 +700,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; /* should not be reached */ BOOST_CHECK(false); return ProcessQueryResult::SendAnswer; @@ -679,6 +740,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -715,6 +778,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -776,6 +841,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionWithProxyProtocol_SelfAnswered, T { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -809,6 +876,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionWithProxyProtocol_SelfAnswered, T { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -839,6 +908,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionWithProxyProtocol_SelfAnswered, T { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -918,10 +989,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -958,10 +1033,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; throw std::runtime_error("Unexpected error while processing the response"); }; @@ -997,10 +1076,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return false; }; @@ -1040,10 +1123,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1068,9 +1155,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1105,10 +1197,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1173,10 +1269,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1206,26 +1306,31 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, query.size() - 2 }, /* opening a connection to the backend (5 tries by default) */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, @@ -1235,11 +1340,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { - + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1271,11 +1379,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { - + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1318,10 +1429,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1375,10 +1490,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1431,10 +1550,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1463,24 +1586,28 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* and now reconnection fails (1) */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* 2 */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* 3 */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* 4 */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, @@ -1490,10 +1617,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1542,10 +1673,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1602,10 +1737,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1643,10 +1782,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1707,10 +1850,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) s_steps.push_back({ ExpectedStep::ExpectedRequest::closeClient, IOState::Done }); s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1749,12 +1896,16 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; dq.asynchronous = true; /* note that we do nothing with the query, we just tell the frontend it was dealt with */ return ProcessQueryResult::Asynchronous; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1937,10 +2088,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2075,6 +2230,9 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2200,6 +2358,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) /* reading a query from the client (5) */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, 2 }, { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(4).size() - 2, [&threadData,&backendDesc](int desc) { + (void)desc; /* set the backend descriptor as ready now */ dynamic_cast(threadData.mplexer.get())->setReady(backendDesc); } }, @@ -2230,6 +2389,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) /* reading a response from the backend (5) */ { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, 2 }, { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(4).size() - 2, [&threadData](int desc) { + (void)desc; /* set the client descriptor as ready to resume sending */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -2253,10 +2413,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2317,6 +2481,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(1).size() - 2 }, /* query is dropped, closing the connection to the client */ { ExpectedStep::ExpectedRequest::closeClient, IOState::Done, 0, [&timeout](int desc) { + (void)desc; timeout = true; } }, /* closing a connection to the backend after a timeout */ @@ -2325,6 +2490,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) counter = 0; s_processQuery = [backend,&counter](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; if (counter == 0) { ++counter; selectedBackend = backend; @@ -2333,6 +2499,9 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) return ProcessQueryResult::Drop; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2396,6 +2565,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(1).size() - 2 }, /* query is dropped, closing the connection to the client */ { ExpectedStep::ExpectedRequest::closeClient, IOState::Done, 0, [&threadData,&backendDescriptor](int desc) { + (void)desc; /* the backend descriptor becomes ready */ dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptor); } }, @@ -2408,6 +2578,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) counter = 0; s_processQuery = [backend,&counter](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; if (counter == 0) { ++counter; selectedBackend = backend; @@ -2416,6 +2587,9 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) return ProcessQueryResult::Drop; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2520,6 +2694,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(4).size() - 2 }, /* sending response (3) to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(4).size(), [&timeout](int desc) { + (void)desc; timeout = true; } }, /* closing a connection to the backend */ @@ -2529,10 +2704,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2645,30 +2824,36 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done,0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done,0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done,0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done,0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, /* closing a connection to the backend, client becomes ready */ { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done, 0, [&threadData](int desc) { + (void)desc; /* the client descriptor is ready */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -2681,10 +2866,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2848,6 +3037,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) } }, /* no more query from the client for now */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::NeedRead, 0 , [&threadData](int desc) { + (void)desc; /* the client descriptor becomes NOT ready */ dynamic_cast(threadData.mplexer.get())->setNotReady(-1); } }, @@ -2866,6 +3056,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, axfrResponses.at(2).size() - 2 }, /* sending response (3) to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, axfrResponses.at(2).size(), [&threadData](int desc) { + (void)desc; /* the client descriptor becomes ready */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -2888,10 +3079,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3036,6 +3231,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) } }, /* no more query from the client for now */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::NeedRead, 0 , [&threadData](int desc) { + (void)desc; /* the client descriptor becomes NOT ready */ dynamic_cast(threadData.mplexer.get())->setNotReady(-1); } }, @@ -3062,10 +3258,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [proxyEnabledBackend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = proxyEnabledBackend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3291,6 +3491,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, firstResponse.size() - 2 }, /* sending response (1) to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, firstResponse.size(), [&threadData](int desc) { + (void)desc; /* client descriptor becomes ready */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -3304,6 +3505,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, ixfrResponses.at(0).size() - 2 }, /* sending response (ixfr 1) to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, ixfrResponses.at(0).size(), [&threadData](int desc) { + (void)desc; /* the client descriptor becomes ready */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -3326,10 +3528,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3452,10 +3658,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [proxyEnabledBackend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = proxyEnabledBackend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3537,10 +3747,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [proxyEnabledBackend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = proxyEnabledBackend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3593,6 +3807,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) /* reading a third query from the client */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, 2 }, { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(2).size() - 2, [&timeout](int desc) { + (void)desc; timeout = true; } }, /* trying to read more from the client but nothing to read */ @@ -3604,10 +3819,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3723,6 +3942,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::NeedRead, 0 }, /* nothing more to read from the client at that moment */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::NeedRead, 0, [&threadData, &backend1Desc](int desc) { + (void)desc; /* but the first backend becomes readable */ dynamic_cast(threadData.mplexer.get())->setReady(backend1Desc); } }, @@ -3764,6 +3984,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(2).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(2).size(), [&threadData,&backend1Desc,&backend2Desc](int desc) { + (void)desc; /* backend 2 is no longer readable, backend 1 becomes readable */ dynamic_cast(threadData.mplexer.get())->setNotReady(backend2Desc); dynamic_cast(threadData.mplexer.get())->setReady(backend1Desc); @@ -3773,6 +3994,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(4).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(4).size(), [&threadData,&backend1Desc,&backend2Desc](int desc) { + (void)desc; /* backend 1 is no longer readable, backend 2 becomes readable */ dynamic_cast(threadData.mplexer.get())->setNotReady(backend1Desc); dynamic_cast(threadData.mplexer.get())->setReady(backend2Desc); @@ -3782,6 +4004,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(3).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(3).size(), [&threadData,&backend2Desc](int desc) { + (void)desc; /* backend 2 is no longer readable */ dynamic_cast(threadData.mplexer.get())->setNotReady(backend2Desc); /* client becomes readable */ @@ -3797,10 +4020,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend1](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend1; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3873,6 +4100,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) } }, /* sending it to the client. we don't have anything else to send to the client, no new query from it either, until we time out */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(0).size(), [&timeout](int desc) { + (void)desc; timeout = true; } }, /* closing a connection to the backend */ @@ -3882,10 +4110,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -4061,6 +4293,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, queries.at(4).size() }, /* no response ready yet, client stops being readable, first backend has a response */ { ExpectedStep::ExpectedRequest::readFromBackend, IOState::NeedRead, 0, [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(0)); } }, /* trying to read from the client but nothing yet */ @@ -4072,6 +4305,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(0).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(0).size(), [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(2)); } }, /* reading response (3) from the third backend (3) */ @@ -4079,6 +4313,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(2).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(2).size(), [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(1)); } }, /* reading response (2) from the second backend (2) */ @@ -4086,6 +4321,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(1).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(1).size(), [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(4)); } }, /* reading response (5) from the fifth backend (5) */ @@ -4093,6 +4329,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(4).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(4).size(), [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(3)); } }, /* reading response (4) from the fourth backend (4) */ @@ -4100,6 +4337,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(3).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(3).size(), [&threadData](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, /* client closes the connection */ @@ -4115,10 +4353,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -4158,6 +4400,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, 2 }, { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(1).size() - 2 }, { ExpectedStep::ExpectedRequest::readFromClient, IOState::NeedRead, 0, [&timeout](int desc) { + (void)desc; timeout = true; }}, /* close the connection with the client */ @@ -4171,6 +4414,9 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) return ProcessQueryResult::Asynchronous; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; diff --git a/pdns/libssl.cc b/pdns/libssl.cc index 2493f73d1d0b..5f4b08a52c33 100644 --- a/pdns/libssl.cc +++ b/pdns/libssl.cc @@ -895,7 +895,7 @@ bool OpenSSLTLSTicketKey::decrypt(const unsigned char* iv, EVP_CIPHER_CTX* ectx, } std::pair, std::vector> libssl_init_server_context(const TLSConfig& config, - std::map& ocspResponses) + [[maybe_unused]] std::map& ocspResponses) { std::vector warnings; auto ctx = std::unique_ptr(SSL_CTX_new(SSLv23_server_method()), SSL_CTX_free); diff --git a/pdns/tcpiohandler.cc b/pdns/tcpiohandler.cc index cb9d480919f1..532adce91663 100644 --- a/pdns/tcpiohandler.cc +++ b/pdns/tcpiohandler.cc @@ -7,25 +7,13 @@ const bool TCPIOHandler::s_disableConnectForUnitTests = false; -namespace { -bool shouldDoVerboseLogging() -{ -#ifdef DNSDIST - return dnsdist::configuration::getCurrentRuntimeConfiguration().d_verbose; -#elif defined(RECURSOR) - return false; -#else - return true; -#endif -} -} - #ifdef HAVE_LIBSODIUM #include #endif /* HAVE_LIBSODIUM */ TLSCtx::tickets_key_added_hook TLSCtx::s_ticketsKeyAddedHook{nullptr}; +#if defined(HAVE_DNS_OVER_TLS) || defined(HAVE_DNS_OVER_HTTPS) static std::vector> getALPNVector(TLSFrontend::ALPN alpn, bool client) { if (alpn == TLSFrontend::ALPN::DoT) { @@ -46,9 +34,21 @@ static std::vector> getALPNVector(TLSFrontend::ALPN alpn, b return {}; } -#if defined(HAVE_DNS_OVER_TLS) || defined(HAVE_DNS_OVER_HTTPS) #ifdef HAVE_LIBSSL +namespace { +bool shouldDoVerboseLogging() +{ +#ifdef DNSDIST + return dnsdist::configuration::getCurrentRuntimeConfiguration().d_verbose; +#elif defined(RECURSOR) + return false; +#else + return true; +#endif +} +} + #include #include #include diff --git a/tasks.py b/tasks.py index 5a0d53101fb2..8c035828b95c 100644 --- a/tasks.py +++ b/tasks.py @@ -345,6 +345,11 @@ def install_rec_build_deps(c): @task(optional=['skipXDP']) def install_dnsdist_build_deps(c, skipXDP=False): c.sudo('apt-get install -y --no-install-recommends ' + ' '.join(all_build_deps + git_build_deps + dnsdist_build_deps + (dnsdist_xdp_build_deps if not skipXDP else []))) + install_meson(c) + +@task +def ci_install_meson(c): + install_meson(c) @task def ci_autoconf(c, meson=False): @@ -393,7 +398,22 @@ def ci_docs_add_ssh(c, ssh_key, host_key): def get_sanitizers(meson=False): sanitizers = os.getenv('SANITIZERS', '') if meson: - return f'-D b_sanitize={sanitizers}' if sanitizers != '' else '' + subst = { + 'tsan': 'thread', + 'asan': 'address', + 'ubsan': 'undefined' + } + meson_sanitizers = '' + sanitizers = sanitizers.split('+') + for sanitizer in sanitizers: + if sanitizer in subst: + if meson_sanitizers != '': + meson_sanitizers = meson_sanitizers + ',' + meson_sanitizers = meson_sanitizers + subst[sanitizer] + else: + meson_sanitizers = meson_sanitizers + sanitizer + + return f'-D b_sanitize={meson_sanitizers}' if meson_sanitizers != '' else '' if sanitizers != '': sanitizers = sanitizers.split('+') sanitizers = ['--enable-' + sanitizer for sanitizer in sanitizers] @@ -611,8 +631,54 @@ def ci_rec_configure(c, features): @task -def ci_dnsdist_configure(c, features): +def ci_dnsdist_configure(c, features, builder, build_dir): additional_flags = '' + if features == 'least': + additional_flags = '-DDISABLE_COMPLETION \ + -DDISABLE_DELAY_PIPE \ + -DDISABLE_DYNBLOCKS \ + -DDISABLE_PROMETHEUS \ + -DDISABLE_PROTOBUF \ + -DDISABLE_BUILTIN_HTML \ + -DDISABLE_CARBON \ + -DDISABLE_SECPOLL \ + -DDISABLE_DEPRECATED_DYNBLOCK \ + -DDISABLE_LUA_WEB_HANDLERS \ + -DDISABLE_NON_FFI_DQ_BINDINGS \ + -DDISABLE_POLICIES_BINDINGS \ + -DDISABLE_PACKETCACHE_BINDINGS \ + -DDISABLE_DOWNSTREAM_BINDINGS \ + -DDISABLE_COMBO_ADDR_BINDINGS \ + -DDISABLE_CLIENT_STATE_BINDINGS \ + -DDISABLE_QPS_LIMITER_BINDINGS \ + -DDISABLE_SUFFIX_MATCH_BINDINGS \ + -DDISABLE_NETMASK_BINDINGS \ + -DDISABLE_DNSNAME_BINDINGS \ + -DDISABLE_DNSHEADER_BINDINGS \ + -DDISABLE_RECVMMSG \ + -DDISABLE_WEB_CACHE_MANAGEMENT \ + -DDISABLE_WEB_CONFIG \ + -DDISABLE_RULES_ALTERING_QUERIES \ + -DDISABLE_ECS_ACTIONS \ + -DDISABLE_TOP_N_BINDINGS \ + -DDISABLE_OCSP_STAPLING \ + -DDISABLE_HASHED_CREDENTIALS \ + -DDISABLE_FALSE_SHARING_PADDING \ + -DDISABLE_NPN' + + if builder == 'meson': + cmd = ci_dnsdist_configure_meson(features, additional_flags, build_dir) + logfile = 'meson-logs/meson-log.txt' + else: + cmd = ci_dnsdist_configure_autotools(features, additional_flags) + logfile = 'config.log' + + res = c.run(cmd, warn=True) + if res.exited != 0: + c.run(f'cat {logfile}') + raise UnexpectedExit(res) + +def ci_dnsdist_configure_autotools(features, additional_flags): if features == 'full': features_set = '--enable-dnstap \ --enable-dnscrypt \ @@ -645,41 +711,10 @@ def ci_dnsdist_configure(c, features): --without-net-snmp \ --without-nghttp2 \ --without-re2' - additional_flags = '-DDISABLE_COMPLETION \ - -DDISABLE_DELAY_PIPE \ - -DDISABLE_DYNBLOCKS \ - -DDISABLE_PROMETHEUS \ - -DDISABLE_PROTOBUF \ - -DDISABLE_BUILTIN_HTML \ - -DDISABLE_CARBON \ - -DDISABLE_SECPOLL \ - -DDISABLE_DEPRECATED_DYNBLOCK \ - -DDISABLE_LUA_WEB_HANDLERS \ - -DDISABLE_NON_FFI_DQ_BINDINGS \ - -DDISABLE_POLICIES_BINDINGS \ - -DDISABLE_PACKETCACHE_BINDINGS \ - -DDISABLE_DOWNSTREAM_BINDINGS \ - -DDISABLE_COMBO_ADDR_BINDINGS \ - -DDISABLE_CLIENT_STATE_BINDINGS \ - -DDISABLE_QPS_LIMITER_BINDINGS \ - -DDISABLE_SUFFIX_MATCH_BINDINGS \ - -DDISABLE_NETMASK_BINDINGS \ - -DDISABLE_DNSNAME_BINDINGS \ - -DDISABLE_DNSHEADER_BINDINGS \ - -DDISABLE_RECVMMSG \ - -DDISABLE_WEB_CACHE_MANAGEMENT \ - -DDISABLE_WEB_CONFIG \ - -DDISABLE_RULES_ALTERING_QUERIES \ - -DDISABLE_ECS_ACTIONS \ - -DDISABLE_TOP_N_BINDINGS \ - -DDISABLE_OCSP_STAPLING \ - -DDISABLE_HASHED_CREDENTIALS \ - -DDISABLE_FALSE_SHARING_PADDING \ - -DDISABLE_NPN' unittests = get_unit_tests() fuzztargets = get_fuzzing_targets() tools = f'''AR=llvm-ar-{clang_version} RANLIB=llvm-ranlib-{clang_version}''' if is_compiler_clang() else '' - configure_cmd = " ".join([ + return " ".join([ tools, get_base_configure_cmd(additional_c_flags='', additional_cxx_flags=additional_flags, enable_systemd=False, enable_sodium=False), features_set, @@ -689,10 +724,67 @@ def ci_dnsdist_configure(c, features): '--prefix=/opt/dnsdist' ]) - res = c.run(configure_cmd, warn=True) - if res.exited != 0: - c.run('cat config.log') - raise UnexpectedExit(res) +def ci_dnsdist_configure_meson(features, additional_flags, build_dir): + if features == 'full': + features_set = '-D cdb=enabled \ + -D dnscrypt=enabled \ + -D dnstap=enabled \ + -D ebpf=enabled \ + -D h2o=enabled \ + -D ipcipher=enabled \ + -D libedit=enabled \ + -D libsodium=enabled \ + -D lmdb=enabled \ + -D nghttp2=enabled \ + -D re2=enabled \ + -D systemd=enabled \ + -D tls-gnutls=enabled \ + -D dns-over-https=true \ + -D dns-over-http3=true \ + -D dns-over-quic=true \ + -D dns-over-tls=true \ + -D reproducible=true \ + -D snmp=true' + else: + features_set = '-D cdb=disabled \ + -D dnscrypt=disabled \ + -D dnstap=disabled \ + -D ebpf=disabled \ + -D h2o=disabled \ + -D ipcipher=disabled \ + -D libedit=disabled \ + -D libsodium=disabled \ + -D lmdb=disabled \ + -D nghttp2=disabled \ + -D re2=disabled \ + -D systemd=disabled \ + -D tls-gnutls=disabled \ + -D dns-over-https=false \ + -D dns-over-http3=false \ + -D dns-over-quic=false \ + -D dns-over-tls=false \ + -D reproducible=false \ + -D snmp=false' + unittests = get_unit_tests(meson=True) + fuzztargets = get_fuzzing_targets(meson=True) + tools = f'''AR=llvm-ar-{clang_version} RANLIB=llvm-ranlib-{clang_version}''' if is_compiler_clang() else '' + cflags = " ".join([get_cflags()]) + cxxflags = " ".join([get_cxxflags(), additional_flags]) + return " ".join([ + tools, + f'CFLAGS="{cflags}"', + f'CXXFLAGS="{cxxflags}"', + f"CC='{get_c_compiler()}'", + f"CXX='{get_cxx_compiler()}'", + f'. {repo_home}/.venv/bin/activate && meson setup {build_dir}', + features_set, + unittests, + fuzztargets, + "-D hardening-fortify-source=auto", + "-D auto-var-init=pattern", + get_coverage(meson=True), + get_sanitizers(meson=True) + ]) @task def ci_auth_make(c): @@ -725,8 +817,14 @@ def ci_rec_make_bear(c): def ci_dnsdist_make(c): c.run(f'make -j{get_build_concurrency(4)} -k V=1') +def ci_dnsdist_run_ninja(c): + c.run(f'. {repo_home}/.venv/bin/activate && ninja -j{get_build_concurrency()} --verbose') + @task -def ci_dnsdist_make_bear(c): +def ci_dnsdist_make_bear(c, builder): + if builder == 'meson': + return ci_dnsdist_run_ninja(c) + # Assumed to be running under ./pdns/dnsdistdist/ c.run(f'bear --append -- make -j{get_build_concurrency(4)} -k V=1') @@ -757,10 +855,16 @@ def ci_rec_run_unit_tests(c): raise UnexpectedExit(res) @task -def ci_dnsdist_run_unit_tests(c): - res = c.run('make check', warn=True) +def ci_dnsdist_run_unit_tests(c, builder): + if builder == 'meson': + suite_timeout_sec = 120 + logfile = 'meson-logs/testlog.txt' + res = c.run(f'. {repo_home}/.venv/bin/activate && meson test --verbose -t {suite_timeout_sec}', warn=True) + else: + logfile = 'test-suite.log' + res = c.run('make check', warn=True) if res.exited != 0: - c.run('cat test-suite.log') + c.run(f'cat {logfile}', warn=True) raise UnexpectedExit(res) @task