mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Support get hostname
This commit is contained in:
parent
26f73e7593
commit
38f935ead8
2 changed files with 21 additions and 0 deletions
|
@ -382,3 +382,21 @@ string srs_get_original_ip(ISrsHttpMessage* r)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string _srs_system_hostname;
|
||||||
|
|
||||||
|
string srs_get_system_hostname()
|
||||||
|
{
|
||||||
|
if (!_srs_system_hostname.empty()) {
|
||||||
|
return _srs_system_hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buf[256];
|
||||||
|
if (-1 == gethostname(buf, sizeof(buf))) {
|
||||||
|
srs_warn("gethostbyname fail");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
_srs_system_hostname = std::string(buf);
|
||||||
|
return _srs_system_hostname;
|
||||||
|
}
|
|
@ -76,5 +76,8 @@ extern bool srs_net_device_is_internet(const sockaddr* addr);
|
||||||
// Get the original ip from query and header by proxy.
|
// Get the original ip from query and header by proxy.
|
||||||
extern std::string srs_get_original_ip(ISrsHttpMessage* r);
|
extern std::string srs_get_original_ip(ISrsHttpMessage* r);
|
||||||
|
|
||||||
|
// Get hostname
|
||||||
|
extern std::string srs_get_system_hostname(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue