Граф коммитов

69 Коммитов

Автор SHA1 Сообщение Дата
Akinori MUSHA b101ca598e [ruby/ipaddr] Bump the version to 1.2.7
https://github.com/ruby/ipaddr/commit/b44d2a1173
2024-10-19 12:59:03 +00:00
Akinori MUSHA bfc586b2be [ruby/ipaddr] Use string interpolation instead of format()
https://github.com/ruby/ipaddr/commit/1f41cd7320
2024-10-19 12:56:27 +00:00
Akinori MUSHA 689f14e255 [ruby/ipaddr] Use string interpolation instead of format()
https://github.com/ruby/ipaddr/commit/73f59e111f
2024-10-18 16:03:49 +00:00
Taketo Takashima eb8cf1d60e [ruby/ipaddr] Added to_json/as_json method
Updated to use cidr method when return address with prefix in #as_json

https://github.com/ruby/ipaddr/commit/cf8181d53e
2024-10-18 15:00:37 +00:00
Ben Fritsch 6ac8f6a10e
[ruby/ipaddr] Add IPAddr.cidr to return ip address in cidr notation
https://github.com/ruby/ipaddr/commit/f5b006741f
2024-04-18 10:27:19 +09:00
Taketo Takashima f9f25d0ed0 [ruby/ipaddr] Added IPAddr#wildcard_mask
https://github.com/ruby/ipaddr/commit/2093cebc1d
2024-04-10 10:30:53 +00:00
Akira Matsuda 73dd3ce03e [ruby/ipaddr] Prefer String#start_with? over Regexp.match
https://github.com/ruby/ipaddr/commit/054fe12ec4
2024-02-23 17:56:08 +00:00
Akira Matsuda 6ad52e336d [ruby/ipaddr] String#split seems to be faster than capturing digits with Regexp
https://github.com/ruby/ipaddr/commit/e0feb0708b
2024-02-23 17:55:33 +00:00
Earlopain 86fa418dea [ruby/ipaddr] Consider IPv4-mapped IPv6 addresses link local/loopback if IPV4 address is private
Same as #57

https://github.com/ruby/ipaddr/commit/d56acecb80
2023-12-25 21:12:49 +09:00
Luke Randall da77c79d80 [ruby/ipaddr] Fix regressions in exception messages
Changes introduced by 09edfd4 have broken some exception
messages, and added the address as an unnecessary
suffix in others.

https://github.com/ruby/ipaddr/commit/74a043109c
2023-12-25 21:12:49 +09:00
Kasumi Hanazuki eb53131367 [ruby/ipaddr] ntop: Measure address size in bytes
`IPAddr.ntop` takes the binary representation of an IP address, whose
length should be 4 or 16 *bytes* (not characters/codepoints).

The current implementation accepts strings in any encoding, but for
some values in non-BINARY encoding, it fails proper length check and
raises an `AddressFamilyError`. Since passing strings in a multibyte
encoding has never worked correctly for years, this patch makes it an
explicit error with an `InvalidAddressError`.

Fixes: https://github.com/ruby/ipaddr/issues/56

https://github.com/ruby/ipaddr/commit/a33fd14d4a
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA 4fd3c85acd
[ruby/ipaddr] Bump up v1.2.6
https://github.com/ruby/ipaddr/commit/247459faa5
2023-12-16 13:20:55 +08:00
Hartley McGuire e581b78ed2 Improve performance of include? by 5-10x
Rails uses IPAddr#include? to evaluate what it should use as the
client's remote ip by filtering potential ips against a trusted list
of internal ips. In a _very_ minimal app, #include? was showing up in
a profile as ~1% of request time.

The issue is that #include? was converting itself and the other value
passed in to ranges of IPAddr. This mean as a worst case (where other is
a non-IPAddr, like a String) then there would be 5 IPAddr instances
created (other -> IPAddr, and two each for the conversions to ranges).
However, wrapping the begin and end values as IPAddr is not needed
because they are necessarily fixed addresses already.

This patch extracts the logic for getting the begin_addr and end_addr
from the #to_range method so that they can be used in #include? without
having to instantiate so many IPAddr.

Benchmark:

```ruby
net1 = IPAddr.new("192.168.2.0/24")
net2 = IPAddr.new("192.168.2.100")
net3 = IPAddr.new("192.168.3.0")
net4 = IPAddr.new("192.168.2.0/16")

Benchmark.ips do |x|
  x.report("/24 includes address") { net1.include? net2 }
  x.report("/24 not includes address") { net1.include? net3 }
  x.report("/16 includes /24") { net4.include? net1 }
  x.report("/24 not includes /16") { net1.include? net4 }
  x.compare!
end
```

Before:

```
Comparison:
    /24 not includes /16:   175041.3 i/s
/24 not includes address:   164933.2 i/s - 1.06x  (± 0.00) slower
        /16 includes /24:   163881.9 i/s - 1.07x  (± 0.00) slower
    /24 includes address:   163558.4 i/s - 1.07x  (± 0.00) slower
```

After:

```
Comparison:
    /24 not includes /16:  2588364.9 i/s
/24 not includes address:  1474650.7 i/s - 1.76x  (± 0.00) slower
        /16 includes /24:  1461351.0 i/s - 1.77x  (± 0.00) slower
    /24 includes address:  1425463.5 i/s - 1.82x  (± 0.00) slower
```
2023-09-23 02:22:25 +00:00
Jeremy Evans de51a4a13e [ruby/ipaddr] Consider IPv4-mapped IPv6 addresses private if IPv4 address is private
Fixes [Bug #19479]

https://github.com/ruby/ipaddr/commit/7faa0768d3
2023-06-22 16:40:46 +00:00
Hiroshi SHIBATA 51cfe70135 [ruby/ipaddr] Bump version to 1.2.5
https://github.com/ruby/ipaddr/commit/d92acb3982
2022-12-05 06:32:03 +00:00
rm155 70e6be2b05 [ruby/ipaddr] Improve Ractor-compliance
https://github.com/ruby/ipaddr/commit/73461724e5
2022-09-08 14:09:06 +09:00
Hiroshi SHIBATA 52d3e31d27
[ruby/ipaddr] Bump version to 1.2.4
https://github.com/ruby/ipaddr/commit/6edf6ee6c3
2022-02-10 17:18:05 +09:00
Espartaco Palma 9b768012f6
[ruby/ipaddr] Fix exception calling `to_range' after `freeze'
https://github.com/ruby/ipaddr/commit/77fe1fca0a
2022-02-10 17:18:05 +09:00
Jean Boussier 100253c7f0
[ruby/ipaddr] Ipaddr#native must also coerce `@mask_addr`
Before it would be left as an IPv6 mask causing `to_range` to fail.

```
>> IPAddr.new("::2").native.to_range
/opt/rubies/3.0.3/lib/ruby/3.0.0/ipaddr.rb:479:in `set': invalid address (IPAddr::InvalidAddressError)
```

https://github.com/ruby/ipaddr/commit/af485192f3
2022-02-10 17:18:05 +09:00
Jean Boussier 5221cb4468
[ruby/ipaddr] Expose IPAddr::VERSION
An almost universal convention for gems is to expose Namespace::VERSION
which makes it much easier when debugging etc.

https://github.com/ruby/ipaddr/commit/587ae6996e
2022-02-10 17:18:03 +09:00
Jeremy Evans 391d6ab4f7
[ruby/ipaddr] Fix include? and ipv4_mapped to allow drb tests to pass
include? should return false if comparing an IPv4 address to an IPv6
address.

ipv4_mapped needs to set the correct netmask on the mapped
addresses.

https://github.com/ruby/ipaddr/commit/da22ef8e6c
2021-10-11 13:50:54 +09:00
Jeremy Evans 9a321dd9b2
[ruby/ipaddr] Make IPAddr#include? consider range of argument
It would be nice to use Range#cover? here, but it doesn't work
correctly before Ruby 2.6. Switch to manual checks of the beginning
of end of the ranges.

Fixes Ruby Bug 14119

https://github.com/ruby/ipaddr/commit/f45630da31
2021-10-11 13:50:54 +09:00
Jeremy Evans bd6e1a0f08
[ruby/ipaddr] Support zone identifiers in IPv6 addresses
These are supported by Ruby's socket library if the operating system
supports zone indentifiers, so they should be supported by ipaddr.
See RFCs 4007 and 6874 for additional information.

Implements Ruby Feature #10911

https://github.com/ruby/ipaddr/commit/09a6408fb2
2021-10-07 18:22:43 +09:00
Bogdan Irimie 74ed881e10
[ruby/ipaddr] Add netmask method that returns net mask as string.
https://github.com/ruby/ipaddr/commit/283d16f3a3
2021-10-07 18:22:43 +09:00
Jeremy Evans abad5e10e8
[ruby/ipaddr] Disallow leading zeros in mask
https://github.com/ruby/ipaddr/commit/f49d2d49a4
2021-10-07 18:22:43 +09:00
Nobuyoshi Nakada 38da84296c
[ruby/ipaddr] Raise if extra slashes follow
https://bugs.ruby-lang.org/issues/15832

https://github.com/ruby/ipaddr/commit/de9805d6fa
2021-10-07 18:22:42 +09:00
Jeremy Evans 54ee22be53
[ruby/ipaddr] Avoid reraising exceptions
Instead of raising a new exception with a modified message, just
use the correct message to begin with.  This avoids the issue with
both exceptions being displayed at error exit.

https://github.com/ruby/ipaddr/commit/09edfd4a7f
2021-10-07 18:22:42 +09:00
Espartaco Palma b23fba91ae [ruby/ipaddr] Removing superfluos assingments & return
Also adding test for ntop

https://github.com/ruby/ipaddr/commit/0ba16cca10
2021-10-07 17:46:00 +09:00
knu ab364fb5a8 Import ipaddr 1.2.2
- Enable frozen_string_literal and do a bit of code cleanup


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-18 05:09:08 +00:00
knu 236e2993ef Include the input in the message when raising InvalidAddressError
[Feature #5987]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-09 08:40:54 +00:00
shyouhei f2a91397fd Add uplevel keyword to Kernel#warn and use it
If uplevel keyword is given, the warning message is prepended
with caller file and line information and the string "warning: ".
The use of the uplevel keyword makes Kernel#warn format output
similar to how rb_warn formats output.

This patch modifies net/ftp and net/imap to use Kernel#warn
instead of $stderr.puts or $stderr.printf, since they are used
for printing warnings.

This makes lib/cgi/core and tempfile use $stderr.puts instead of
warn for debug logging, since they are used for debug printing
and not for warning.

This does not modify bundler, rubygems, or rdoc, as those are
maintained outside of ruby and probably wish to remain backwards
compatible with older ruby versions.

rb_warn_m code is originally from nobu, but I've changed it
so that it only includes the path and lineno from uplevel
(not the method), and also prepends the string "warning: ",
to make it more similar to rb_warn.

From: Jeremy Evans code@jeremyevans.net
Signed-off-by: Urabe Shyouhei shyouhei@ruby-lang.org


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:56:25 +00:00
kazu dabdec31e4 Use caller with length to reduce unused strings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:40:03 +00:00
knu c2db917b3d 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
2017-10-21 13:34:19 +00:00
knu 2d8841791f IPAddr#== and IPAddr#<=> no longer raise an exception if coercion fails
* lib/ipaddr.rb (IPAddr#==): If coercion fails, return false
  instead of passing through the exception. [ruby-core:77451]
  [Bug #12799]

* lib/ipaddr.rb (IPAddr#<=>): If coercion fails, return nil
  instead of passing through the exception. [ruby-core:77451]
  [Bug #12799]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 13:53:38 +00:00
nobu 4458026d85 ipaddr: fix typo [ci skip]
* lib/ipaddr.rb: [DOC] fix documentation of IN6MASK to mention
  IPv6.  [Fix GH-1349]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21 02:18:44 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
hsbt 2cd1f852e1 * lib/ipaddr.rb, test/test_ipaddr.rb: Reject invalid address contained
EOL string. Patch by @kachick [fix GH-942][Bug #11513]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 07:35:14 +00:00
hsbt f84ef81dad * lib/ipaddr.rb: extracted inline tests into test dir.
* test/test_ipaddr.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-31 07:36:51 +00:00
knu a16c76f7c5 * lib/ipaddr.rb (IPAddr#in6_addr): Fix a typo with the closing
parenthesis.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-18 07:31:17 +00:00
knu 7d63004fce Fix the IPv6 parser.
* lib/ipaddr.rb (IPAddr#in6_addr): Fix the parser so that it can
  recognize IPv6 addresses with only one edge 16-bit piece
  compressed, like [::2:3:4:5:6:7:8] or [1:2:3:4:5:6:7::].
  [Bug #7477]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-18 03:45:21 +00:00
marcandre 6f64d9eb56 * lib/cgi/core.rb: Use symbols instead of strings for
{const_,instance_variable_}{get,set}. [#7161]

* lib/drb/drb.rb: ditto.

* lib/ipaddr.rb: ditto.

* lib/irb/workspace.rb: ditto.

* lib/monitor.rb: ditto.

* lib/rss/maker/base.rb: ditto.

* lib/rss/rss.rb: ditto.

* lib/xmlrpc/parser.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-16 16:55:29 +00:00
knu e03d266c1d * lib/ipaddr.rb: Introduce several new error classes where only
ArgumentError and StandardError were used.  IPAddr::Error is
  their common ancestor class that inherits from ArgumentError for
  backward compatibility.  Submitted by Jon Daniel.  Fixes #173 on
  GitHub.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-31 07:30:22 +00:00
nobu d059d718b5 remove trainling spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-21 04:50:18 +00:00
knu 866761d2e8 * lib/ipaddr.rb: Inhibit zero-filled octets in an IPv4 address in
all platforms. [ruby-dev:45671]

* lib/ipaddr.rb: Allow the xxxd.d.d.d form not limited to
  IPv4 mapped/compatible addresses.  This change also makes it
  possible for the parser to understand IPv4 mapped and compatible
  IPv6 addresses in non-compressed form.

* lib/ipaddr.rb: Stop exposing IPSocket.valid*? methods which were
  only usable on non-IPv6-ready platforms.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-02 09:18:32 +00:00
drbrain 95e1fc5b4e * lib/ipaddr.rb: Improve documentation. Patch by Sandor Szucs.
[Ruby 1.9 - Bug #4753]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-22 02:21:56 +00:00
nobu d371e3583e * lib: revert r31635-r31638 and untabify with expand(1).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-19 00:07:25 +00:00
drbrain 7bbf2f3085 * lib: Convert tabs to spaces for ruby files per
http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style
	  Patch by Steve Klabnik [Ruby 1.9 - Bug #4730]
	  Patch by Jason Dew [Ruby 1.9 - Feature #4718]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-18 21:19:18 +00:00
drbrain f347a9212e * lib/ipaddr.rb (unless Socket): Document valid*? methods. Patch by
Sebastian Martinez.  [Ruby 1.9 - Feature #4687]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-13 17:59:35 +00:00
akr 66390013a1 * lib/resolv-replace.rb: specify super class for rdoc.
* lib/ipaddr.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-21 12:10:53 +00:00
nobu c9dd4823d9 * lib: fixed typo. a patch by Sho Hashimoto in [ruby-dev:40716].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-20 03:30:59 +00:00