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:
parent
26bcc09017
commit
215b1c234b
7 changed files with 85 additions and 81 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue