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 return net::ERR_NAME_NOT_RESOLVED; |
360 *address = | |
361 net::IPEndPoint(net::IPAddressNumber(), dest_host_port_pair_.port()); | |
362 } | 361 } |
363 | 362 |
| 363 *address = net::IPEndPoint(ip_number, dest_host_port_pair_.port()); |
364 return net::OK; | 364 return net::OK; |
365 } | 365 } |
366 | 366 |
367 int ProxyResolvingClientSocket::GetLocalAddress( | 367 int ProxyResolvingClientSocket::GetLocalAddress( |
368 net::IPEndPoint* address) const { | 368 net::IPEndPoint* address) const { |
369 if (transport_.get() && transport_->socket()) | 369 if (transport_.get() && transport_->socket()) |
370 return transport_->socket()->GetLocalAddress(address); | 370 return transport_->socket()->GetLocalAddress(address); |
371 NOTREACHED(); | 371 NOTREACHED(); |
372 return net::ERR_SOCKET_NOT_CONNECTED; | 372 return net::ERR_SOCKET_NOT_CONNECTED; |
373 } | 373 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 return false; | 422 return false; |
423 } | 423 } |
424 | 424 |
425 void ProxyResolvingClientSocket::CloseTransportSocket() { | 425 void ProxyResolvingClientSocket::CloseTransportSocket() { |
426 if (transport_.get() && transport_->socket()) | 426 if (transport_.get() && transport_->socket()) |
427 transport_->socket()->Disconnect(); | 427 transport_->socket()->Disconnect(); |
428 transport_.reset(); | 428 transport_.reset(); |
429 } | 429 } |
430 | 430 |
431 } // namespace jingle_glue | 431 } // namespace jingle_glue |
OLD | NEW |