#include "stable-bloom.hh"
namespace nod {
- const float fp_rate = 0.01;
- const size_t num_cells = 67108864;
- const uint8_t num_dec = 10;
+ const float c_fp_rate = 0.01;
+ const size_t c_num_cells = 67108864;
+ const uint8_t c_num_dec = 10;
const unsigned int snapshot_interval_default = 600;
const std::string bf_suffix = "bf";
const std::string sbf_prefix = "sbf";
// Synchronization (at the instance level) is needed when snapshotting
class PersistentSBF {
public:
+ PersistentSBF() : d_sbf{c_fp_rate, c_num_cells, c_num_dec} {}
+ PersistentSBF(uint32_t num_cells) : d_sbf{c_fp_rate, num_cells, c_num_dec} {}
bool init(bool ignore_pid=false);
void setPrefix(const std::string& prefix) { d_prefix = prefix; } // Added to filenames in cachedir
void setCacheDir(const std::string& cachedir);
}
private:
bool d_init{false};
- bf::stableBF d_sbf{fp_rate, num_cells, num_dec}; // Stable Bloom Filter
+ bf::stableBF d_sbf; // Stable Bloom Filter
std::string d_cachedir;
std::string d_prefix = sbf_prefix;
std::mutex d_sbf_mutex; // Per-instance mutex for snapshots
class NODDB {
public:
- NODDB() {}
+ NODDB() : d_psbf{} {}
+ NODDB(uint32_t num_cells) : d_psbf{num_cells} {}
// Set ignore_pid to true if you don't mind loading files
// created by the current process
bool init(bool ignore_pid=false) {
class UniqueResponseDB {
public:
- UniqueResponseDB() {}
+ UniqueResponseDB() : d_psbf{} {}
+ UniqueResponseDB(uint32_t num_cells) : d_psbf{num_cells} {}
bool init(bool ignore_pid=false) {
d_psbf.setPrefix("udr");
return d_psbf.init(ignore_pid);
static void setupNODThread()
{
if (g_nodEnabled) {
- t_nodDBp = std::make_shared<nod::NODDB>();
+ uint32_t num_cells = ::arg().asNum("new-domain-db-size");
+ t_nodDBp = std::make_shared<nod::NODDB>(num_cells);
try {
t_nodDBp->setCacheDir(::arg()["new-domain-history-dir"]);
}
t.detach();
}
if (g_udrEnabled) {
- t_udrDBp = std::make_shared<nod::UniqueResponseDB>();
+ uint32_t num_cells = ::arg().asNum("unique-response-db-size");
+ t_udrDBp = std::make_shared<nod::UniqueResponseDB>(num_cells);
try {
t_udrDBp->setCacheDir(::arg()["unique-response-history-dir"]);
}
::arg().set("new-domain-lookup", "Perform a DNS lookup newly observed domains as a subdomain of the configured domain")="";
::arg().set("new-domain-history-dir", "Persist new domain tracking data here to persist between restarts")=string(NODCACHEDIR)+"/nod";
::arg().set("new-domain-whitelist", "List of domains (and implicitly all subdomains) which will never be considered a new domain")="";
+ ::arg().set("new-domain-db-size", "Size of the DB used to track new domains in terms of number of cells. Defaults to 67108864")="67108864";
::arg().set("unique-response-tracking", "Track unique responses (tuple of query name, type and RR).")="no";
::arg().set("unique-response-log", "Log unique responses")="yes";
::arg().set("unique-response-history-dir", "Persist unique response tracking data here to persist between restarts")=string(NODCACHEDIR)+"/udr";
+ ::arg().set("unique-response-db-size", "Size of the DB used to track unique responses in terms of number of cells. Defaults to 67108864")="67108864";
#endif /* NOD_ENABLED */
::arg().setCmd("help","Provide a helpful message");
::arg().setCmd("version","Print version string");