From 11d17017fd1d135ce979e3fbff0adc4f71501bc6 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 7 Jan 2025 12:25:35 -0500 Subject: [PATCH] net: replace deprecated ip::address_v4::from_string() boost::asio::ip::address_v4::from_string() was removed in boost 1.87, leading to compilation failures: src/seastar/src/net/ip.cc:44:46: error: no member named 'from_string' in 'boost::asio::ip::address_v4' auto ipv4 = boost::asio::ip::address_v4::from_string(addr, ec); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ prior to 1.87, the function had been documented as deprecated [1]: > (Deprecated: Use make_address_v4().) [1] https://www.boost.org/doc/libs/1_86_0/doc/html/boost_asio/reference/ip__address_v4/from_string.html Signed-off-by: Casey Bodley Closes scylladb/seastar#2610 --- src/net/ip.cc | 2 +- src/net/net.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/net/ip.cc b/src/net/ip.cc index 75c8ae4048e..ed158b33596 100644 --- a/src/net/ip.cc +++ b/src/net/ip.cc @@ -41,7 +41,7 @@ namespace net { ipv4_address::ipv4_address(const std::string& addr) { boost::system::error_code ec; - auto ipv4 = boost::asio::ip::address_v4::from_string(addr, ec); + auto ipv4 = boost::asio::ip::make_address_v4(addr, ec); if (ec) { throw std::runtime_error( fmt::format("Wrong format for IPv4 address {}. Please ensure it's in dotted-decimal format", addr)); diff --git a/src/net/net.cc b/src/net/net.cc index ef722e2b78b..587de31be03 100644 --- a/src/net/net.cc +++ b/src/net/net.cc @@ -57,17 +57,17 @@ ipv4_addr::ipv4_addr(const std::string &addr) { std::vector items; boost::split(items, addr, boost::is_any_of(":")); if (items.size() == 1) { - ip = boost::asio::ip::address_v4::from_string(addr).to_ulong(); + ip = boost::asio::ip::make_address_v4(addr).to_ulong(); port = 0; } else if (items.size() == 2) { - ip = boost::asio::ip::address_v4::from_string(items[0]).to_ulong(); + ip = boost::asio::ip::make_address_v4(items[0]).to_ulong(); port = std::stoul(items[1]); } else { throw std::invalid_argument("invalid format: " + addr); } } -ipv4_addr::ipv4_addr(const std::string &addr, uint16_t port_) : ip(boost::asio::ip::address_v4::from_string(addr).to_ulong()), port(port_) {} +ipv4_addr::ipv4_addr(const std::string &addr, uint16_t port_) : ip(boost::asio::ip::make_address_v4(addr).to_ulong()), port(port_) {} ipv4_addr::ipv4_addr(const net::inet_address& a, uint16_t port) : ipv4_addr(::in_addr(a), port)