Commit 4d3b5010 authored by Mark Karpilovskij's avatar Mark Karpilovskij Committed by Daniel Salzman

mod-rrl: improve code readability

parent 1c80ae4e
This diff is collapsed.
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> /* Copyright (C) 2019 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -90,15 +90,15 @@ rrl_table_t *rrl_create(size_t size, uint32_t rate); ...@@ -90,15 +90,15 @@ rrl_table_t *rrl_create(size_t size, uint32_t rate);
* \brief Query the RRL table for accept or deny, when the rate limit is reached. * \brief Query the RRL table for accept or deny, when the rate limit is reached.
* *
* \param rrl RRL table. * \param rrl RRL table.
* \param a Source address. * \param remote Source address.
* \param req RRL request (containing resp., flags and question). * \param req RRL request (containing resp., flags and question).
* \param zone Zone name related to the response (or NULL). * \param zone Zone name related to the response (or NULL).
* \param mod Query module (needed for logging). * \param mod Query module (needed for logging).
* \retval KNOT_EOK if passed. * \retval KNOT_EOK if passed.
* \retval KNOT_ELIMIT when the limit is reached. * \retval KNOT_ELIMIT when the limit is reached.
*/ */
int rrl_query(rrl_table_t *rrl, const struct sockaddr_storage *a, rrl_req_t *req, int rrl_query(rrl_table_t *rrl, const struct sockaddr_storage *remote,
const knot_dname_t *zone, knotd_mod_t *mod); rrl_req_t *req, const knot_dname_t *zone, knotd_mod_t *mod);
/*! /*!
* \brief Roll a dice whether answer slips or not. * \brief Roll a dice whether answer slips or not.
......
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> /* Copyright (C) 2019 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -164,17 +164,16 @@ int rrl_load(knotd_mod_t *mod) ...@@ -164,17 +164,16 @@ int rrl_load(knotd_mod_t *mod)
} }
// Create table. // Create table.
knotd_conf_t rate = knotd_conf_mod(mod, MOD_RATE_LIMIT); uint32_t rate = knotd_conf_mod(mod, MOD_RATE_LIMIT).single.integer;
knotd_conf_t size = knotd_conf_mod(mod, MOD_TBL_SIZE); size_t size = knotd_conf_mod(mod, MOD_TBL_SIZE).single.integer;
ctx->rrl = rrl_create(size.single.integer, rate.single.integer); ctx->rrl = rrl_create(size, rate);
if (ctx->rrl == NULL) { if (ctx->rrl == NULL) {
ctx_free(ctx); ctx_free(ctx);
return KNOT_ENOMEM; return KNOT_ENOMEM;
} }
// Get slip. // Get slip.
knotd_conf_t conf = knotd_conf_mod(mod, MOD_SLIP); ctx->slip = knotd_conf_mod(mod, MOD_SLIP).single.integer;
ctx->slip = conf.single.integer;
// Get whitelist. // Get whitelist.
ctx->whitelist = knotd_conf_mod(mod, MOD_WHITELIST); ctx->whitelist = knotd_conf_mod(mod, MOD_WHITELIST);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment