mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Add utest for srs_rtp_seq_distance
This commit is contained in:
parent
be1b0bf941
commit
3f5ab8dc63
13 changed files with 206 additions and 38 deletions
|
@ -350,9 +350,12 @@ srs_error_t SrsHttpMessage::set_url(string url, bool allow_jsonp)
|
|||
// use server public ip when host not specified.
|
||||
// to make telnet happy.
|
||||
std::string host = _header.get("Host");
|
||||
|
||||
// If no host in header, we use local discovered IP, IPv4 first.
|
||||
if (host.empty()) {
|
||||
host= srs_get_public_internet_address();
|
||||
host = srs_get_public_internet_address(true);
|
||||
}
|
||||
|
||||
if (!host.empty()) {
|
||||
uri = "http://" + host + _url;
|
||||
}
|
||||
|
|
|
@ -139,6 +139,26 @@ bool srs_net_device_is_internet(const sockaddr* addr)
|
|||
if (IN6_IS_ADDR_SITELOCAL(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Others.
|
||||
if (IN6_IS_ADDR_MULTICAST(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
if (IN6_IS_ADDR_MC_NODELOCAL(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
if (IN6_IS_ADDR_MC_LINKLOCAL(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
if (IN6_IS_ADDR_MC_SITELOCAL(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
if (IN6_IS_ADDR_MC_ORGLOCAL(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
if (IN6_IS_ADDR_MC_GLOBAL(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -287,7 +307,7 @@ vector<SrsIPAddress*>& srs_get_local_ips()
|
|||
|
||||
std::string _public_internet_address;
|
||||
|
||||
string srs_get_public_internet_address()
|
||||
string srs_get_public_internet_address(bool ipv4_only)
|
||||
{
|
||||
if (!_public_internet_address.empty()) {
|
||||
return _public_internet_address;
|
||||
|
@ -301,6 +321,9 @@ string srs_get_public_internet_address()
|
|||
if (!ip->is_internet) {
|
||||
continue;
|
||||
}
|
||||
if (ipv4_only && !ip->is_ipv4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
srs_warn("use public address as ip: %s, ifname=%s", ip->ip.c_str(), ip->ifname.c_str());
|
||||
_public_internet_address = ip->ip;
|
||||
|
@ -313,6 +336,9 @@ string srs_get_public_internet_address()
|
|||
if (ip->is_loopback) {
|
||||
continue;
|
||||
}
|
||||
if (ipv4_only && !ip->is_ipv4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
srs_warn("use private address as ip: %s, ifname=%s", ip->ip.c_str(), ip->ifname.c_str());
|
||||
_public_internet_address = ip->ip;
|
||||
|
|
|
@ -67,7 +67,7 @@ struct SrsIPAddress
|
|||
extern std::vector<SrsIPAddress*>& srs_get_local_ips();
|
||||
|
||||
// Get local public ip, empty string if no public internet address found.
|
||||
extern std::string srs_get_public_internet_address();
|
||||
extern std::string srs_get_public_internet_address(bool ipv4_only = false);
|
||||
|
||||
// Detect whether specified device is internet public address.
|
||||
extern bool srs_net_device_is_internet(std::string ifname);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue