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

For #1920, refine rtmp listen ip and port check (#2581)

This commit is contained in:
ChenGH 2021-09-05 14:05:28 +08:00 committed by GitHub
parent 714e182096
commit 3f94d26ca4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 3 deletions

View file

@ -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 "+-."