Verified Commit 24379ca4 authored by Pavel Doležal's avatar Pavel Doležal
Browse files

dnstap: Add list of dnstap sockets to probe's configuration and command line parameters

parent 8c5b697b
......@@ -13,6 +13,10 @@ default:
# List of PCAPs to process in addition to PCAPs passed with '-p' command line parameter.
pcap-list: []
# List of unix sockets to process dnstap data from in addition to sockets passed with '-d'
# command line parameter.
dnstap-socket-list: []
# Indicates RAW PCAPs as input in 'pcap-list' or from command line with '-p' parameter.
# Might get overriden by '-r' command line parameter.
# MUST be set to 'false' if 'interface-list' or '-i' command line parameter are used.
......
......@@ -40,6 +40,7 @@ namespace DDP {
Config() : interface_list(),
pcap_list(),
raw_pcap(false),
dnstap_socket_list(),
log_file(),
coremask(0x7),
dns_ports({53}),
......@@ -74,6 +75,7 @@ namespace DDP {
ConfigItem<CList<std::string>> interface_list; //!< List of network interfaces to process traffic from
ConfigItem<CList<std::string>> pcap_list; //!< List of PCAP files to process
ConfigItem<bool> raw_pcap; //!< Defines if input PCAP files are without ethernet headers
ConfigItem<CList<std::string>> dnstap_socket_list; //!< List of unix sockets to process dnstap data from
ConfigItem<std::string> log_file; //!< Log file for storing probe's logs
ConfigItem<ThreadManager::MaskType> coremask; //!< Coremask used fo selecting cores where application will be running.
ConfigItem<CList<Port_t>> dns_ports; //!< TCP/UDP port list used for identifying DNS traffic
......
......@@ -66,6 +66,12 @@ void DDP::ConfigFile::load_instance(Config& cfg, YAML::Node node)
if (node["raw-pcap"] && node["raw-pcap"].IsScalar())
cfg.raw_pcap.add_value(node["raw-pcap"].as<bool>());
if (node["dnstap-socket-list"] && node["dnstap-socket-list"].IsSequence()) {
for (auto item : node["dnstap-socket-list"]) {
cfg.dnstap_socket_list.add_value(item.as<std::string>());
}
}
if (node["log-file"] && node["log-file"].IsScalar())
cfg.log_file.add_value(node["log-file"].as<std::string>());
......
......@@ -52,6 +52,7 @@ namespace DDP {
std::list<std::string> interfaces; //<! List of interfaces used for listening for incoming DNS data
std::list<PciDevice> devices; //<! List of PCI devices corresponding to interfaces list (used in DPDK version)
std::list<std::string> pcaps; //<! List of PCAPs with data for processing
std::list<std::string> dnstap_sockets; //<! List of unix sockets to process dnstap data from
std::string log_file; //!< Log file to store probe's logs
std::string instance_name = "default"; //!< Instance name used for getting YAML configuration
std::string conf_file = PROBE_CONFIG; //!< YAML file to load initial configuration from
......
......@@ -94,7 +94,7 @@ DDP::ParsedArgs DDP::Probe::process_args(int argc, char** argv)
args.app = argv[0];
int opt;
while ((opt = getopt(argc, argv, "hi:p:rl:n:c:")) != EOF) {
while ((opt = getopt(argc, argv, "hi:p:rd:l:n:c:")) != EOF) {
switch (opt) {
case 'h':
......@@ -114,6 +114,10 @@ DDP::ParsedArgs DDP::Probe::process_args(int argc, char** argv)
args.raw_pcap = true;
break;
case 'd':
args.dnstap_sockets.emplace_back(optarg);
break;
case 'l':
logwriter.set_output(std::string(optarg));
args.log_file = optarg;
......@@ -150,13 +154,14 @@ void DDP::Probe::print_help(const char* app)
interface = "interface name e.g. eth0 or PCI ID e.g. 00:1f.6";
std::cout << std::endl << app << std::endl
<< "\t-p PCAP : input pcap files. Parameter can repeat." << std::endl
<< "\t-i INTERFACE : " << interface << ". Parameter can repeat." << std::endl
<< "\t-r : indicates RAW PCAPs as input. Can't be used together with -i parameter." << std::endl
<< "\t-l LOGFILE : redirect probe's logs to LOGFILE instead of standard output" << std::endl
<< "\t-n INSTANCE : Unique identifier (for config purposes) for given instance of DNS Probe" << std::endl
<< "\t-c CONFIG_FILE : YAML file to load initial configuration from." << std::endl
<< "\t-h : this help message" << std::endl;
<< "\t-p PCAP : input pcap files. Parameter can repeat." << std::endl
<< "\t-i INTERFACE : " << interface << ". Parameter can repeat." << std::endl
<< "\t-r : indicates RAW PCAPs as input. Can't be used together with -i parameter." << std::endl
<< "\t-d DNSTAP_SOCKET : path to input dnstap unix socket. Parameter can repeat." << std::endl
<< "\t-l LOGFILE : redirect probe's logs to LOGFILE instead of standard output" << std::endl
<< "\t-n INSTANCE : Unique identifier (for config purposes) for given instance of DNS Probe" << std::endl
<< "\t-c CONFIG_FILE : YAML file to load initial configuration from." << std::endl
<< "\t-h : this help message" << std::endl;
}
DDP::Probe& DDP::Probe::getInstance()
......@@ -191,7 +196,11 @@ void DDP::Probe::load_config(Arguments& args)
args.pcaps.emplace_back(pcap);
}
if (args.interfaces.empty() && args.pcaps.empty())
for (auto& dt_socket : m_cfg.dnstap_socket_list.value()) {
args.dnstap_sockets.emplace_back(dt_socket);
}
if (args.interfaces.empty() && args.pcaps.empty() && args.dnstap_sockets.empty())
throw std::invalid_argument("At least one interface or pcap should be specified!");
m_cfg_loaded = true;
......
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