whois 4.0.6 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +12 -0
  3. data/.github/dependabot.yml +17 -0
  4. data/.github/workflows/release.yml +19 -0
  5. data/.github/workflows/tests.yml +29 -0
  6. data/.gitignore +11 -0
  7. data/.rspec +1 -0
  8. data/.rubocop.yml +27 -0
  9. data/.rubocop_opinionated.yml +115 -0
  10. data/.rubocop_todo.yml +89 -0
  11. data/.simplecov +6 -0
  12. data/.tool-versions +1 -0
  13. data/CHANGELOG.md +147 -44
  14. data/CONTRIBUTING.md +18 -6
  15. data/Gemfile +8 -0
  16. data/LICENSE.txt +1 -1
  17. data/README.md +4 -4
  18. data/Rakefile +28 -0
  19. data/SECURITY.md +24 -0
  20. data/bin/console +1 -0
  21. data/bin/whoisrb +6 -5
  22. data/data/ipv4.json +1 -3
  23. data/data/tld.json +125 -1049
  24. data/lib/whois/client.rb +5 -7
  25. data/lib/whois/errors.rb +4 -6
  26. data/lib/whois/record/part.rb +5 -6
  27. data/lib/whois/record.rb +5 -8
  28. data/lib/whois/server/adapters/afilias.rb +4 -5
  29. data/lib/whois/server/adapters/arin.rb +7 -8
  30. data/lib/whois/server/adapters/arpa.rb +19 -24
  31. data/lib/whois/server/adapters/base.rb +29 -46
  32. data/lib/whois/server/adapters/formatted.rb +4 -6
  33. data/lib/whois/server/adapters/none.rb +4 -6
  34. data/lib/whois/server/adapters/not_implemented.rb +4 -6
  35. data/lib/whois/server/adapters/standard.rb +4 -6
  36. data/lib/whois/server/adapters/verisign.rb +4 -5
  37. data/lib/whois/server/adapters/web.rb +4 -6
  38. data/lib/whois/server/socket_handler.rb +11 -12
  39. data/lib/whois/server.rb +73 -64
  40. data/lib/whois/version.rb +4 -2
  41. data/lib/whois.rb +32 -33
  42. data/spec/fixtures/referrals/afilias.bz.txt +23 -0
  43. data/spec/fixtures/referrals/arin_referral_apnic.txt +78 -0
  44. data/spec/fixtures/referrals/arin_referral_missing.txt +52 -0
  45. data/spec/fixtures/referrals/arin_referral_ripe.txt +50 -0
  46. data/spec/fixtures/referrals/arin_referral_rwhois.txt +63 -0
  47. data/spec/fixtures/referrals/arin_referral_servernap.txt +63 -0
  48. data/spec/fixtures/referrals/arin_referral_whois.txt +56 -0
  49. data/spec/fixtures/referrals/crsnic.com.txt +60 -0
  50. data/spec/fixtures/referrals/crsnic.com_referral.txt +56 -0
  51. data/spec/fixtures/referrals/crsnic.com_referral_missing.txt +50 -0
  52. data/spec/integration/whois_spec.rb +73 -0
  53. data/spec/spec_helper.rb +19 -0
  54. data/spec/support/helpers/connectivity_helper.rb +15 -0
  55. data/spec/support/helpers/spec_helper.rb +31 -0
  56. data/spec/whois/client_spec.rb +143 -0
  57. data/spec/whois/record/part_spec.rb +38 -0
  58. data/spec/whois/record_spec.rb +168 -0
  59. data/spec/whois/server/adapters/afilias_spec.rb +49 -0
  60. data/spec/whois/server/adapters/arin_spec.rb +83 -0
  61. data/spec/whois/server/adapters/arpa_spec.rb +29 -0
  62. data/spec/whois/server/adapters/base_spec.rb +155 -0
  63. data/spec/whois/server/adapters/formatted_spec.rb +53 -0
  64. data/spec/whois/server/adapters/none_spec.rb +23 -0
  65. data/spec/whois/server/adapters/not_implemented_spec.rb +24 -0
  66. data/spec/whois/server/adapters/standard_spec.rb +42 -0
  67. data/spec/whois/server/adapters/verisign_spec.rb +60 -0
  68. data/spec/whois/server/adapters/web_spec.rb +24 -0
  69. data/spec/whois/server/socket_handler_spec.rb +33 -0
  70. data/spec/whois/server_spec.rb +302 -0
  71. data/spec/whois/web_interface_error_spec.rb +23 -0
  72. data/spec/whois/whois_spec.rb +15 -0
  73. data/utils/compare-whois.rb +30 -0
  74. data/utils/deftld.rb +230 -0
  75. data/utils/defutils.rb +26 -0
  76. data/utils/fixupd.rb +60 -0
  77. data/utils/matrix.rb +68 -0
  78. data/utils/mkwhois.rb +31 -0
  79. data/whois.gemspec +19 -32
  80. metadata +58 -11
  81. data/4.0-Upgrade.md +0 -143
  82. data/bin/setup +0 -8
data/4.0-Upgrade.md DELETED
@@ -1,143 +0,0 @@
1
- # Welcome to Whois 4.0!
2
-
3
- Whois 4 is a major upgrade compared to Whois 3. This library is now 7 years old, enough mature to offer pretty much all the features you need to perform WHOIS queries.
4
-
5
- In these last 7 years the adoption of this library has grown beyond any expectation. Most of the time was spent updating the definitions to stay up to date with the various registrar changes (thanks ICANN for thew newGLTDs...), updating the registry parsers and polishing up the public interface.
6
-
7
- For Whois 4 I decided to take a step back, and rewrite some of the internal components of this library to improve performance and readability. As a result of these changes, there are several compatibility breaks with Whois 4 that I'm going to document here.
8
-
9
- -- Simone
10
-
11
- ## What's New
12
-
13
- - The Whois client and the Whois parser are now two separate repositories, and they are also distributed as two separate gems:
14
-
15
- - https://github.com/weppos/whois - https://rubygems.org/gems/whois
16
- - https://github.com/weppos/whois-parser https://rubygems.org/gems/whois-parser
17
-
18
- There are several reasons behind this change (see [weppos/whois#503](https://github.com/weppos/whois/pull/503)).
19
-
20
- First of all, the maintenance of the whois-parser component is the most time consuming task. Updating a parser may require from a few minutes to several hours, depending on how big are the changes. It also requires to generate the appropriate fixtures, and write the necessary tests. In the last years I noticed that more than once client updates were delayed because of pending parser changes. Separating the repositories and the release cycles will likely speedup future released of the client gem.
21
-
22
- Moreover, the parser component takes a lot of space (due to all the files and fixtures). If you just need a Ruby whois client, loading the entire parser component is inefficient and a waste of time/CPU/resources.
23
-
24
- Last but not least, in the last years the Whois client inspired several ports in different languages. Most of these ports were not interested in porting the parser as well. However, the parser was so tightly coupled with the client that it made the client code harder to read.
25
-
26
- - The definition files have been largely redesigned, in particular the TLD file. The definitions are now maintained using a set of CLI tools. The goal is to eventually extract the definition files into a separate, standalone repository that other WHOIS libraries can easily fetch.
27
-
28
- ## Upgrade
29
-
30
- When upgrading, here's the most relevant changes to keep an eye on:
31
-
32
- - If you are using the Whois parser, install and require the `whois-parser` gem. The parser will automatically download the appropriate `whois` dependency.
33
-
34
- ```ruby
35
- require 'whois-parser'
36
- ```
37
-
38
- If you only need the client and you don't care about the parser, simply continue to require the `whois` gem directly.
39
-
40
- ```ruby
41
- require 'whois'
42
- ```
43
-
44
- - `Whois::Server.definitions` no longer return the internal definitions. Definitions are no longer accessible directly, because their internal representation may change at any time. If you need to modify the definitions, use the public API.
45
-
46
- ```ruby
47
- Whois::Server.define(Whois::Server::TYPE_TLD, ...)
48
- ```
49
-
50
- You can still use `Whois::Server.definitions`, but it will return a copy of the internal definitions, and you have to specify which type of definitions you want to access.
51
-
52
- ```ruby
53
- Whois::Server.definitions(Whois::Server::TYPE_TLD)
54
- ```
55
-
56
- - **The parser methods are no longer accessible directly within the response object.**
57
-
58
- This is probably one of the most important changes, and it is explained in details at [weppos/whois-parser#5](https://github.com/weppos/whois-parser/pull/5).
59
-
60
- In Whois 3, you can invoke a property method on a record object and the record will automatically route the method call to the underlying parser. If the property is not supported or defined in any of the parsers, then the method will return nil.
61
-
62
- However, this behavior is often the cause of confusion and misunderstandings, especially for partially implemented parsers. Without to mention that the code required for this feature to work added an extra layer of complexity to the `Whois::Record` implementation.
63
-
64
- Starting from Whois 4, the `Whois::Record` doesn't expose any parsing methods anymore. If you want to parse a record, you have to istantiate a parser manually. Of course, you also need to use the `whois-parser` library instead of `whois`.
65
-
66
- Whois 3:
67
-
68
- ```ruby
69
- require 'whois-parser'
70
-
71
- record = Whois.whois("example.it")
72
- record.expires_on
73
- ```
74
-
75
- Whois 4:
76
-
77
- ```ruby
78
- require 'whois-parser'
79
-
80
- record = Whois.whois("example.it")
81
- parser = Whois::Parser.new(record)
82
- parser.expires_on
83
- ```
84
-
85
- You can still use the convenient helper `record.parser` to initialize a parser:
86
-
87
- ```ruby
88
- require 'whois-parser'
89
-
90
- record = Whois.whois("example.it")
91
- record.parser.expires_on
92
- ```
93
-
94
- Also note that any parser method, such as `parser.expires_on`, will raise an error if the property is not implemented, as opposite to silently returning `nil` as it was in Whois 3.
95
-
96
- - **Parser extensions**
97
-
98
- The Parser features available in Whois 3 has been packaged into several extensions. Some of them are loaded by default in Whois 4 when you require `whois-parser`, others not anymore. The reason is because although some of them may appear convenient (because it makes you write more code), it turned out that they made some assumptions that were often source of confusion.
99
-
100
- Check the header of the [`whois/parser.rb`](https://github.com/weppos/whois-parser/blob/master/lib/whois/parser.rb) file to learn more about the purpose of each extension.
101
-
102
- Requiring **all** the extensions will essentially force Whois 4 to work pretty much like Whois 3. This is not recommended, and you should not rely on those extensions to be there forever. Instead, you should write the code depending on what you actually need.
103
-
104
- There is also an ENV variable you can set to rollback compatibility to Whois 3.
105
-
106
- ```ruby
107
- ENV["WHOISRB_4EXTENSIONS"] = 1
108
- ```
109
-
110
- Again, this flag exists only as temporary helper, and it should not become a permanent upgrade workaround.
111
-
112
- - **SafeRecord**
113
-
114
- In the previous point I mentioned that you should write the code you need to customize the `Whois::Record` and extract information with the `Whois::Parser`. However, I omitted an important additional recommendation: avoid monkey patching the Whois::Record object, and instead prefer composition via delegation.
115
-
116
- The SafeRecord is an example of a wrapper around a Record object, that expose a Whois 3 alike interface, without injecting the parser methods directly into the `Whois::Record` itself.
117
-
118
- The advantages are:
119
-
120
- - the code is more maintainable, as it is not tighlty coupled to the Whois::Record
121
- - you don't monkey patch `Whois::Record` in your code, which is an object you don't have control of because it is packaged in a third party library (and can change)
122
- - the library can easily be tested separately
123
-
124
- In these 10 years of writing Ruby code, I've noticed an increasing attitude to monkey patch Ruby classes you don't control, instead of writing your own code and delegate to them. It looks like in several cases Ruby programmers are afraid of writing Ruby code. This results in very fragile code, where methods can easily conflict each other (especially between dependencies).
125
-
126
- The `Whois::SafeRecord` is an alternative example of how you can restore Whois 3 behavior by using a custom object.
127
-
128
- ```ruby
129
- require 'whois/parser'
130
- require 'whois/safe_record'
131
-
132
- record = Whois.whois('example.com')
133
- record.disclaimer
134
- # => Whois::AttributeNotSupported
135
-
136
- safe_record = Whois::SafeRecord.new(record)
137
- safe_record.disclaimer
138
- # => nil
139
- ```
140
-
141
- This is preferred over requiring the `whois/parser_extensions` or enabling v3 compatibility mode.
142
-
143
- Please note that the parser extension is provided as example. It may be removed from future versions therefore, once again, you should write the code you need to access the parsed data.
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here