Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: replace deprecated ip::address_v4::from_string() #2610

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/net/ip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/net/net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ ipv4_addr::ipv4_addr(const std::string &addr) {
std::vector<std::string> 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)
Expand Down
Loading