diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 20:37:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 20:37:50 +0000 |
commit | c1f743ab2e4a7046d5500875a47d1f62c8624603 (patch) | |
tree | 709946d52f5f3bbaeb38be9e3f1d56d11f058237 /modules/refuse_nord/refuse_nord.c | |
parent | Initial commit. (diff) | |
download | knot-resolver-c1f743ab2e4a7046d5500875a47d1f62c8624603.tar.xz knot-resolver-c1f743ab2e4a7046d5500875a47d1f62c8624603.zip |
Adding upstream version 5.7.1.upstream/5.7.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/refuse_nord/refuse_nord.c')
-rw-r--r-- | modules/refuse_nord/refuse_nord.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/modules/refuse_nord/refuse_nord.c b/modules/refuse_nord/refuse_nord.c new file mode 100644 index 0000000..607ff61 --- /dev/null +++ b/modules/refuse_nord/refuse_nord.c @@ -0,0 +1,38 @@ +/* Copyright (C) Knot Resolver contributors. + * SPDX-License-Identifier: GPL-3.0-or-later + * + * This module responds to all queries without RD bit set with REFUSED. */ + +#include <libknot/consts.h> +#include <libknot/packet/pkt.h> +#include "daemon/worker.h" +#include "lib/module.h" +#include "lib/layer.h" + +static int refuse_nord_query(kr_layer_t *ctx) +{ + struct kr_request *req = ctx->req; + uint8_t rd = knot_wire_get_rd(req->qsource.packet->wire); + if (rd) + return ctx->state; + + knot_pkt_t *answer = kr_request_ensure_answer(req); + if (!answer) + return ctx->state; + knot_wire_set_rcode(answer->wire, KNOT_RCODE_REFUSED); + knot_wire_clear_ad(answer->wire); + kr_request_set_extended_error(req, KNOT_EDNS_EDE_NOTAUTH, "ABC4"); + ctx->state = KR_STATE_DONE; + return ctx->state; +} + +KR_EXPORT int refuse_nord_init(struct kr_module *module) +{ + static const kr_layer_api_t layer = { + .begin = &refuse_nord_query, + }; + module->layer = &layer; + return kr_ok(); +} + +KR_MODULE_EXPORT(refuse_nord) |