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