Project

General

Profile

Feature #10912

Add method(s) to IPAddr for determining whether an address is link local

Added by postmodern (Hal Brodigan) over 4 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:68332]

Description

I was surprised to find that IPAddr has no methods for determining whether an address is a link local address (ie RFC1918 or RFC5735). This would make it easy to blacklist local IP addresses from services.


Related issues

Is duplicate of Ruby master - Feature #11666: IPAddr#private?ClosedActions

Associated revisions

Revision c2db917b
Added by knu (Akinori MUSHA) almost 2 years ago

Import ipaddr 1.2.0

  • Add IPAddr#prefix
  • Add IPAddr#loopback?
  • Add IPAddr#private? [Feature #11666]
  • Add IPAddr#link_local? [Feature #10912]
  • Reject invalid address mask [Bug #13399]
  • Warn that IPAddr#ipv4_compat and #ipv4_compat? are deprecated [#Bug 13769]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 60270
Added by knu (Akinori MUSHA) almost 2 years ago

Import ipaddr 1.2.0

  • Add IPAddr#prefix
  • Add IPAddr#loopback?
  • Add IPAddr#private? [Feature #11666]
  • Add IPAddr#link_local? [Feature #10912]
  • Reject invalid address mask [Bug #13399]
  • Warn that IPAddr#ipv4_compat and #ipv4_compat? are deprecated [#Bug 13769]

Revision 60270
Added by knu (Akinori MUSHA) almost 2 years ago

Import ipaddr 1.2.0

  • Add IPAddr#prefix
  • Add IPAddr#loopback?
  • Add IPAddr#private? [Feature #11666]
  • Add IPAddr#link_local? [Feature #10912]
  • Reject invalid address mask [Bug #13399]
  • Warn that IPAddr#ipv4_compat and #ipv4_compat? are deprecated [#Bug 13769]

Revision 60270
Added by knu (Akinori MUSHA) almost 2 years ago

Import ipaddr 1.2.0

  • Add IPAddr#prefix
  • Add IPAddr#loopback?
  • Add IPAddr#private? [Feature #11666]
  • Add IPAddr#link_local? [Feature #10912]
  • Reject invalid address mask [Bug #13399]
  • Warn that IPAddr#ipv4_compat and #ipv4_compat? are deprecated [#Bug 13769]

History

Updated by knqyf263 (Teppei Fukuda) almost 3 years ago

I also want a method to determine whether an address is link-local.
There is a proposal for a fix on https://github.com/ruby/ruby/pull/1494 .

#2

Updated by shyouhei (Shyouhei Urabe) almost 3 years ago

Updated by knqyf263 (Teppei Fukuda) almost 3 years ago

Is there any progress?

In RFC 4291 2.4, the type of an IPv6 address is defined, as follows:

  Address type         Binary prefix        IPv6 notation   Section
  ------------         -------------        -------------   -------
  Unspecified          00...0  (128 bits)   ::/128          2.5.2
  Loopback             00...1  (128 bits)   ::1/128         2.5.3
  Multicast            11111111             FF00::/8        2.7
  Link-Local unicast   1111111010           FE80::/10       2.5.6
  Global Unicast       (everything else)

"Private-Use" network is not defined, but the above five address types are clearly defined.
These addresses are also defined in IPv4 (RFC 6890 2.2.2).
Although "unspecified" network is not clearly defined in IPv4, it can be considered as 0.0.0.0/8.

Is it difficult to add methods to determine these networks?
If it is not good to mix IPv4 and IPv6, I think there is a way to separate method names(like ipv4_linklocal? and ipv6_linklocal?)

Updated by shyouhei (Shyouhei Urabe) over 2 years ago

  • Assignee set to knu (Akinori MUSHA)
  • Status changed from Open to Assigned
#5

Updated by knu (Akinori MUSHA) almost 2 years ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r60270.


Import ipaddr 1.2.0

  • Add IPAddr#prefix
  • Add IPAddr#loopback?
  • Add IPAddr#private? [Feature #11666]
  • Add IPAddr#link_local? [Feature #10912]
  • Reject invalid address mask [Bug #13399]
  • Warn that IPAddr#ipv4_compat and #ipv4_compat? are deprecated [#Bug 13769]

Updated by knu (Akinori MUSHA) almost 2 years ago

Added, thanks for the suggestion.

Also available in: Atom PDF