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/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 int GetPortFromSockaddr(const struct sockaddr* address, socklen_t address_len) { | 726 int GetPortFromSockaddr(const struct sockaddr* address, socklen_t address_len) { |
727 const uint16_t* port_field = GetPortFieldFromSockaddr(address, address_len); | 727 const uint16_t* port_field = GetPortFieldFromSockaddr(address, address_len); |
728 if (!port_field) | 728 if (!port_field) |
729 return -1; | 729 return -1; |
730 return base::NetToHost16(*port_field); | 730 return base::NetToHost16(*port_field); |
731 } | 731 } |
732 | 732 |
733 bool IsLocalhost(const std::string& host) { | 733 bool IsLocalhost(const std::string& host) { |
734 if (host == "localhost" || host == "localhost.localdomain" || | 734 if (host == "localhost" || host == "localhost.localdomain" || |
735 host == "localhost6" || host == "localhost6.localdomain6" || | 735 host == "localhost6" || host == "localhost6.localdomain6" || |
736 host == "localhost." || host == "localhost.localdomain." || | |
737 host == "localhost6." || host == "localhost6.localdomain6." || | |
Ryan Sleevi
2015/06/11 00:34:03
:( on more .localdomain (these are not reserved by
estark
2015/06/11 02:35:32
Do we need to keep these .localdomain things? Why
| |
736 IsLocalhostTLD(host)) | 738 IsLocalhostTLD(host)) |
737 return true; | 739 return true; |
738 | 740 |
739 IPAddressNumber ip_number; | 741 IPAddressNumber ip_number; |
740 if (ParseIPLiteralToNumber(host, &ip_number)) { | 742 if (ParseIPLiteralToNumber(host, &ip_number)) { |
741 size_t size = ip_number.size(); | 743 size_t size = ip_number.size(); |
742 switch (size) { | 744 switch (size) { |
743 case kIPv4AddressSize: { | 745 case kIPv4AddressSize: { |
744 IPAddressNumber localhost_prefix; | 746 IPAddressNumber localhost_prefix; |
745 localhost_prefix.push_back(127); | 747 localhost_prefix.push_back(127); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 }; | 800 }; |
799 const std::string& host = url.host(); | 801 const std::string& host = url.host(); |
800 for (const char* suffix : kGoogleHostSuffixes) { | 802 for (const char* suffix : kGoogleHostSuffixes) { |
801 if (EndsWith(host, suffix, false)) | 803 if (EndsWith(host, suffix, false)) |
802 return true; | 804 return true; |
803 } | 805 } |
804 return false; | 806 return false; |
805 } | 807 } |
806 | 808 |
807 } // namespace net | 809 } // namespace net |
OLD | NEW |