From 36195f61b55e8017d974b7ddcf9466baf6f97300 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 2 Jul 2013 13:14:14 +0200 Subject: [PATCH] implement reading queries from a file --- pdns/dnstcpbench.cc | 10 +++++++++- pdns/docs/dnstcpbench.1.txt | 30 ++++++++++++++++++------------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/pdns/dnstcpbench.cc b/pdns/dnstcpbench.cc index b706bba6b..67a0512b0 100644 --- a/pdns/dnstcpbench.cc +++ b/pdns/dnstcpbench.cc @@ -161,6 +161,7 @@ try ("help,h", "produce help message") ("verbose,v", "be verbose") ("udp-first,u", "try UDP first") + ("file,f", po::value(), "source file - if not specified, defaults to stdin") ("tcp-no-delay", po::value()->default_value(true), "use TCP_NODELAY socket option") ("timeout-msec", po::value()->default_value(10), "wait for this amount of milliseconds for an answer") ("workers", po::value()->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().c_str(), "r"); + if(!fp) + unixDie("Unable to open "+g_vm["file"].as()+" for input"); + } pair q; string line; while(stringfgets(fp, line)) { diff --git a/pdns/docs/dnstcpbench.1.txt b/pdns/docs/dnstcpbench.1.txt index 8758e8ac9..af3fb9a34 100644 --- a/pdns/docs/dnstcpbench.1.txt +++ b/pdns/docs/dnstcpbench.1.txt @@ -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] DESCRIPTION ----------- -dnstcpbench reads DNS queries from standard input and sends them out in -parallel to a remote nameserver. By default TCP/IP is used, but optionally, -UDP is tried first, which allows for the benchmarking of TCP/IP fallback. +dnstcpbench reads DNS queries (by default from standard input) and sends +them out in parallel to a remote nameserver. By default TCP/IP is used, but +optionally, UDP is tried first, which allows for the benchmarking of TCP/IP +fallback. The input format is one query per line: qname single-space qtype. An example: @@ -31,22 +32,27 @@ The equivalent for IPv6 is not known. OPTIONS ------- - ---verbose:: - Be wordy on what the program is doing + +-f,--file:: + Filename from which to read queries. Defaults to standard input if + unspecified. + +-h,--help:: + Provide a helpful message + +--timeout-msec:: + Number of milliseconds to wait for an answer --udp-first, -u:: Attempt resolution via UDP first, only do TCP if truncated answer is received +-v,--verbose:: + Be wordy on what the program is doing + --workers:: Number of parallel worker threads to use. ---timeout-msec:: - Number of milliseconds to wait for an answer - ---help:: - Provide a helpful message Remote IP address can be IPv4 or IPv6. Remote port defaults to 53. -- 2.40.0