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

Merge branch 'develop' into merge/develop

This commit is contained in:
winlin 2021-10-20 09:13:05 +08:00
commit ce9edb9166
2 changed files with 10 additions and 2 deletions

View file

@ -189,7 +189,7 @@ void srs_parse_hostport(string hostport, string& host, int& port)
if (hostport.find(":") == pos) { if (hostport.find(":") == pos) {
host = hostport.substr(0, pos); host = hostport.substr(0, pos);
string p = hostport.substr(pos + 1); string p = hostport.substr(pos + 1);
if (!p.empty()) { if (!p.empty() && p != "0") {
port = ::atoi(p.c_str()); port = ::atoi(p.c_str());
} }
return; return;
@ -204,7 +204,7 @@ void srs_parse_hostport(string hostport, string& host, int& port)
// For ipv6, [host]:port. // For ipv6, [host]:port.
host = hostport.substr(1, pos - 1); host = hostport.substr(1, pos - 1);
string p = hostport.substr(pos + 2); string p = hostport.substr(pos + 2);
if (!p.empty()) { if (!p.empty() && p != "0") {
port = ::atoi(p.c_str()); port = ::atoi(p.c_str());
} }
} }

View file

@ -4571,6 +4571,14 @@ VOID TEST(KernelUtilityTest, CoverTimeUtilityAll)
EXPECT_STREQ("domain.com", host.c_str()); EXPECT_STREQ("domain.com", host.c_str());
} }
if (true) {
string host;
int port = 1935;
srs_parse_hostport("domain.com:0", host, port);
EXPECT_EQ(1935, port);
EXPECT_STREQ("domain.com", host.c_str());
}
if (true) { if (true) {
string ep = srs_any_address_for_listener(); string ep = srs_any_address_for_listener();
EXPECT_TRUE(ep == "0.0.0.0" || ep == "::"); EXPECT_TRUE(ep == "0.0.0.0" || ep == "::");