peerplays_migrated/libraries/plugins/peerplays_sidechain/common/net_utl.cpp

29 lines
627 B
C++
Raw Normal View History

2021-10-21 18:34:42 +00:00
#include "net_utl.h"
2021-10-21 16:54:25 +00:00
#include <boost/asio.hpp>
namespace peerplays {
namespace net {
std::string resolveHostAddr(const std::string & hostName) {
using namespace boost::asio;
io_service service;
ip::tcp::resolver resolver(service);
auto query = ip::tcp::resolver::query(hostName, "");
auto iter = resolver.resolve(query);
auto endpoint = *iter;
2021-10-21 18:34:42 +00:00
auto addr = ((ip::tcp::endpoint)endpoint).address();
2021-10-21 16:54:25 +00:00
return addr.to_string();
}
2021-10-21 18:34:42 +00:00
std::string stripProtoName(const std::string & url) {
auto index = url.find("://");
if (index == std::string::npos)
2021-10-21 18:34:42 +00:00
return url;
return url.substr(index + 3);
}
2021-10-21 16:54:25 +00:00
} // net
} // peerplays