SRS 3.0 does not check if the address is empty when reading IP.
typcn opened this issue · comments
typcn commented
Winlin commented
Can't the network card be read?
TRANS_BY_GPT3
typcn commented
--- a/trunk/src/service/srs_service_utility.cpp
+++ b/trunk/src/service/srs_service_utility.cpp
@@ -149,7 +149,7 @@ void retrieve_local_ips()
// Discover IPv4 first.
for (ifaddrs* p = ifap; p ; p = p->ifa_next) {
ifaddrs* cur = p;
-
+ if(!cur->ifa_addr) continue;
// retrieve IP address, ignore the tun0 network device, whose addr is NULL.
// @see: https://github.com/ossrs/srs/issues/141
bool ipv4 = (cur->ifa_addr->sa_family == AF_INET);
@@ -163,7 +163,7 @@ void retrieve_local_ips()
// Then, discover IPv6 addresses.
for (ifaddrs* p = ifap; p ; p = p->ifa_next) {
ifaddrs* cur = p;
-
+ if(!cur->ifa_addr) continue;
// retrieve IP address, ignore the tun0 network device, whose addr is NULL.
// @see: https://github.com/ossrs/srs/issues/141
bool ipv6 = (cur->ifa_addr->sa_family == AF_INET6);
If a network card does not have any IP address, ifa_addr will be empty, so it needs to be checked.
TRANS_BY_GPT3
Winlin commented
👍
zhengqiang.wang commented
srs did not obtain an IPv4 address, but obtained an IPv6 address, causing an error in the RTMP connection socket. It is necessary to specify the network card address, as automatic DHCP address acquisition is not working. Therefore, configure the specified IP or server_id configuration.
TRANS_BY_GPT3