]> granicus.if.org Git - pdns/commitdiff
implement reading queries from a file
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 2 Jul 2013 11:14:14 +0000 (13:14 +0200)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Thu, 4 Jul 2013 11:33:01 +0000 (13:33 +0200)
pdns/dnstcpbench.cc
pdns/docs/dnstcpbench.1.txt

index b706bba6b0133436808b70cc9ea98b8600667f43..67a0512b0890d95931f81a3aee2fb3eee4f35660 100644 (file)
@@ -161,6 +161,7 @@ try
     ("help,h", "produce help message")
     ("verbose,v", "be verbose")
     ("udp-first,u", "try UDP first")
+    ("file,f", po::value<string>(), "source file - if not specified, defaults to stdin")
     ("tcp-no-delay", po::value<bool>()->default_value(true), "use TCP_NODELAY socket option")
     ("timeout-msec", po::value<int>()->default_value(10), "wait for this amount of milliseconds for an answer")
     ("workers", po::value<int>()->default_value(100), "number of parallel workers");
@@ -210,7 +211,14 @@ try
 
   pthread_t workers[numworkers];
 
-  FILE* fp=fdopen(0, "r");
+  FILE* fp;
+  if(!g_vm.count("file"))
+    fp=fdopen(0, "r");
+  else {
+    fp=fopen(g_vm["file"].as<string>().c_str(), "r");
+    if(!fp)
+      unixDie("Unable to open "+g_vm["file"].as<string>()+" for input");
+  }
   pair<string, string> q;
   string line;
   while(stringfgets(fp, line)) {
index 8758e8ac9381ab7c5a211ffd1ee72299fca94d8c..af3fb9a34ccfc956e0e8757d1ea33578fbb80f04 100644 (file)
@@ -8,13 +8,14 @@ dnstcpbench - tool to perform TCP benchmarking of nameservers
 
 SYNOPSIS
 --------
-'dnstcpbench' [--help] [--verbose] [--udp-first, -u] [--workers] [--timeout-msec] remote-ip-address [remote-port]
+'dnstcpbench' [--help] [--file=filename] [--verbose] [--udp-first, -u] [--workers] [--timeout-msec] remote-ip-address [remote-port]
 \r
 DESCRIPTION
 -----------
-dnstcpbench reads DNS queries from standard input and sends them out in\r
-parallel to a remote nameserver. By default TCP/IP is used, but optionally,\r
-UDP is tried first, which allows for the benchmarking of TCP/IP fallback.\r
+dnstcpbench reads DNS queries (by default from standard input) and sends\r
+them out in parallel to a remote nameserver.  By default TCP/IP is used, but\r
+optionally, UDP is tried first, which allows for the benchmarking of TCP/IP\r
+fallback.\r
 \r
 The input format is one query per line: qname single-space qtype. An\r
 example:\r
@@ -31,22 +32,27 @@ The equivalent for IPv6 is not known.
 \r
 OPTIONS
 -------
-
---verbose::
-       Be wordy on what the program is doing
+\r
+-f,--file::\r
+       Filename from which to read queries. Defaults to standard input if\r
+       unspecified.\r
+\r
+-h,--help::\r
+       Provide a helpful message\r
+\r
+--timeout-msec::\r
+       Number of milliseconds to wait for an answer    
 
 --udp-first, -u::
        Attempt resolution via UDP first, only do TCP if truncated answer is\r
        received
 \r
+-v,--verbose::
+       Be wordy on what the program is doing
+\r
 --workers::\r
        Number of parallel worker threads to use. \r
 \r
---timeout-msec::\r
-       Number of milliseconds to wait for an answer    
-\r
---help::\r
-       Provide a helpful message\r
 \r
 Remote IP address can be IPv4 or IPv6. Remote port defaults to 53.\r
 \r