Allow reading unmasked address when passed a CIDR string

未关闭
#67 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
ruby
领域
networking

调研方向

从 lib/ipaddr.rb 的第 649-651 行开始,跟踪 CIDR 字符串的解析和存储方式。将当前的地址和网络掩码访问器与所请求的行为进行比较,然后定义 API 变更,使 1.2.3.4/16 的未屏蔽地址和网络掩码都可以被读回。

由索引模型根据 Issue 内容生成。

描述

This behavior caught me by surprise:

> ip = IPAddr.new('1.2.3.4/16')
=> #<IPAddr: IPv4:1.2.0.0/255.255.0.0>       
> ip.to_s
=> "1.2.0.0"           

Looking at the code I believe this is happening at https://github.com/ruby/ipaddr/blob/master/lib/ipaddr.rb#L649-L651, which is a very old commit, so this behavior is clearly expected. For my use case I need the host bits unmasked, so I want to parse 1.2.3.4/16 and be able to read back something like ip.address as 1.2.3.4 and the netmask as 255.255.0.0. It looks like that's not currently possible with this gem, which surprises me. Am I overlooking a method, or is there a nuance in the CIDR spec implemented here I've forgotten?

主要语言
Ruby
星标
82
派生
42
平均合并
2 小时 24 分钟
30 天内合并 PR
3

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/ipaddr 的其他 Issue

查看 ruby/ipaddr 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。