End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Addrinfo#ipv4_loopback?
ipv4_loopback?
ext/socket/raddrinfo.c
View on GitHub ↗
static VALUE
addrinfo_ipv4_loopback_p(VALUE self)
{
uint32_t a;
if (!extract_in_addr(self, &a)) return Qfalse;
if ((a & 0xff000000) == 0x7f000000) /* 127.0.0.0/8 */
return Qtrue;
return Qfalse;
}
Returns true for IPv4 loopback address (127.0.0.0/8). It returns false otherwise.
See also
#ipv4?
#ipv4_multicast?
#ip_unpack
#ipv4_private?
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1