internetdata 2.17.0 → 2.19.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.
- checksums.yaml +4 -4
- data/README.md +20 -7
- data/lib/internetdata/api/database_v2_api.rb +1 -1
- data/lib/internetdata/api_client.rb +1 -1
- data/lib/internetdata/api_error.rb +1 -1
- data/lib/internetdata/api_model_base.rb +1 -1
- data/lib/internetdata/client.rb +77 -41
- data/lib/internetdata/configuration.rb +1 -1
- data/lib/internetdata/middleware/core.rb +61 -5
- data/lib/internetdata/models/abuse_contact.rb +8 -8
- data/lib/internetdata/models/asn.rb +2 -19
- data/lib/internetdata/models/asn_hosted_domains.rb +2 -2
- data/lib/internetdata/models/asn_lookup_response.rb +18 -18
- data/lib/internetdata/models/asn_prefix.rb +1 -1
- data/lib/internetdata/models/batch_lookup_error.rb +1 -1
- data/lib/internetdata/models/bit_torrent_detail.rb +1 -1
- data/lib/internetdata/models/bot_detail.rb +1 -1
- data/lib/internetdata/models/carrier_detail.rb +1 -1
- data/lib/internetdata/models/class_detail.rb +1 -1
- data/lib/internetdata/models/client_registration.rb +1 -1
- data/lib/internetdata/models/cohosted_domains.rb +2 -2
- data/lib/internetdata/models/company.rb +3 -3
- data/lib/internetdata/models/database.rb +1 -1
- data/lib/internetdata/models/database_checksums_response.rb +1 -1
- data/lib/internetdata/models/database_format.rb +1 -1
- data/lib/internetdata/models/database_list.rb +1 -1
- data/lib/internetdata/models/database_metadata.rb +1 -1
- data/lib/internetdata/models/database_metadata_column.rb +1 -1
- data/lib/internetdata/models/database_version.rb +1 -1
- data/lib/internetdata/models/db_checksums.rb +1 -1
- data/lib/internetdata/models/device_authorization.rb +1 -1
- data/lib/internetdata/models/disposable_detail.rb +1 -1
- data/lib/internetdata/models/dns_address_record.rb +1 -1
- data/lib/internetdata/models/dns_cname_record.rb +1 -1
- data/lib/internetdata/models/dns_mx_record.rb +1 -1
- data/lib/internetdata/models/dns_ns_record.rb +1 -1
- data/lib/internetdata/models/dns_resolver_detail.rb +1 -1
- data/lib/internetdata/models/domain_backlinks.rb +2 -2
- data/lib/internetdata/models/domain_dns.rb +2 -2
- data/lib/internetdata/models/domain_host.rb +1 -1
- data/lib/internetdata/models/domain_ip_range.rb +1 -1
- data/lib/internetdata/models/domain_ip_ranges.rb +2 -2
- data/lib/internetdata/models/domain_lookup_response.rb +4 -4
- data/lib/internetdata/models/domain_redirects.rb +2 -2
- data/lib/internetdata/models/domain_web.rb +2 -2
- data/lib/internetdata/models/domain_web_links.rb +1 -1
- data/lib/internetdata/models/download.rb +1 -1
- data/lib/internetdata/models/download_list.rb +1 -1
- data/lib/internetdata/models/entitlement.rb +1 -1
- data/lib/internetdata/models/entitlement_apikey.rb +1 -1
- data/lib/internetdata/models/entitlement_plan.rb +2 -2
- data/lib/internetdata/models/entitlement_usage.rb +3 -3
- data/lib/internetdata/models/error_envelope.rb +1 -1
- data/lib/internetdata/models/hosted_domains.rb +2 -2
- data/lib/internetdata/models/location.rb +11 -11
- data/lib/internetdata/models/lookup_response.rb +31 -167
- data/lib/internetdata/models/oauth_metadata.rb +1 -1
- data/lib/internetdata/models/proxy_detail.rb +1 -1
- data/lib/internetdata/models/pubproxy_detail.rb +1 -1
- data/lib/internetdata/models/rwhois.rb +2 -2
- data/lib/internetdata/models/satellite_detail.rb +1 -1
- data/lib/internetdata/models/smtp_detail.rb +1 -1
- data/lib/internetdata/models/ssh_detail.rb +1 -1
- data/lib/internetdata/models/standing.rb +1 -1
- data/lib/internetdata/models/token_response.rb +1 -1
- data/lib/internetdata/models/user_agent_verdict.rb +1 -1
- data/lib/internetdata/models/web_detail.rb +1 -1
- data/lib/internetdata/models/whois.rb +2 -2
- data/lib/internetdata/result.rb +30 -12
- data/lib/internetdata/transport.rb +45 -14
- data/lib/internetdata/version.rb +1 -1
- metadata +1 -1
data/lib/internetdata/result.rb
CHANGED
|
@@ -200,7 +200,8 @@ module InternetData
|
|
|
200
200
|
|
|
201
201
|
# Whether an automated client uses the address (Bot IP): a search engine's or
|
|
202
202
|
# an AI company's crawler, an uptime monitor, an internet scanner or a
|
|
203
|
-
# webhook sender
|
|
203
|
+
# webhook sender, or nil when your plan does not include it. Paid plans and
|
|
204
|
+
# the trial; `bot` says whose.
|
|
204
205
|
def is_bot
|
|
205
206
|
@raw['is_bot']
|
|
206
207
|
end
|
|
@@ -221,8 +222,8 @@ module InternetData
|
|
|
221
222
|
@raw['is_anycast'] == true
|
|
222
223
|
end
|
|
223
224
|
|
|
224
|
-
# Whether the address is in a mobile carrier's address space (Carrier IP)
|
|
225
|
-
#
|
|
225
|
+
# Whether the address is in a mobile carrier's address space (Carrier IP), or
|
|
226
|
+
# nil when your plan does not include it. Paid plans and the trial.
|
|
226
227
|
def is_carrier
|
|
227
228
|
@raw['is_carrier']
|
|
228
229
|
end
|
|
@@ -233,7 +234,7 @@ module InternetData
|
|
|
233
234
|
end
|
|
234
235
|
|
|
235
236
|
# Whether the address is in a satellite operator's address space (Satellite
|
|
236
|
-
# IP).
|
|
237
|
+
# IP), or nil when your plan does not include it. Paid plans and the trial.
|
|
237
238
|
def is_satellite
|
|
238
239
|
@raw['is_satellite']
|
|
239
240
|
end
|
|
@@ -243,7 +244,8 @@ module InternetData
|
|
|
243
244
|
@raw['is_satellite'] == true
|
|
244
245
|
end
|
|
245
246
|
|
|
246
|
-
# Whether an SSH server answered on the address (SSH IP)
|
|
247
|
+
# Whether an SSH server answered on the address (SSH IP), or nil when your
|
|
248
|
+
# plan does not include it. Paid plans and the trial.
|
|
247
249
|
def is_ssh
|
|
248
250
|
@raw['is_ssh']
|
|
249
251
|
end
|
|
@@ -253,7 +255,8 @@ module InternetData
|
|
|
253
255
|
@raw['is_ssh'] == true
|
|
254
256
|
end
|
|
255
257
|
|
|
256
|
-
# Whether a mail server answered on the address (SMTP IP)
|
|
258
|
+
# Whether a mail server answered on the address (SMTP IP), or nil when your
|
|
259
|
+
# plan does not include it. Paid plans and the trial.
|
|
257
260
|
def is_smtp
|
|
258
261
|
@raw['is_smtp']
|
|
259
262
|
end
|
|
@@ -263,8 +266,8 @@ module InternetData
|
|
|
263
266
|
@raw['is_smtp'] == true
|
|
264
267
|
end
|
|
265
268
|
|
|
266
|
-
# Whether a web server answered on the address on port 80 or 443 (Web IP)
|
|
267
|
-
#
|
|
269
|
+
# Whether a web server answered on the address on port 80 or 443 (Web IP), or
|
|
270
|
+
# nil when your plan does not include it. Paid plans and the trial.
|
|
268
271
|
def is_web
|
|
269
272
|
@raw['is_web']
|
|
270
273
|
end
|
|
@@ -274,8 +277,8 @@ module InternetData
|
|
|
274
277
|
@raw['is_web'] == true
|
|
275
278
|
end
|
|
276
279
|
|
|
277
|
-
# Whether an open DNS resolver answered on the address (DNS Resolver IP)
|
|
278
|
-
#
|
|
280
|
+
# Whether an open DNS resolver answered on the address (DNS Resolver IP), or
|
|
281
|
+
# nil when your plan does not include it. Paid plans and the trial.
|
|
279
282
|
def is_dns_resolver
|
|
280
283
|
@raw['is_dns_resolver']
|
|
281
284
|
end
|
|
@@ -286,7 +289,8 @@ module InternetData
|
|
|
286
289
|
end
|
|
287
290
|
|
|
288
291
|
# Whether a BitTorrent client was seen on the address in the last 90 days
|
|
289
|
-
# (BitTorrent IP).
|
|
292
|
+
# (BitTorrent IP), or nil when your plan does not include it. Paid plans and
|
|
293
|
+
# the trial.
|
|
290
294
|
def is_bittorrent
|
|
291
295
|
@raw['is_bittorrent']
|
|
292
296
|
end
|
|
@@ -392,7 +396,8 @@ module InternetData
|
|
|
392
396
|
end
|
|
393
397
|
|
|
394
398
|
# The network announcing the address, from IP ASN, as a wire hash
|
|
395
|
-
# (`result.asn['name']`), with asn 0 where none does. Every answer
|
|
399
|
+
# (`result.asn['name']`), with asn 0 where none does. Every answer; the
|
|
400
|
+
# network's type on paid plans and the trial.
|
|
396
401
|
def asn
|
|
397
402
|
@raw['asn']
|
|
398
403
|
end
|
|
@@ -433,6 +438,19 @@ module InternetData
|
|
|
433
438
|
@raw['hosted_domains']
|
|
434
439
|
end
|
|
435
440
|
|
|
441
|
+
# What the API made of the user agent the lookup sent, as a wire hash
|
|
442
|
+
# (`result.user_agent['verdict']`): agent, the agent it names (`Googlebot`,
|
|
443
|
+
# `Chrome`, `Unknown` where it names none); kind, what kind of client it says
|
|
444
|
+
# it is (`browser`, `bot`, `ai-bot` and the rest); and verdict, `verified`
|
|
445
|
+
# where the agent's operator vouches for this address, `spoofed` where it does
|
|
446
|
+
# not, `unverifiable` for a bot nothing published can confirm, or `not_bot`
|
|
447
|
+
# for a browser, an app or a script. Present only when the lookup sent an
|
|
448
|
+
# agent and the answer has every field (a paid plan, or the trial); nil on a
|
|
449
|
+
# bogon, which is answered locally.
|
|
450
|
+
def user_agent
|
|
451
|
+
@raw['user_agent']
|
|
452
|
+
end
|
|
453
|
+
|
|
436
454
|
# On answers to a key on the free plan only: false while its organization's
|
|
437
455
|
# trial of every field lasts, true once the answer has Unlimited's; nil on
|
|
438
456
|
# any other answer.
|
|
@@ -203,12 +203,16 @@ module InternetData
|
|
|
203
203
|
request
|
|
204
204
|
end
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
# `user_agent` goes as the query parameter only when there is one: nil or
|
|
207
|
+
# empty is none. Built here rather than by a generated client, whose
|
|
208
|
+
# `maxLength` check refuses an agent past the spec's 1024 characters that the
|
|
209
|
+
# API itself cuts there and answers.
|
|
210
|
+
def lookup_request(ip, timeout: nil, user_agent: nil)
|
|
211
|
+
lookup_get(LOOKUP_PATH.sub('{ip}', CGI.escape(ip.to_s)), timeout, user_agent: user_agent)
|
|
208
212
|
end
|
|
209
213
|
|
|
210
|
-
def myip_request(timeout: nil)
|
|
211
|
-
lookup_get(MYIP_PATH, timeout)
|
|
214
|
+
def myip_request(timeout: nil, user_agent: nil)
|
|
215
|
+
lookup_get(MYIP_PATH, timeout, user_agent: user_agent)
|
|
212
216
|
end
|
|
213
217
|
|
|
214
218
|
def asn_request(asn, timeout: nil)
|
|
@@ -223,17 +227,32 @@ module InternetData
|
|
|
223
227
|
lookup_get(ENTITLEMENT_PATH, timeout)
|
|
224
228
|
end
|
|
225
229
|
|
|
226
|
-
# The one request with a body: the batch.
|
|
227
|
-
|
|
230
|
+
# The one request with a body: the batch. `user_agents`, keyed by each
|
|
231
|
+
# address as it is in `ips`, is sent only when it holds an entry, never as
|
|
232
|
+
# `{}`: the spec types it an object, never null or empty.
|
|
233
|
+
def batch_request(ips, timeout: nil, user_agents: nil)
|
|
234
|
+
body = { ips: ips }
|
|
235
|
+
body[:user_agents] = user_agents unless user_agents.nil? || user_agents.empty?
|
|
228
236
|
build_request(
|
|
229
237
|
:POST, BATCH_PATH,
|
|
230
238
|
header_params: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' },
|
|
231
|
-
body:
|
|
239
|
+
body: body,
|
|
232
240
|
auth_names: LOOKUP_AUTH,
|
|
233
241
|
timeout: timeout,
|
|
234
242
|
)
|
|
235
243
|
end
|
|
236
244
|
|
|
245
|
+
# The agent a call sends: nil for none, which an empty one is, as the API
|
|
246
|
+
# reads `user_agent=`. Anything but a String or nil is refused, since its
|
|
247
|
+
# text would be sent as the agent. One past the spec's 1024 characters is
|
|
248
|
+
# sent as it is: the API cuts it there and answers.
|
|
249
|
+
def self.checked_user_agent(user_agent)
|
|
250
|
+
return nil if user_agent.nil?
|
|
251
|
+
raise ArgumentError, "user_agent must be a String, not #{user_agent.inspect}" unless user_agent.is_a?(String)
|
|
252
|
+
|
|
253
|
+
user_agent.empty? ? nil : user_agent
|
|
254
|
+
end
|
|
255
|
+
|
|
237
256
|
def self.entitlement_result(response)
|
|
238
257
|
body = answer(response)
|
|
239
258
|
begin
|
|
@@ -357,8 +376,7 @@ module InternetData
|
|
|
357
376
|
# is `{}` under a false flag. test/database_test.rb holds this to
|
|
358
377
|
# spec/openapi.yaml.
|
|
359
378
|
REQUIRED = {
|
|
360
|
-
'LookupResponse' => %i[ip is_bogon is_tor is_relay
|
|
361
|
-
is_smtp is_web is_dns_resolver is_bittorrent tor relay location asn company hostname
|
|
379
|
+
'LookupResponse' => %i[ip is_bogon is_tor is_relay is_anycast tor relay location asn company hostname
|
|
362
380
|
abuse],
|
|
363
381
|
'ClassDetail' => [],
|
|
364
382
|
'ProxyDetail' => [],
|
|
@@ -375,7 +393,7 @@ module InternetData
|
|
|
375
393
|
'UserAgentVerdict' => %i[agent kind verdict],
|
|
376
394
|
'Location' => %i[continent continent_name country country_name timezone currency_code currency_name
|
|
377
395
|
currency_symbol flag_emoji flag_unicode],
|
|
378
|
-
'Asn' => %i[asn name domain
|
|
396
|
+
'Asn' => %i[asn name domain prefix country rpki_status],
|
|
379
397
|
'Company' => %i[name domain],
|
|
380
398
|
'AbuseContact' => %i[email],
|
|
381
399
|
'Whois' => %i[id name org country status source domain abuse_email asn],
|
|
@@ -415,6 +433,15 @@ module InternetData
|
|
|
415
433
|
'Download' => %i[dataset_id format outcome sample open bytes http_status apikey_id client_ip user_agent created],
|
|
416
434
|
}.freeze
|
|
417
435
|
|
|
436
|
+
# The members the spec stopped requiring in 2026.11.26, because Unlimited's answer leaves
|
|
437
|
+
# them out: absent reads as absent, as any member a plan leaves out does. A served null
|
|
438
|
+
# is still refused, as it was while they were required.
|
|
439
|
+
NEVER_NULL = {
|
|
440
|
+
'LookupResponse' => %i[is_bot is_carrier is_satellite is_ssh is_smtp is_web is_dns_resolver
|
|
441
|
+
is_bittorrent],
|
|
442
|
+
'Asn' => %i[type],
|
|
443
|
+
}.freeze
|
|
444
|
+
|
|
418
445
|
# RFC 3339's full-date, the spec's `date`, and its date-time, the spec's
|
|
419
446
|
# `date-time`, its `T` and `Z` in either case, as RFC 3339 allows: through
|
|
420
447
|
# 2.8.4 a lowercase one failed the call. Anything else reached the
|
|
@@ -470,11 +497,14 @@ module InternetData
|
|
|
470
497
|
end
|
|
471
498
|
|
|
472
499
|
# A member absent or null reads as absent, unless the spec requires it and
|
|
473
|
-
# does not make it nullable.
|
|
500
|
+
# does not make it nullable, or {NEVER_NULL} lists it and the answer carries it null.
|
|
474
501
|
def self.check_member!(model, attr, member, value, where)
|
|
475
502
|
key = model.attribute_map[attr].to_s
|
|
476
503
|
return check_type!(value[key], member.to_s, "#{where}.#{key}") unless value[key].nil?
|
|
477
|
-
|
|
504
|
+
|
|
505
|
+
name = model.name.split('::').last
|
|
506
|
+
null_refused = value.key?(key) && NEVER_NULL.fetch(name, []).include?(attr)
|
|
507
|
+
return true unless REQUIRED.fetch(name).include?(attr) || null_refused
|
|
478
508
|
return true if model.openapi_nullable.include?(attr)
|
|
479
509
|
|
|
480
510
|
raise TypeError, "#{where}.#{key} is #{value.key?(key) ? 'null' : 'missing'}"
|
|
@@ -484,8 +514,9 @@ module InternetData
|
|
|
484
514
|
|
|
485
515
|
private
|
|
486
516
|
|
|
487
|
-
def lookup_get(path, timeout)
|
|
488
|
-
build_request(:GET, path,
|
|
517
|
+
def lookup_get(path, timeout, user_agent: nil)
|
|
518
|
+
build_request(:GET, path, query_params: user_agent ? { user_agent: user_agent } : {},
|
|
519
|
+
header_params: { 'Accept' => 'application/json' }, auth_names: LOOKUP_AUTH,
|
|
489
520
|
timeout: timeout)
|
|
490
521
|
end
|
|
491
522
|
end
|
data/lib/internetdata/version.rb
CHANGED