Skip to content

Commit 2def747

Browse files
committed
use array instead vector for reserved ranges
1 parent 6a65680 commit 2def747

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

libi2pd/util.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013-2024, The PurpleI2P Project
2+
* Copyright (c) 2013-2025, The PurpleI2P Project
33
*
44
* This file is part of Purple i2pd project and licensed under BSD3
55
*
@@ -8,6 +8,7 @@
88

99
#include <cstdlib>
1010
#include <string>
11+
#include <array>
1112
#include <unordered_set>
1213
#include <boost/asio.hpp>
1314

@@ -123,8 +124,8 @@ const char *inet_ntop_xp(int af, const void *src, char *dst, socklen_t size)
123124
#endif
124125
#endif
125126

126-
#define address_pair_v4(a,b) { boost::asio::ip::make_address (a).to_v4 ().to_uint (), boost::asio::ip::make_address(b).to_v4 ().to_uint () }
127-
#define address_pair_v6(a,b) { boost::asio::ip::make_address (a).to_v6 ().to_bytes (), boost::asio::ip::make_address(b).to_v6 ().to_bytes () }
127+
#define address_pair_v4(a,b) std::pair{ boost::asio::ip::make_address (a).to_v4 ().to_uint (), boost::asio::ip::make_address(b).to_v4 ().to_uint () }
128+
#define address_pair_v6(a,b) std::pair{ boost::asio::ip::make_address (a).to_v6 ().to_bytes (), boost::asio::ip::make_address(b).to_v6 ().to_bytes () }
128129

129130
namespace i2p
130131
{
@@ -647,7 +648,8 @@ namespace net
647648
if (host.is_unspecified ()) return false;
648649
if (host.is_v4())
649650
{
650-
static const std::vector< std::pair<uint32_t, uint32_t> > reservedIPv4Ranges {
651+
static const std::array<std::pair<uint32_t, uint32_t>, 14> reservedIPv4Ranges
652+
{
651653
address_pair_v4("0.0.0.0", "0.255.255.255"),
652654
address_pair_v4("10.0.0.0", "10.255.255.255"),
653655
address_pair_v4("100.64.0.0", "100.127.255.255"),
@@ -672,7 +674,8 @@ namespace net
672674
}
673675
if (host.is_v6())
674676
{
675-
static const std::vector< std::pair<boost::asio::ip::address_v6::bytes_type, boost::asio::ip::address_v6::bytes_type> > reservedIPv6Ranges {
677+
static const std::array<std::pair<boost::asio::ip::address_v6::bytes_type, boost::asio::ip::address_v6::bytes_type>, 7> reservedIPv6Ranges
678+
{
676679
address_pair_v6("64:ff9b::", "64:ff9b:ffff:ffff:ffff:ffff:ffff:ffff"), // NAT64
677680
address_pair_v6("2001:db8::", "2001:db8:ffff:ffff:ffff:ffff:ffff:ffff"),
678681
address_pair_v6("fc00::", "fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"),

0 commit comments

Comments
 (0)