client bug fix: smaller ips convert to hex

This commit is contained in:
2019-05-16 14:07:58 +02:00
parent f1a1391866
commit 9315768159
2 changed files with 9 additions and 4 deletions

View File

@ -31,9 +31,9 @@ std::string IpAddr::str() const {
}
std::string IpAddr::hex() const {
std::ostringstream ss;
ss << std::hex << std::setfill('0') << std::setw(2);
for (int i = 0; i != 4; ++i) {
ss << ((addr_ >> i * 8) & 0xFF);
ss << std::hex << std::setfill('0') << std::setw(2)
<< ((addr_ >> i * 8) & 0xFF);
}
return ss.str();
}