mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #460, fix ipv6 intranet address filter bug. 3.0.93
This commit is contained in:
parent
bc6c61e546
commit
76d92792b7
8 changed files with 144 additions and 21 deletions
|
@ -157,7 +157,7 @@ srs_error_t srs_tcp_connect(string server, int port, srs_utime_t tm, srs_netfd_t
|
|||
|
||||
addrinfo hints;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
addrinfo* r = NULL;
|
||||
|
|
|
@ -115,8 +115,28 @@ bool srs_net_device_is_internet(const sockaddr* addr)
|
|||
}
|
||||
} else if(addr->sa_family == AF_INET6) {
|
||||
const sockaddr_in6* a6 = (const sockaddr_in6*)addr;
|
||||
if ((IN6_IS_ADDR_LINKLOCAL(&a6->sin6_addr)) ||
|
||||
(IN6_IS_ADDR_SITELOCAL(&a6->sin6_addr))) {
|
||||
|
||||
// IPv6 loopback is ::1
|
||||
if (IN6_IS_ADDR_LOOPBACK(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// IPv6 unspecified is ::
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// From IPv4, you might know APIPA (Automatic Private IP Addressing) or AutoNet.
|
||||
// Whenever automatic IP configuration through DHCP fails.
|
||||
// The prefix of a site-local address is FE80::/10.
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Site-local addresses are equivalent to private IP addresses in IPv4.
|
||||
// The prefix of a site-local address is FEC0::/10.
|
||||
// https://4sysops.com/archives/ipv6-tutorial-part-6-site-local-addresses-and-link-local-addresses/
|
||||
if (IN6_IS_ADDR_SITELOCAL(&a6->sin6_addr)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue