From df575f968fa3d82fb40c2637e7d3e245def43766 Mon Sep 17 00:00:00 2001 From: lucas Date: Thu, 12 Dec 2019 16:33:34 +0000 Subject: [PATCH] h2load: add --connect-to option --- src/h2load.cc | 14 ++++++++++++-- src/h2load.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/h2load.cc b/src/h2load.cc index 334b1e2b..10dbd20f 100644 --- a/src/h2load.cc +++ b/src/h2load.cc @@ -1563,8 +1563,11 @@ void resolve_host() { hints.ai_protocol = 0; hints.ai_flags = AI_ADDRCONFIG; - rv = getaddrinfo(config.host.c_str(), util::utos(config.port).c_str(), &hints, - &res); + const auto &resolve_host = + config.connect_to_host.empty() ? config.host : config.connect_to_host; + + rv = getaddrinfo(resolve_host.c_str(), util::utos(config.port).c_str(), + &hints, &res); if (rv != 0) { std::cerr << "getaddrinfo() failed: " << gai_strerror(rv) << std::endl; exit(EXIT_FAILURE); @@ -1979,6 +1982,8 @@ Options: response time when using one worker thread, but may appear slightly out of order with multiple threads due to buffering. Status code is -1 for failed streams. + --connect-to= + Host to connect instead of using the host in . -v, --verbose Output debug information. --version Display version information and exit. @@ -2037,6 +2042,7 @@ int main(int argc, char **argv) { {"encoder-header-table-size", required_argument, &flag, 8}, {"warm-up-time", required_argument, &flag, 9}, {"log-file", required_argument, &flag, 10}, + {"connect-to", required_argument, &flag, 11}, {nullptr, 0, nullptr, 0}}; int option_index = 0; auto c = getopt_long(argc, argv, @@ -2264,6 +2270,10 @@ int main(int argc, char **argv) { // --log-file logfile = optarg; break; + case 11: + // --connect-to + config.connect_to_host = optarg; + break; } break; default: diff --git a/src/h2load.h b/src/h2load.h index a5de4613..c3ed12ee 100644 --- a/src/h2load.h +++ b/src/h2load.h @@ -69,6 +69,7 @@ struct Config { nghttp2::Headers custom_headers; std::string scheme; std::string host; + std::string connect_to_host; std::string ifile; std::string ciphers; // length of upload data