018-dns.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. // SPDX-FileCopyrightText: 2019-2024 Ivan Baidakou
  3. #include "test-utils.h"
  4. #include "utils/dns.h"
  5. using namespace syncspirit::utils;
  6. namespace ip = boost::asio::ip;
  7. TEST_CASE("get_block_size", "[support]") {
  8. auto str = "192.168.1.100,192.168.1.101:53,[1:2:3::4]:53,[fe80::1]:53%eth0";
  9. auto endpoints = parse_dns_servers(str);
  10. #if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0600
  11. CHECK(endpoints.size() == 4u);
  12. #else
  13. CHECK(endpoints.size() == 2u);
  14. #endif
  15. auto &e0 = endpoints[0];
  16. CHECK(e0.ip == ip::make_address_v4("192.168.1.100"));
  17. CHECK(e0.port == 53);
  18. auto &e1 = endpoints[1];
  19. CHECK(e1.ip == ip::make_address_v4("192.168.1.101"));
  20. CHECK(e1.port == 53);
  21. #if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0600
  22. auto &e2 = endpoints[2];
  23. CHECK(e2.ip == ip::make_address_v6("1:2:3::4"));
  24. CHECK(e2.port == 53);
  25. auto &e3 = endpoints[3];
  26. CHECK(e3.ip == ip::make_address_v6("fe80::1"));
  27. CHECK(e3.port == 53);
  28. #endif
  29. }