Is there a way to identify a Shared Address Space IP address ? (

Hey everyone,
This is kinda similar to my previous post about link local IPs: Shouldn't the IP address "" be a private IP?

This is the problem - tested with Crystal 1.8.2:

icr:1> require "socket"
 => nil
icr:2> ip_address ="", 1)
 => Socket::IPAddress(
icr:3> ip_address.private?
 => false
icr:4> ip_address.loopback?
 => false

Currently, unless I’m mistaken, there’s no way for Crystal to classify an IP address in the range. Those IPs are not private IPs or loopback IPs or public IPs.

Would it make sense to add a .shared_address_space? function or something similar so that those IPs can be correctly classified ?

The relevant RFC seems to be: RFC 6598: IANA-Reserved IPv4 Prefix for Shared Address Space
Here’s the discussion about the same issue in Python: ipaddress should make it easy to identify rfc6598 addresses · Issue #61602 · python/cpython · GitHub


I am starting to think we should have something like ip_address.in_range?("") in the standard library on top of those predefined classification methods. This is easier than before now that Socket::IPAddress.parse_v*_fields? exist

1 Like

that would definitely work for me! Just to clarify: this isn’t possible at the moment right?