ipaddress-gem/ipaddress

NoMethodError: undefined method `loopback?' for 127.0.0.1:IPAddress::IPv4

Closed this issue · 5 comments

I'm trying to check if my IP is a loopback ip, I get this:

ip = IPAddress('127.0.0.1').loopback?
NoMethodError: undefined method `loopback?' for 127.0.0.1:IPAddress::IPv4
    from (irb):9
    from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
    from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
    from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Any ideas?

It is not implemented. The IPv6 equivalent doesn't seem completely valid either :

IPAddress(IPAddress("127.0.0.1").to_ipv6).loopback?
=> false

IPAddress("::ffff:127.0.0.1").loopback?
=> false
tisba commented

My current workaround is to check if a given IP address is included in 127.0.0.0/8 (I only need v4 currently). Would be a nice addition to the gem's feature set!

It'd be easy enough to include this in a PR but when is 1.0 coming out. I would imagine most are hesitant to contribute changes that would get clobbered by a major release.

This was fixed by Mike in f562a7f7

I'm doing some issue gardening 🌱🌿 🌷 and came upon this issue.

Fixed as per the comment above. Closing this issue, to avoid having lots of old issues open.