Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "jingle/glue/proxy_resolving_client_socket.h" | 5 #include "jingle/glue/proxy_resolving_client_socket.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 return false; | 343 return false; |
| 344 return transport_->socket()->IsConnectedAndIdle(); | 344 return transport_->socket()->IsConnectedAndIdle(); |
| 345 } | 345 } |
| 346 | 346 |
| 347 int ProxyResolvingClientSocket::GetPeerAddress( | 347 int ProxyResolvingClientSocket::GetPeerAddress( |
| 348 net::IPEndPoint* address) const { | 348 net::IPEndPoint* address) const { |
| 349 if (!transport_.get() || !transport_->socket()) { | 349 if (!transport_.get() || !transport_->socket()) { |
| 350 NOTREACHED(); | 350 NOTREACHED(); |
| 351 return net::ERR_SOCKET_NOT_CONNECTED; | 351 return net::ERR_SOCKET_NOT_CONNECTED; |
| 352 } | 352 } |
| 353 | |
| 353 if (proxy_info_.is_direct()) | 354 if (proxy_info_.is_direct()) |
| 354 return transport_->socket()->GetPeerAddress(address); | 355 return transport_->socket()->GetPeerAddress(address); |
| 355 | 356 |
| 356 net::IPAddressNumber ip_number; | 357 net::IPAddressNumber ip_number; |
| 357 if (net::ParseIPLiteralToNumber(dest_host_port_pair_.host(), &ip_number)) { | 358 if (!net::ParseIPLiteralToNumber(dest_host_port_pair_.host(), &ip_number)) { |
| 358 *address = net::IPEndPoint(ip_number, dest_host_port_pair_.port()); | 359 // Do not expose the proxy IP address to the caller. |
| 359 } else { | |
| 360 *address = | 360 *address = |
| 361 net::IPEndPoint(net::IPAddressNumber(), dest_host_port_pair_.port()); | 361 net::IPEndPoint(net::IPAddressNumber(), dest_host_port_pair_.port()); |
|
Ryan Sleevi
2015/03/06 21:23:41
BUG: Don't assign to *address
Just return an erro
| |
| 362 return net::ERR_NAME_NOT_RESOLVED; | |
| 362 } | 363 } |
| 363 | 364 |
| 365 *address = net::IPEndPoint(ip_number, dest_host_port_pair_.port()); | |
| 364 return net::OK; | 366 return net::OK; |
| 365 } | 367 } |
| 366 | 368 |
| 367 int ProxyResolvingClientSocket::GetLocalAddress( | 369 int ProxyResolvingClientSocket::GetLocalAddress( |
| 368 net::IPEndPoint* address) const { | 370 net::IPEndPoint* address) const { |
| 369 if (transport_.get() && transport_->socket()) | 371 if (transport_.get() && transport_->socket()) |
| 370 return transport_->socket()->GetLocalAddress(address); | 372 return transport_->socket()->GetLocalAddress(address); |
| 371 NOTREACHED(); | 373 NOTREACHED(); |
| 372 return net::ERR_SOCKET_NOT_CONNECTED; | 374 return net::ERR_SOCKET_NOT_CONNECTED; |
| 373 } | 375 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 return false; | 424 return false; |
| 423 } | 425 } |
| 424 | 426 |
| 425 void ProxyResolvingClientSocket::CloseTransportSocket() { | 427 void ProxyResolvingClientSocket::CloseTransportSocket() { |
| 426 if (transport_.get() && transport_->socket()) | 428 if (transport_.get() && transport_->socket()) |
| 427 transport_->socket()->Disconnect(); | 429 transport_->socket()->Disconnect(); |
| 428 transport_.reset(); | 430 transport_.reset(); |
| 429 } | 431 } |
| 430 | 432 |
| 431 } // namespace jingle_glue | 433 } // namespace jingle_glue |
| OLD | NEW |