Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1138)

Unified Diff: net/tools/quic/quic_simple_client_bin.cc

Issue 1004173004: Make the simple QUIC client able to resolve hosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove EXPORT to fix Win Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_client_bin.cc ('k') | net/tools/quic/synchronous_host_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_simple_client_bin.cc
diff --git a/net/tools/quic/quic_simple_client_bin.cc b/net/tools/quic/quic_simple_client_bin.cc
index 33f3e997d52ddcccbaa5e1a55dbb0008b3055917..396009290943db575988b4d270cd3ec1687bdb22 100644
--- a/net/tools/quic/quic_simple_client_bin.cc
+++ b/net/tools/quic/quic_simple_client_bin.cc
@@ -47,6 +47,8 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "net/base/ip_endpoint.h"
+#include "net/base/net_errors.h"
+#include "net/base/net_log.h"
#include "net/base/privacy_mode.h"
#include "net/cert/cert_verifier.h"
#include "net/http/http_request_info.h"
@@ -57,6 +59,7 @@
#include "net/quic/quic_utils.h"
#include "net/spdy/spdy_http_utils.h"
#include "net/tools/quic/quic_simple_client.h"
+#include "net/tools/quic/synchronous_host_resolver.h"
#include "url/gurl.h"
using base::StringPiece;
@@ -170,14 +173,18 @@ int main(int argc, char *argv[]) {
// protocol is required in the URL.
GURL url(urls[0]);
string host = FLAGS_host;
- // TODO(rtenneti): get ip_addr from hostname by doing host resolution.
if (host.empty()) {
- LOG(ERROR) << "--host must be specified\n";
- return 1;
+ host = url.host();
}
if (!net::ParseIPLiteralToNumber(host, &ip_addr)) {
- LOG(ERROR) << "--host could not be parsed as an IP address\n";
- return 1;
+ net::AddressList addresses;
+ int rv = net::tools::SynchronousHostResolver::Resolve(host, &addresses);
+ if (rv != net::OK) {
+ LOG(ERROR) << "Unable to resolve '" << host << "' : "
+ << net::ErrorToString(rv);
+ return 1;
+ }
+ ip_addr = addresses[0].address();
}
string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port);
« no previous file with comments | « net/tools/quic/quic_client_bin.cc ('k') | net/tools/quic/synchronous_host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698