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 "net/socket/socks_client_socket.h" | 5 #include "net/socket/socks_client_socket.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 DCHECK(!addresses_.empty()); | 328 DCHECK(!addresses_.empty()); |
329 const IPEndPoint& endpoint = addresses_.front(); | 329 const IPEndPoint& endpoint = addresses_.front(); |
330 | 330 |
331 // We disabled IPv6 results when resolving the hostname, so none of the | 331 // We disabled IPv6 results when resolving the hostname, so none of the |
332 // results in the list will be IPv6. | 332 // results in the list will be IPv6. |
333 // TODO(eroman): we only ever use the first address in the list. It would be | 333 // TODO(eroman): we only ever use the first address in the list. It would be |
334 // more robust to try all the IP addresses we have before | 334 // more robust to try all the IP addresses we have before |
335 // failing the connect attempt. | 335 // failing the connect attempt. |
336 CHECK_EQ(ADDRESS_FAMILY_IPV4, endpoint.GetFamily()); | 336 CHECK_EQ(ADDRESS_FAMILY_IPV4, endpoint.GetFamily()); |
337 CHECK_LE(endpoint.address().size(), sizeof(request.ip)); | 337 CHECK_LE(endpoint.address().size(), sizeof(request.ip)); |
338 memcpy(&request.ip, &endpoint.address()[0], endpoint.address().size()); | 338 memcpy(&request.ip, &endpoint.address().bytes()[0], |
| 339 endpoint.address().size()); |
339 | 340 |
340 DVLOG(1) << "Resolved Host is : " << endpoint.ToStringWithoutPort(); | 341 DVLOG(1) << "Resolved Host is : " << endpoint.ToStringWithoutPort(); |
341 | 342 |
342 std::string handshake_data(reinterpret_cast<char*>(&request), | 343 std::string handshake_data(reinterpret_cast<char*>(&request), |
343 sizeof(request)); | 344 sizeof(request)); |
344 handshake_data.append(kEmptyUserId, arraysize(kEmptyUserId)); | 345 handshake_data.append(kEmptyUserId, arraysize(kEmptyUserId)); |
345 | 346 |
346 return handshake_data; | 347 return handshake_data; |
347 } | 348 } |
348 | 349 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 455 |
455 int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const { | 456 int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const { |
456 return transport_->socket()->GetPeerAddress(address); | 457 return transport_->socket()->GetPeerAddress(address); |
457 } | 458 } |
458 | 459 |
459 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { | 460 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { |
460 return transport_->socket()->GetLocalAddress(address); | 461 return transport_->socket()->GetLocalAddress(address); |
461 } | 462 } |
462 | 463 |
463 } // namespace net | 464 } // namespace net |
OLD | NEW |