1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/llarp/service/address.cpp
Ryan Tharp e4214cb25e format
2018-08-17 03:40:14 -07:00

29 lines
679 B
C++

#include <algorithm>
#include <llarp/service/address.hpp>
namespace llarp
{
namespace service
{
std::string
Address::ToString() const
{
char tmp[(1 + 32) * 2] = {0};
std::string str = Base32Encode(*this, tmp);
return str + ".loki";
}
bool
Address::FromString(const std::string& str)
{
auto pos = str.find(".loki");
if(pos == std::string::npos)
return false;
auto sub = str.substr(0, pos);
// make sure it's lowercase
std::transform(sub.begin(), sub.end(), sub.begin(), ::tolower);
;
return Base32Decode(sub, *this);
}
} // namespace service
} // namespace llarp