internetdata 2.9.1 → 2.10.0

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +146 -9
  3. data/lib/internetdata/api/database_v2_api.rb +2 -2
  4. data/lib/internetdata/api_client.rb +2 -2
  5. data/lib/internetdata/api_error.rb +2 -2
  6. data/lib/internetdata/api_model_base.rb +2 -2
  7. data/lib/internetdata/asn_result.rb +107 -0
  8. data/lib/internetdata/bogon.rb +87 -0
  9. data/lib/internetdata/bogons.rb +93 -0
  10. data/lib/internetdata/cache.rb +35 -0
  11. data/lib/internetdata/client.rb +388 -16
  12. data/lib/internetdata/configuration.rb +23 -2
  13. data/lib/internetdata/domain_result.rb +124 -0
  14. data/lib/internetdata/errors.rb +29 -6
  15. data/lib/internetdata/models/abuse_contact.rb +236 -0
  16. data/lib/internetdata/models/asn.rb +294 -0
  17. data/lib/internetdata/models/asn_lookup_response.rb +405 -0
  18. data/lib/internetdata/models/asn_prefix.rb +329 -0
  19. data/lib/internetdata/models/batch_lookup_error.rb +192 -0
  20. data/lib/internetdata/models/bit_torrent_detail.rb +410 -0
  21. data/lib/internetdata/models/carrier_detail.rb +273 -0
  22. data/lib/internetdata/models/class_detail.rb +246 -0
  23. data/lib/internetdata/models/client_registration.rb +2 -2
  24. data/lib/internetdata/models/company.rb +213 -0
  25. data/lib/internetdata/models/database.rb +2 -2
  26. data/lib/internetdata/models/database_checksums_response.rb +2 -2
  27. data/lib/internetdata/models/database_format.rb +2 -2
  28. data/lib/internetdata/models/database_list.rb +2 -2
  29. data/lib/internetdata/models/database_metadata.rb +2 -2
  30. data/lib/internetdata/models/database_metadata_column.rb +2 -2
  31. data/lib/internetdata/models/database_version.rb +2 -2
  32. data/lib/internetdata/models/db_checksums.rb +2 -2
  33. data/lib/internetdata/models/device_authorization.rb +2 -2
  34. data/lib/internetdata/models/disposable_detail.rb +248 -0
  35. data/lib/internetdata/models/dns_address_record.rb +192 -0
  36. data/lib/internetdata/models/dns_cname_record.rb +192 -0
  37. data/lib/internetdata/models/dns_mx_record.rb +219 -0
  38. data/lib/internetdata/models/dns_ns_record.rb +192 -0
  39. data/lib/internetdata/models/dns_resolver_detail.rb +300 -0
  40. data/lib/internetdata/models/domain_dns.rb +279 -0
  41. data/lib/internetdata/models/domain_ip_range.rb +219 -0
  42. data/lib/internetdata/models/domain_ip_ranges.rb +276 -0
  43. data/lib/internetdata/models/domain_lookup_response.rb +376 -0
  44. data/lib/internetdata/models/download.rb +2 -2
  45. data/lib/internetdata/models/download_list.rb +2 -2
  46. data/lib/internetdata/models/entitlement.rb +243 -0
  47. data/lib/internetdata/models/entitlement_apikey.rb +207 -0
  48. data/lib/internetdata/models/entitlement_plan.rb +216 -0
  49. data/lib/internetdata/models/entitlement_usage.rb +259 -0
  50. data/lib/internetdata/models/error_envelope.rb +2 -2
  51. data/lib/internetdata/models/hosted_domains.rb +166 -0
  52. data/lib/internetdata/models/location.rb +509 -0
  53. data/lib/internetdata/models/lookup_response.rb +897 -0
  54. data/lib/internetdata/models/oauth_metadata.rb +2 -2
  55. data/lib/internetdata/models/proxy_detail.rb +327 -0
  56. data/lib/internetdata/models/pubproxy_detail.rb +329 -0
  57. data/lib/internetdata/models/rwhois.rb +301 -0
  58. data/lib/internetdata/models/satellite_detail.rb +327 -0
  59. data/lib/internetdata/models/smtp_detail.rb +273 -0
  60. data/lib/internetdata/models/ssh_detail.rb +300 -0
  61. data/lib/internetdata/models/standing.rb +2 -2
  62. data/lib/internetdata/models/token_response.rb +2 -2
  63. data/lib/internetdata/models/web_detail.rb +516 -0
  64. data/lib/internetdata/models/whois.rb +382 -0
  65. data/lib/internetdata/oauth_api.rb +12 -5
  66. data/lib/internetdata/result.rb +431 -0
  67. data/lib/internetdata/transport.rb +215 -27
  68. data/lib/internetdata/version.rb +1 -1
  69. data/lib/internetdata.rb +17 -2
  70. metadata +58 -3
@@ -0,0 +1,431 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InternetData
4
+ # What every lookup answer shares: the response exactly as it came off the
5
+ # wire, and whether your plan carries a member at all.
6
+ module Answer
7
+ # The response exactly as it came off the wire, with its original names.
8
+ # Frozen, because the cache hands this same object to every later caller of
9
+ # the address.
10
+ attr_reader :raw
11
+
12
+ def initialize(raw)
13
+ @raw = deep_freeze(raw)
14
+ freeze
15
+ end
16
+
17
+ # Whether your plan includes a member at all, told apart from a member your
18
+ # plan includes that answered false.
19
+ #
20
+ # result.included?(:is_vpn) # => false, not in your plan
21
+ # result.is_vpn # => nil
22
+ def included?(field)
23
+ @raw.key?(field.to_s)
24
+ end
25
+
26
+ def to_h
27
+ @raw
28
+ end
29
+
30
+ def ==(other)
31
+ other.is_a?(self.class) && other.raw == @raw
32
+ end
33
+ alias eql? ==
34
+
35
+ def hash
36
+ [self.class, @raw].hash
37
+ end
38
+
39
+ private
40
+
41
+ def deep_freeze(value)
42
+ case value
43
+ when Hash then value.each { |_, v| deep_freeze(v) }.freeze
44
+ when Array then value.each { |v| deep_freeze(v) }.freeze
45
+ else value.freeze
46
+ end
47
+ end
48
+ end
49
+
50
+ # What a lookup of an address answers.
51
+ #
52
+ # An **absent** member is one your plan does not include. It never means "we
53
+ # could not check", so `nil` and `false` are genuinely different answers: `nil`
54
+ # is "not in your plan", `false` is "checked, and no".
55
+ #
56
+ # Ruby makes that easy to lose, because `nil` and `false` are both falsy. Read
57
+ # the field itself (`is_vpn`) when the difference matters, ask {#included?}
58
+ # when you need to know whether your plan carries it at all, and use the
59
+ # predicate (`vpn?`) when you only care whether the address is flagged. A
60
+ # predicate always answers `true` or `false`, never `nil`.
61
+ #
62
+ # A detail object that is present but empty (`{}`, or Web IP's `[]`) means the
63
+ # flag above it is false. A populated one always carries every one of its keys.
64
+ # Details and objects are the wire hashes with their original string keys, so
65
+ # `result.vpn['provider']`, and the same holds inside them: a member a plan
66
+ # leaves out of an object, such as `location['city']`, is absent, never empty.
67
+ class Result
68
+ include Answer
69
+
70
+ FLAGS = %w[
71
+ is_vpn is_tor is_relay is_resproxy is_dcproxy is_mobproxy is_pubproxy is_hosting is_cdn is_anycast
72
+ is_carrier is_satellite is_ssh is_smtp is_web is_dns_resolver is_bittorrent
73
+ ].freeze
74
+
75
+ # The detail object behind each flag that has one; `is_anycast` has none.
76
+ DETAILS = %w[
77
+ vpn tor relay resproxy dcproxy mobproxy pubproxy hosting cdn carrier satellite ssh smtp dns_resolver
78
+ bittorrent
79
+ ].freeze
80
+
81
+ # The details that are a list of rows rather than one object.
82
+ DETAIL_LISTS = %w[web].freeze
83
+
84
+ # The address that was looked up, normalized: `::ffff:a.b.c.d` answers as
85
+ # `a.b.c.d`.
86
+ def ip
87
+ @raw['ip']
88
+ end
89
+
90
+ # Whether the address is reserved space, answered from the address alone.
91
+ # Every answer. A bogon never reaches the network: this library answers it.
92
+ def is_bogon
93
+ @raw['is_bogon']
94
+ end
95
+
96
+ # `is_bogon` with an absent member read as false.
97
+ def bogon?
98
+ @raw['is_bogon'] == true
99
+ end
100
+
101
+ # Whether the address is a VPN service's server (VPN IP), or nil when your
102
+ # plan does not include it. Paid plans and the trial.
103
+ def is_vpn
104
+ @raw['is_vpn']
105
+ end
106
+
107
+ # `is_vpn` with an absent member read as false.
108
+ def vpn?
109
+ @raw['is_vpn'] == true
110
+ end
111
+
112
+ # Whether the address is a Tor exit (Tor IP). Every answer.
113
+ def is_tor
114
+ @raw['is_tor']
115
+ end
116
+
117
+ # `is_tor` with an absent member read as false.
118
+ def tor?
119
+ @raw['is_tor'] == true
120
+ end
121
+
122
+ # Whether the address is an anonymizing relay such as iCloud Private Relay
123
+ # (Relay IP). Every answer.
124
+ def is_relay
125
+ @raw['is_relay']
126
+ end
127
+
128
+ # `is_relay` with an absent member read as false.
129
+ def relay?
130
+ @raw['is_relay'] == true
131
+ end
132
+
133
+ # Whether the address is a residential proxy exit in Residential Proxy IP's
134
+ # 90-day window, or nil when your plan does not include it. Paid plans and
135
+ # the trial.
136
+ def is_resproxy
137
+ @raw['is_resproxy']
138
+ end
139
+
140
+ # `is_resproxy` with an absent member read as false.
141
+ def resproxy?
142
+ @raw['is_resproxy'] == true
143
+ end
144
+
145
+ # Whether the address is in Datacenter Proxy IP's 90-day window, or nil when
146
+ # your plan does not include it. Paid plans and the trial.
147
+ def is_dcproxy
148
+ @raw['is_dcproxy']
149
+ end
150
+
151
+ # `is_dcproxy` with an absent member read as false.
152
+ def dcproxy?
153
+ @raw['is_dcproxy'] == true
154
+ end
155
+
156
+ # Whether the address is in Mobile Proxy IP's 90-day window, or nil when your
157
+ # plan does not include it. Paid plans and the trial.
158
+ def is_mobproxy
159
+ @raw['is_mobproxy']
160
+ end
161
+
162
+ # `is_mobproxy` with an absent member read as false.
163
+ def mobproxy?
164
+ @raw['is_mobproxy'] == true
165
+ end
166
+
167
+ # Whether a public proxy listens on the address or its traffic left from it
168
+ # (Public Proxy IP), or nil when your plan does not include it. Paid plans
169
+ # and the trial.
170
+ def is_pubproxy
171
+ @raw['is_pubproxy']
172
+ end
173
+
174
+ # `is_pubproxy` with an absent member read as false.
175
+ def pubproxy?
176
+ @raw['is_pubproxy'] == true
177
+ end
178
+
179
+ # Whether the address is on a hosting or cloud network (Hosting IP), or nil
180
+ # when your plan does not include it. Paid plans and the trial.
181
+ def is_hosting
182
+ @raw['is_hosting']
183
+ end
184
+
185
+ # `is_hosting` with an absent member read as false.
186
+ def hosting?
187
+ @raw['is_hosting'] == true
188
+ end
189
+
190
+ # Whether the address is on a content delivery network (CDN IP), or nil when
191
+ # your plan does not include it. Paid plans and the trial.
192
+ def is_cdn
193
+ @raw['is_cdn']
194
+ end
195
+
196
+ # `is_cdn` with an absent member read as false.
197
+ def cdn?
198
+ @raw['is_cdn'] == true
199
+ end
200
+
201
+ # Whether the address is announced from many places at once (Anycast IP).
202
+ # Every answer.
203
+ def is_anycast
204
+ @raw['is_anycast']
205
+ end
206
+
207
+ # `is_anycast` with an absent member read as false.
208
+ def anycast?
209
+ @raw['is_anycast'] == true
210
+ end
211
+
212
+ # Whether the address is in a mobile carrier's address space (Carrier IP).
213
+ # Every answer.
214
+ def is_carrier
215
+ @raw['is_carrier']
216
+ end
217
+
218
+ # `is_carrier` with an absent member read as false.
219
+ def carrier?
220
+ @raw['is_carrier'] == true
221
+ end
222
+
223
+ # Whether the address is in a satellite operator's address space (Satellite
224
+ # IP). Every answer.
225
+ def is_satellite
226
+ @raw['is_satellite']
227
+ end
228
+
229
+ # `is_satellite` with an absent member read as false.
230
+ def satellite?
231
+ @raw['is_satellite'] == true
232
+ end
233
+
234
+ # Whether an SSH server answered on the address (SSH IP). Every answer.
235
+ def is_ssh
236
+ @raw['is_ssh']
237
+ end
238
+
239
+ # `is_ssh` with an absent member read as false.
240
+ def ssh?
241
+ @raw['is_ssh'] == true
242
+ end
243
+
244
+ # Whether a mail server answered on the address (SMTP IP). Every answer.
245
+ def is_smtp
246
+ @raw['is_smtp']
247
+ end
248
+
249
+ # `is_smtp` with an absent member read as false.
250
+ def smtp?
251
+ @raw['is_smtp'] == true
252
+ end
253
+
254
+ # Whether a web server answered on the address on port 80 or 443 (Web IP).
255
+ # Every answer.
256
+ def is_web
257
+ @raw['is_web']
258
+ end
259
+
260
+ # `is_web` with an absent member read as false.
261
+ def web?
262
+ @raw['is_web'] == true
263
+ end
264
+
265
+ # Whether an open DNS resolver answered on the address (DNS Resolver IP).
266
+ # Every answer.
267
+ def is_dns_resolver
268
+ @raw['is_dns_resolver']
269
+ end
270
+
271
+ # `is_dns_resolver` with an absent member read as false.
272
+ def dns_resolver?
273
+ @raw['is_dns_resolver'] == true
274
+ end
275
+
276
+ # Whether a BitTorrent client was seen on the address in the last 90 days
277
+ # (BitTorrent IP). Every answer.
278
+ def is_bittorrent
279
+ @raw['is_bittorrent']
280
+ end
281
+
282
+ # `is_bittorrent` with an absent member read as false.
283
+ def bittorrent?
284
+ @raw['is_bittorrent'] == true
285
+ end
286
+
287
+ # VPN IP's row for the address. Paid plans and the trial.
288
+ def vpn
289
+ @raw['vpn']
290
+ end
291
+
292
+ # Tor IP's row. Every answer.
293
+ def tor
294
+ @raw['tor']
295
+ end
296
+
297
+ # Relay IP's row. Every answer.
298
+ def relay
299
+ @raw['relay']
300
+ end
301
+
302
+ # Detail for `is_resproxy`. Paid plans and the trial.
303
+ def resproxy
304
+ @raw['resproxy']
305
+ end
306
+
307
+ # Detail for `is_dcproxy`. Paid plans and the trial.
308
+ def dcproxy
309
+ @raw['dcproxy']
310
+ end
311
+
312
+ # Detail for `is_mobproxy`. Paid plans and the trial.
313
+ def mobproxy
314
+ @raw['mobproxy']
315
+ end
316
+
317
+ # Detail for `is_pubproxy`. Paid plans and the trial.
318
+ def pubproxy
319
+ @raw['pubproxy']
320
+ end
321
+
322
+ # Detail for `is_hosting`. Paid plans and the trial.
323
+ def hosting
324
+ @raw['hosting']
325
+ end
326
+
327
+ # Detail for `is_cdn`. Paid plans and the trial.
328
+ def cdn
329
+ @raw['cdn']
330
+ end
331
+
332
+ # Detail for `is_carrier`. Paid plans and the trial.
333
+ def carrier
334
+ @raw['carrier']
335
+ end
336
+
337
+ # Detail for `is_satellite`. Paid plans and the trial.
338
+ def satellite
339
+ @raw['satellite']
340
+ end
341
+
342
+ # Detail for `is_ssh`. Paid plans and the trial.
343
+ def ssh
344
+ @raw['ssh']
345
+ end
346
+
347
+ # Detail for `is_smtp`. Paid plans and the trial.
348
+ def smtp
349
+ @raw['smtp']
350
+ end
351
+
352
+ # Detail for `is_web`: a row per port that answered, lowest first. Paid plans
353
+ # and the trial.
354
+ def web
355
+ @raw['web']
356
+ end
357
+
358
+ # Detail for `is_dns_resolver`. Paid plans and the trial.
359
+ def dns_resolver
360
+ @raw['dns_resolver']
361
+ end
362
+
363
+ # Detail for `is_bittorrent`. Paid plans and the trial.
364
+ def bittorrent
365
+ @raw['bittorrent']
366
+ end
367
+
368
+ # Where the address is, as a wire hash (`result.location['country']`).
369
+ # Every answer; the city and finer members on paid plans and the trial.
370
+ def location
371
+ @raw['location']
372
+ end
373
+
374
+ # The network announcing the address, from IP ASN, as a wire hash
375
+ # (`result.asn['name']`), with asn 0 where none does. Every answer.
376
+ def asn
377
+ @raw['asn']
378
+ end
379
+
380
+ # Who uses the address, from IP Company. Every answer.
381
+ def company
382
+ @raw['company']
383
+ end
384
+
385
+ # The name the address's reverse DNS (PTR) record points to in IP RDNS,
386
+ # empty when it has none. Every answer.
387
+ def hostname
388
+ @raw['hostname']
389
+ end
390
+
391
+ # Where to report abuse, from IP Abuse Contact. Every answer; the contact's
392
+ # name, phone and the rest on paid plans and the trial.
393
+ def abuse
394
+ @raw['abuse']
395
+ end
396
+
397
+ # IP Whois's most specific record covering the address. Paid plans and the
398
+ # trial.
399
+ def whois
400
+ @raw['whois']
401
+ end
402
+
403
+ # IP RWHOIS's most specific network covering the address. Paid plans and
404
+ # the trial.
405
+ def rwhois
406
+ @raw['rwhois']
407
+ end
408
+
409
+ # How many domains IP Hosted Domains finds on the address, as
410
+ # `{'total' => n}`: a count, never the list. Paid plans and the trial.
411
+ def hosted_domains
412
+ @raw['hosted_domains']
413
+ end
414
+
415
+ # On answers to a key on the free plan only: false while its organization's
416
+ # daily trial lasts (every field for the first 100 lookups each UTC day),
417
+ # true once the answer has Unlimited's; nil on any other answer.
418
+ def trial_expired
419
+ @raw['trial_expired']
420
+ end
421
+
422
+ # `trial_expired` with an absent member read as false.
423
+ def trial_expired?
424
+ @raw['trial_expired'] == true
425
+ end
426
+
427
+ def inspect
428
+ "#<#{self.class} ip=#{ip.inspect} is_bogon=#{is_bogon.inspect} is_vpn=#{is_vpn.inspect}>"
429
+ end
430
+ end
431
+ end