1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refine the local ip and interface retrieve

This commit is contained in:
winlin 2020-05-09 10:40:25 +08:00
parent 26bcc09017
commit 215b1c234b
7 changed files with 85 additions and 81 deletions

View file

@ -111,15 +111,20 @@ static std::vector<std::string> get_candidate_ips()
std::vector<std::string> candidate_ips;
string candidate = _srs_config->get_rtc_server_candidates();
if (candidate == "*" || candidate == "0.0.0.0") {
std::vector<std::string> tmp = srs_get_local_ips();
for (int i = 0; i < (int)tmp.size(); ++i) {
if (tmp[i] != "127.0.0.1") {
candidate_ips.push_back(tmp[i]);
}
}
} else {
if (candidate != "*" && candidate != "0.0.0.0") {
candidate_ips.push_back(candidate);
return candidate_ips;
}
// For * or 0.0.0.0, auto discovery expose ip addresses.
std::vector<SrsIPAddress*>& ips = srs_get_local_ips();
for (int i = 0; i < (int)ips.size(); ++i) {
SrsIPAddress* ip = ips[i];
if (!ip->is_loopback) {
continue;
}
candidate_ips.push_back(ip->ip);
}
return candidate_ips;