mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Suqash: Merge 4.0
This commit is contained in:
parent
7ab3e4a86c
commit
19c0a9eb4b
17 changed files with 84 additions and 184 deletions
|
@ -258,6 +258,24 @@ void srs_parse_endpoint(string hostport, string& ip, int& port)
|
|||
}
|
||||
}
|
||||
|
||||
bool srs_check_ip_addr_valid(string ip)
|
||||
{
|
||||
unsigned char buf[sizeof(struct in6_addr)];
|
||||
|
||||
// check ipv4
|
||||
int ret = inet_pton(AF_INET, ip.data(), buf);
|
||||
if (ret > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ret = inet_pton(AF_INET6, ip.data(), buf);
|
||||
if (ret > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
string srs_int2str(int64_t value)
|
||||
{
|
||||
// len(max int64_t) is 20, plus one "+-."
|
||||
|
@ -308,6 +326,7 @@ string srs_string_replace(string str, string old_str, string new_str)
|
|||
size_t pos = 0;
|
||||
while ((pos = ret.find(old_str, pos)) != std::string::npos) {
|
||||
ret = ret.replace(pos, old_str.length(), new_str);
|
||||
pos += new_str.length();
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue