@@ -246,6 +246,25 @@ BOOST_AUTO_TEST_CASE(cnetaddr_basic)
246
246
BOOST_CHECK (!addr.IsBindAny ());
247
247
BOOST_CHECK_EQUAL (addr.ToString (), " 1122:3344:5566:7788:9900:aabb:ccdd:eeff" );
248
248
249
+ // IPv6, scoped/link-local. See https://tools.ietf.org/html/rfc4007
250
+ // We support non-negative decimal integers (uint32_t) as zone id indices.
251
+ // Test with a fairly-high value, e.g. 32, to avoid locally reserved ids.
252
+ const std::string link_local{" fe80::1" };
253
+ const std::string scoped_addr{link_local + " %32" };
254
+ BOOST_REQUIRE (LookupHost (scoped_addr, addr, false ));
255
+ BOOST_REQUIRE (addr.IsValid ());
256
+ BOOST_REQUIRE (addr.IsIPv6 ());
257
+ BOOST_CHECK (!addr.IsBindAny ());
258
+ const std::string addr_str{addr.ToString ()};
259
+ BOOST_CHECK (addr_str == scoped_addr || addr_str == " fe80:0:0:0:0:0:0:1" );
260
+ // The fallback case "fe80:0:0:0:0:0:0:1" is needed for macOS 10.14/10.15 and (probably) later.
261
+ // Test that the delimiter "%" and default zone id of 0 can be omitted for the default scope.
262
+ BOOST_REQUIRE (LookupHost (link_local + " %0" , addr, false ));
263
+ BOOST_REQUIRE (addr.IsValid ());
264
+ BOOST_REQUIRE (addr.IsIPv6 ());
265
+ BOOST_CHECK (!addr.IsBindAny ());
266
+ BOOST_CHECK_EQUAL (addr.ToString (), link_local);
267
+
249
268
// TORv2
250
269
BOOST_REQUIRE (addr.SetSpecial (" 6hzph5hv6337r6p2.onion" ));
251
270
BOOST_REQUIRE (addr.IsValid ());
0 commit comments