Codechange: [Network] Make hostname/client IP return strings instead of a C-string

This commit is contained in:
rubidium42
2021-06-13 21:05:15 +02:00
committed by rubidium42
parent a91e29b656
commit 667301e3ec
5 changed files with 7 additions and 7 deletions

View File

@@ -19,7 +19,7 @@
* IPv4 dotted representation is given.
* @return the hostname
*/
const char *NetworkAddress::GetHostname()
const std::string &NetworkAddress::GetHostname()
{
if (this->hostname.empty() && this->address.ss_family != AF_UNSPEC) {
assert(this->address_length != 0);
@@ -27,7 +27,7 @@ const char *NetworkAddress::GetHostname()
getnameinfo((struct sockaddr *)&this->address, this->address_length, buffer, sizeof(buffer), nullptr, 0, NI_NUMERICHOST);
this->hostname = buffer;
}
return this->hostname.c_str();
return this->hostname;
}
/**