@@ -139,12 +139,26 @@ BC_POP_WARNING()
139
139
// asio/asio conversions.
140
140
// ----------------------------------------------------------------------------
141
141
142
- inline bool is_embedded_v4 (const boost::asio::ip::address_v6& ip6) NOEXCEPT
142
+ // address_v6.to_v4 removed in boost 1.87, no replacement.
143
+ inline asio::address to_v4 (const boost::asio::ip::address_v6& ip6) THROWS
143
144
{
144
- BC_PUSH_WARNING (NO_THROW_IN_NOEXCEPT)
145
- // is_v4_compatible is deprecated, removed in 1.87, no replacement.
146
- return ip6.is_v4_mapped () || ip6.is_v4_compatible ();
147
- BC_POP_WARNING ()
145
+ // Required for equivalence with boost 1.86.
146
+ if (!ip6.is_v4_mapped ())
147
+ throw std::exception{};
148
+
149
+ const auto bytes = ip6.to_bytes ();
150
+ return
151
+ {
152
+ boost::asio::ip::address_v4
153
+ {
154
+ boost::asio::ip::address_v4::bytes_type
155
+ {
156
+ {
157
+ bytes.at (12 ), bytes.at (13 ), bytes.at (14 ), bytes.at (15 )
158
+ }
159
+ }
160
+ }
161
+ };
148
162
}
149
163
150
164
// Convert IPv6-mapped to IPV4 (ensures consistent internal matching).
@@ -155,13 +169,11 @@ asio::address denormalize(const asio::address& ip) NOEXCEPT
155
169
{
156
170
try
157
171
{
158
- const auto ip6 = ip.to_v6 ();
159
-
160
- // to_v4 is deprecated, removed in 1.87, no replacement.
161
- if (is_embedded_v4 (ip6)) return { ip6.to_v4 () };
172
+ return { to_v4 (ip.to_v6 ()) };
162
173
}
163
174
catch (const std::exception&)
164
175
{
176
+ return ip;
165
177
}
166
178
}
167
179
@@ -176,7 +188,7 @@ inline std::string to_host(const boost::asio::ip::address_v6& ip6) NOEXCEPT
176
188
try
177
189
{
178
190
BC_PUSH_WARNING (NO_THROW_IN_NOEXCEPT)
179
- return is_embedded_v4 ( ip6) ? to_host (ip6. to_v4 ()) : ip6.to_string ();
191
+ return ip6. is_v4_mapped ( ) ? to_host (to_v4 (ip6 )) : ip6.to_string ();
180
192
BC_POP_WARNING ()
181
193
}
182
194
catch (const std::exception&)
0 commit comments