Project

General

Profile

Actions

Feature #11210

closed

IPAddr has no public method to get the current subnet mask

Added by herwinw (Herwin Quarantainenet) almost 9 years ago. Updated about 5 years ago.

Status:
Closed
Target version:
-
[ruby-core:69447]

Description

Both to_s and to_string omit the subnet mask of an IP address. The only way to query it via public methods is to manually parse the output of inspect.


Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #11527: IPAddr#mask_addr isn't a methodAssignedknu (Akinori MUSHA)Actions

Updated by bjmllr (Ben Miller) almost 9 years ago

It would be useful to expose @mask_addr. I have done this at times by reopening IPAddr and adding an attr_reader. Then the string form of the mask can be obtained with

IPAddr.new(addr.mask_addr, addr.family).to_s

#mask_addr is also useful when doing subnetting operations which are beyond the scope of IPAddr.

Updated by Eregon (Benoit Daloze) about 8 years ago

  • Assignee set to knu (Akinori MUSHA)

Assigning this to the official maintainer of ipaddr.
Or should it be assigned to matz?

Could this be decided at the next Developer meeting or sooner?

See https://github.com/ruby/ruby/pull/1269 for the patch.

Updated by knu (Akinori MUSHA) almost 8 years ago

  • Status changed from Open to Assigned

Sorry for being inactive.

I've made some comments in the above PR.

I can't recall the exact reason why there's no access to the netmask provided, but one main design concept of IPAddr by the original author (Ume-san) was to allow manipulating IP addresses independent of what family each instance is in, so I'd welcome the PR in that it introduces an address family independent class for returning values.

Except for a few things I mentioned in the PR it looks good to merge, so please toss your feedback to it if you have any opinions. Thank you.

Updated by herwin (Herwin W) over 7 years ago

Any progress? I believe all the comments have been addressed.

Actions #5

Updated by usa (Usaku NAKAMURA) over 6 years ago

Updated by Eregon (Benoit Daloze) over 6 years ago

@knu (Akinori MUSHA): Could you review the PR and decide whether to merge it?

Updated by herwin (Herwin W) about 6 years ago

https://github.com/ruby/ipaddr/commit/293ad5ac6ed704f91d418ecaf24ae58156a587e7 fixes this in the ipaddr gem. Good enough for me, I guess this issue can be closed.

Actions #8

Updated by knu (Akinori MUSHA) about 5 years ago

  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0