Hey everyone,
I have a script that checks whether an IP is public or private. Here are the important bits from crystal i
Crystal interpreter 1.7.2 (2023-01-23).
EXPERIMENTAL SOFTWARE: if you find a bug, please consider opening an issue in
https://github.com/crystal-lang/crystal/issues/new/
icr:1> require "socket"
=> nil
icr:2> ip_address = Socket::IPAddress.new("169.254.169.254", 0)
=> Socket::IPAddress(169.254.169.254:0)
icr:3> ip_address.private?
=> false
icr:4> ip_address.loopback?
=> false
icr:5> ip_address.unspecified?
=> false
icr:6>
My question is - shouldn’t the IP 169.254.169.254
come up as a Private IP ?
If not - what’s the best way to check if this IP is not a public IP ?
Thanks!