diff --git a/src/socket/address.cr b/src/socket/address.cr index 0670bc25a074..9c1993d1190e 100644 --- a/src/socket/address.cr +++ b/src/socket/address.cr @@ -228,8 +228,9 @@ class Socket addr.s_addr & 0x000000ff_u32 == 0x0000007f_u32 in LibC::In6Addr addr8 = ipv6_addr8(addr) - addr8 == StaticArray[0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 1_u8] || # "::1" - addr8.to_slice[0, 13] == StaticArray[0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 255_u8, 255_u8, 127_u8].to_slice # "::ffff:127.0.0.1/104" + num = addr8.unsafe_as(UInt128) + num == (1_u128 << 120) || # "::1" + num & 0xffffffffffffffffffffffffff_u128 == 0x7fffff00000000000000000000_u128 # "::ffff:127.0.0.1/104" end end