SocketAddressTestHelper.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2015-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. namespace folly {
  18. class SocketAddressTestHelper {
  19. public:
  20. static constexpr const char* kLoopbackAddrIPv4 = "127.0.0.1";
  21. static constexpr const char* kLoopbackAddrIPv6 = "::1";
  22. // https://developers.google.com/speed/public-dns/docs/using?hl=en
  23. static constexpr const char* kGooglePublicDnsAName =
  24. "google-public-dns-a.google.com";
  25. static constexpr const char* kGooglePublicDnsBName =
  26. "google-public-dns-b.google.com";
  27. static constexpr const char* kGooglePublicDnsAAddrIPv4 = "8.8.8.8";
  28. static constexpr const char* kGooglePublicDnsBAddrIPv4 = "8.8.4.4";
  29. static constexpr const char* kGooglePublicDnsAAddrIPv6 =
  30. "2001:4860:4860::8888";
  31. static constexpr const char* kGooglePublicDnsBAddrIPv6 =
  32. "2001:4860:4860::8844";
  33. static bool isIPv4Enabled();
  34. static bool isIPv6Enabled();
  35. private:
  36. static bool isFamilyOfAddrEnabled(const char* addr);
  37. };
  38. } // namespace folly