internetdata 2.9.2 → 2.10.1
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 +146 -9
- data/lib/internetdata/api/database_v2_api.rb +2 -2
- data/lib/internetdata/api_client.rb +2 -2
- data/lib/internetdata/api_error.rb +2 -2
- data/lib/internetdata/api_model_base.rb +2 -2
- data/lib/internetdata/asn_result.rb +107 -0
- data/lib/internetdata/bogon.rb +92 -0
- data/lib/internetdata/bogons.rb +93 -0
- data/lib/internetdata/cache.rb +35 -0
- data/lib/internetdata/client.rb +396 -16
- data/lib/internetdata/configuration.rb +23 -2
- data/lib/internetdata/domain_result.rb +124 -0
- data/lib/internetdata/errors.rb +29 -6
- data/lib/internetdata/models/abuse_contact.rb +236 -0
- data/lib/internetdata/models/asn.rb +294 -0
- data/lib/internetdata/models/asn_lookup_response.rb +405 -0
- data/lib/internetdata/models/asn_prefix.rb +329 -0
- data/lib/internetdata/models/batch_lookup_error.rb +192 -0
- data/lib/internetdata/models/bit_torrent_detail.rb +240 -0
- data/lib/internetdata/models/carrier_detail.rb +188 -0
- data/lib/internetdata/models/class_detail.rb +178 -0
- data/lib/internetdata/models/client_registration.rb +2 -2
- data/lib/internetdata/models/company.rb +213 -0
- data/lib/internetdata/models/database.rb +2 -2
- data/lib/internetdata/models/database_checksums_response.rb +2 -2
- data/lib/internetdata/models/database_format.rb +2 -2
- data/lib/internetdata/models/database_list.rb +2 -2
- data/lib/internetdata/models/database_metadata.rb +2 -2
- data/lib/internetdata/models/database_metadata_column.rb +2 -2
- data/lib/internetdata/models/database_version.rb +2 -2
- data/lib/internetdata/models/db_checksums.rb +2 -2
- data/lib/internetdata/models/device_authorization.rb +2 -2
- data/lib/internetdata/models/disposable_detail.rb +180 -0
- data/lib/internetdata/models/dns_address_record.rb +192 -0
- data/lib/internetdata/models/dns_cname_record.rb +192 -0
- data/lib/internetdata/models/dns_mx_record.rb +219 -0
- data/lib/internetdata/models/dns_ns_record.rb +192 -0
- data/lib/internetdata/models/dns_resolver_detail.rb +198 -0
- data/lib/internetdata/models/domain_dns.rb +279 -0
- data/lib/internetdata/models/domain_ip_range.rb +219 -0
- data/lib/internetdata/models/domain_ip_ranges.rb +276 -0
- data/lib/internetdata/models/domain_lookup_response.rb +376 -0
- data/lib/internetdata/models/download.rb +2 -2
- data/lib/internetdata/models/download_list.rb +2 -2
- data/lib/internetdata/models/entitlement.rb +243 -0
- data/lib/internetdata/models/entitlement_apikey.rb +207 -0
- data/lib/internetdata/models/entitlement_plan.rb +216 -0
- data/lib/internetdata/models/entitlement_usage.rb +259 -0
- data/lib/internetdata/models/error_envelope.rb +2 -2
- data/lib/internetdata/models/hosted_domains.rb +166 -0
- data/lib/internetdata/models/location.rb +509 -0
- data/lib/internetdata/models/lookup_response.rb +897 -0
- data/lib/internetdata/models/oauth_metadata.rb +2 -2
- data/lib/internetdata/models/proxy_detail.rb +208 -0
- data/lib/internetdata/models/pubproxy_detail.rb +210 -0
- data/lib/internetdata/models/rwhois.rb +301 -0
- data/lib/internetdata/models/satellite_detail.rb +208 -0
- data/lib/internetdata/models/smtp_detail.rb +188 -0
- data/lib/internetdata/models/ssh_detail.rb +198 -0
- data/lib/internetdata/models/standing.rb +2 -2
- data/lib/internetdata/models/token_response.rb +2 -2
- data/lib/internetdata/models/web_detail.rb +516 -0
- data/lib/internetdata/models/whois.rb +382 -0
- data/lib/internetdata/oauth_api.rb +1 -1
- data/lib/internetdata/result.rb +431 -0
- data/lib/internetdata/transport.rb +210 -26
- data/lib/internetdata/version.rb +1 -1
- data/lib/internetdata.rb +17 -2
- metadata +58 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'cgi'
|
|
3
4
|
require 'json'
|
|
4
5
|
require 'uri'
|
|
5
6
|
|
|
@@ -7,6 +8,21 @@ module InternetData
|
|
|
7
8
|
# The generated wire client, with the three things it gets wrong for this API
|
|
8
9
|
# corrected in one place.
|
|
9
10
|
class Transport < ApiClient
|
|
11
|
+
# The spec's path templates for the lookups, which the client builds itself:
|
|
12
|
+
# no generated class holds them, since a batch queues its requests on a hydra
|
|
13
|
+
# and the generated methods run each request as they build it. The suite
|
|
14
|
+
# holds each one to spec/openapi.yaml.
|
|
15
|
+
LOOKUP_PATH = '/{ip}'
|
|
16
|
+
MYIP_PATH = '/myip'
|
|
17
|
+
ASN_PATH = '/asn/{asn}'
|
|
18
|
+
DOMAIN_PATH = '/domain/{domain}'
|
|
19
|
+
ENTITLEMENT_PATH = '/api/v1/entitlement'
|
|
20
|
+
BATCH_PATH = '/batch'
|
|
21
|
+
# The lookups' operations spell their bearer scheme `bearerAuth` and the
|
|
22
|
+
# database's `BearerAuth`. Config answers the one bearer this client sends
|
|
23
|
+
# under the database's spelling, so a lookup names that.
|
|
24
|
+
LOOKUP_AUTH = %w[BearerAuth].freeze
|
|
25
|
+
|
|
10
26
|
# The longest `timeout` curl holds, in seconds: 2**31 - 1 ms, about 24.8 days.
|
|
11
27
|
# libcurl refuses a longer one, and any negative, and Ethon ignores the
|
|
12
28
|
# refusal, so the call would run with no bound at all.
|
|
@@ -48,6 +64,10 @@ module InternetData
|
|
|
48
64
|
self.scheme = uri.scheme
|
|
49
65
|
self.host = uri.port == uri.default_port ? uri.host : "#{uri.host}:#{uri.port}"
|
|
50
66
|
self.base_path = uri.path
|
|
67
|
+
# Every request goes to this base URL. The spec gives each lookup path a
|
|
68
|
+
# server of its own, production's, which an operation the generator
|
|
69
|
+
# emitted would otherwise be sent to whatever base URL the client has.
|
|
70
|
+
self.ignore_operation_servers = true
|
|
51
71
|
self.access_token = Transport.checked_key(api_key)
|
|
52
72
|
self.timeout = timeout.nil? ? nil : Transport.checked_timeout(timeout)
|
|
53
73
|
end
|
|
@@ -76,7 +96,7 @@ module InternetData
|
|
|
76
96
|
end
|
|
77
97
|
end
|
|
78
98
|
|
|
79
|
-
def initialize(config)
|
|
99
|
+
def initialize(config = Config.new)
|
|
80
100
|
super
|
|
81
101
|
@default_headers['User-Agent'] = "internetdata-ruby/#{VERSION}"
|
|
82
102
|
end
|
|
@@ -97,6 +117,24 @@ module InternetData
|
|
|
97
117
|
request
|
|
98
118
|
end
|
|
99
119
|
|
|
120
|
+
# A request built with `oauth: true` goes to the authorization server, the
|
|
121
|
+
# rest to the API.
|
|
122
|
+
def build_request_url(path, opts = {})
|
|
123
|
+
opts[:oauth] ? "#{oauth_base_url}#{path}" : super
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Where the authorization server answers: the apex the API host is named
|
|
127
|
+
# under, since the issuer is the apex and the API host serves no OAuth
|
|
128
|
+
# route. `api.` is dropped and `api-<env>.` becomes `<env>.`, so
|
|
129
|
+
# `https://api.internetdata.io` signs in at `https://internetdata.io`; any
|
|
130
|
+
# other base URL is used as given.
|
|
131
|
+
def oauth_base_url
|
|
132
|
+
@config.base_url.sub(%r{\A(https?://)api(?:-([^./:]+))?\.}i) do
|
|
133
|
+
env = Regexp.last_match(2)
|
|
134
|
+
"#{Regexp.last_match(1)}#{env ? "#{env}." : ''}"
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
100
138
|
# A 2xx the generated client cannot read as the answer it promises is the
|
|
101
139
|
# server's fault, and a retryable :server_error, as it is on the OAuth calls:
|
|
102
140
|
# a proxy's HTML page, a cut-off or empty body, or an object missing a member
|
|
@@ -112,7 +150,7 @@ module InternetData
|
|
|
112
150
|
data = super
|
|
113
151
|
raise Error.new(:server_error, "the API answered with no #{return_type}", status: response.code) if data.nil?
|
|
114
152
|
|
|
115
|
-
check_type!(JSON.parse(response.body
|
|
153
|
+
Transport.check_type!(JSON.parse(response.body.to_s), return_type.to_s, 'the answer') if return_type
|
|
116
154
|
data
|
|
117
155
|
rescue Error
|
|
118
156
|
raise
|
|
@@ -158,12 +196,111 @@ module InternetData
|
|
|
158
196
|
headers = { 'Accept' => 'application/json' }
|
|
159
197
|
headers['Content-Type'] = 'application/x-www-form-urlencoded' unless form.nil?
|
|
160
198
|
headers['Content-Type'] = 'application/json' unless json.nil?
|
|
161
|
-
request = build_request(http_method, path, header_params: headers, auth_names: [], timeout: timeout
|
|
199
|
+
request = build_request(http_method, path, header_params: headers, auth_names: [], timeout: timeout,
|
|
200
|
+
oauth: true)
|
|
162
201
|
request.options[:body] = URI.encode_www_form(form) unless form.nil?
|
|
163
202
|
request.options[:body] = JSON.generate(json) unless json.nil?
|
|
164
203
|
request
|
|
165
204
|
end
|
|
166
205
|
|
|
206
|
+
def lookup_request(ip, timeout: nil)
|
|
207
|
+
lookup_get(LOOKUP_PATH.sub('{ip}', CGI.escape(ip.to_s)), timeout)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def myip_request(timeout: nil)
|
|
211
|
+
lookup_get(MYIP_PATH, timeout)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def asn_request(asn, timeout: nil)
|
|
215
|
+
lookup_get(ASN_PATH.sub('{asn}', CGI.escape(asn.to_s)), timeout)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def domain_request(domain, timeout: nil)
|
|
219
|
+
lookup_get(DOMAIN_PATH.sub('{domain}', CGI.escape(domain.to_s)), timeout)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def entitlement_request(timeout: nil)
|
|
223
|
+
lookup_get(ENTITLEMENT_PATH, timeout)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# The one request with a body: the batch.
|
|
227
|
+
def batch_request(ips, timeout: nil)
|
|
228
|
+
build_request(
|
|
229
|
+
:POST, BATCH_PATH,
|
|
230
|
+
header_params: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' },
|
|
231
|
+
body: { ips: ips },
|
|
232
|
+
auth_names: LOOKUP_AUTH,
|
|
233
|
+
timeout: timeout,
|
|
234
|
+
)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def self.entitlement_result(response)
|
|
238
|
+
body = answer(response)
|
|
239
|
+
begin
|
|
240
|
+
check_type!(body, 'Entitlement', 'the answer')
|
|
241
|
+
Entitlement.build_from_hash(body)
|
|
242
|
+
rescue StandardError => e
|
|
243
|
+
raise Error.new(:server_error, "could not read the answer as Entitlement: #{e.message}",
|
|
244
|
+
status: response.code)
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def self.lookup_result(response)
|
|
249
|
+
Result.new(checked_answer(response, 'LookupResponse'))
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def self.asn_result(response)
|
|
253
|
+
AsnResult.new(checked_answer(response, 'AsnLookupResponse'))
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def self.domain_result(response)
|
|
257
|
+
DomainResult.new(checked_answer(response, 'DomainLookupResponse'))
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# Whether a parsed value is the generated `type`: a batch entry that is not
|
|
261
|
+
# is that address's error alone.
|
|
262
|
+
def self.conforms?(value, type)
|
|
263
|
+
check_type!(value, type, 'the entry')
|
|
264
|
+
rescue TypeError
|
|
265
|
+
false
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# The two maps of a batch answer, each present even when empty. An answer
|
|
269
|
+
# carrying neither is unreadable as a whole, and is retried as one.
|
|
270
|
+
def self.batch_body(response)
|
|
271
|
+
body = answer(response)
|
|
272
|
+
unless body['results'].is_a?(Hash) || body['errors'].is_a?(Hash)
|
|
273
|
+
raise Error.new(:server_error, 'the batch answer carried neither results nor errors',
|
|
274
|
+
status: response.code)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
{
|
|
278
|
+
'results' => body['results'].is_a?(Hash) ? body['results'] : {},
|
|
279
|
+
'errors' => body['errors'].is_a?(Hash) ? body['errors'] : {},
|
|
280
|
+
}
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# The JSON object a 2xx lookup answer carries; anything else raises the
|
|
284
|
+
# error its status or its unreadable body maps to.
|
|
285
|
+
def self.answer(response)
|
|
286
|
+
raise Error.from_transport(response) if transport_failure?(response)
|
|
287
|
+
raise Error.from_status(response.code, response.headers, response.body) unless response.success?
|
|
288
|
+
|
|
289
|
+
parse_object(response)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# The answer, once every member it carries has the spec's type.
|
|
293
|
+
def self.checked_answer(response, type)
|
|
294
|
+
body = answer(response)
|
|
295
|
+
begin
|
|
296
|
+
check_type!(body, type, 'the answer')
|
|
297
|
+
rescue TypeError => e
|
|
298
|
+
raise Error.new(:server_error, "could not read the answer as #{type}: #{e.message}",
|
|
299
|
+
status: response.code)
|
|
300
|
+
end
|
|
301
|
+
body
|
|
302
|
+
end
|
|
303
|
+
|
|
167
304
|
# The JSON object a 2xx OAuth answer carries. A refusal the authorization
|
|
168
305
|
# server words as an RFC 6749 error raises that; anything else that is not a
|
|
169
306
|
# 2xx raises the ordinary error its status maps to.
|
|
@@ -209,14 +346,54 @@ module InternetData
|
|
|
209
346
|
status: response.code)
|
|
210
347
|
end
|
|
211
348
|
|
|
212
|
-
private_class_method :transport_failure?, :parse_object, :oauth_refusal
|
|
349
|
+
private_class_method :transport_failure?, :parse_object, :oauth_refusal, :answer, :checked_answer
|
|
213
350
|
|
|
214
|
-
# The members the spec requires of each answer a
|
|
215
|
-
#
|
|
216
|
-
# skips the writer of a list or map
|
|
217
|
-
# null` came back as a family with no
|
|
218
|
-
#
|
|
351
|
+
# The members the spec requires of each answer a lookup, a batch, the
|
|
352
|
+
# entitlement or a database call reads. One that is not nullable must be
|
|
353
|
+
# there and not null: the generated reader skips the writer of a list or map
|
|
354
|
+
# member that is not one, so `"versions": null` came back as a family with no
|
|
355
|
+
# versions (2.8.1, measured 2026-10-19). A member the spec does not require is
|
|
356
|
+
# one a plan may leave out, every member of a detail object among them, which
|
|
357
|
+
# is `{}` under a false flag. test/database_test.rb holds this to
|
|
358
|
+
# spec/openapi.yaml.
|
|
219
359
|
REQUIRED = {
|
|
360
|
+
'LookupResponse' => %i[ip is_bogon is_tor is_relay is_anycast is_carrier is_satellite is_ssh is_smtp
|
|
361
|
+
is_web is_dns_resolver is_bittorrent tor relay location asn company hostname abuse],
|
|
362
|
+
'ClassDetail' => [],
|
|
363
|
+
'ProxyDetail' => [],
|
|
364
|
+
'PubproxyDetail' => [],
|
|
365
|
+
'CarrierDetail' => [],
|
|
366
|
+
'SatelliteDetail' => [],
|
|
367
|
+
'SshDetail' => [],
|
|
368
|
+
'SmtpDetail' => [],
|
|
369
|
+
'WebDetail' => %i[port tls_ok session_ok status_code server location title cert_subject_cn
|
|
370
|
+
cert_subject_o cert_issuer_dn cert_browser_trusted tls_version first_seen last_seen],
|
|
371
|
+
'DnsResolverDetail' => [],
|
|
372
|
+
'BitTorrentDetail' => [],
|
|
373
|
+
'Location' => %i[continent continent_name country country_name timezone currency_code currency_name
|
|
374
|
+
currency_symbol flag_emoji flag_unicode],
|
|
375
|
+
'Asn' => %i[asn name domain type prefix],
|
|
376
|
+
'Company' => %i[name domain],
|
|
377
|
+
'AbuseContact' => %i[email],
|
|
378
|
+
'Whois' => %i[id name org country status source domain abuse_email asn],
|
|
379
|
+
'Rwhois' => %i[id name country source domain abuse_email],
|
|
380
|
+
'HostedDomains' => %i[total],
|
|
381
|
+
'AsnLookupResponse' => %i[asn name country registry allocated domain],
|
|
382
|
+
'AsnPrefix' => %i[prefix peer_count rpki_status first_seen country size other_origins],
|
|
383
|
+
'DomainLookupResponse' => %i[domain is_registered has_a has_aaaa has_mx has_ns has_cname],
|
|
384
|
+
'DomainDns' => %i[a aaaa mx ns cname],
|
|
385
|
+
'DnsAddressRecord' => %i[ip last_seen],
|
|
386
|
+
'DnsMxRecord' => %i[priority host last_seen],
|
|
387
|
+
'DnsNsRecord' => %i[host last_seen],
|
|
388
|
+
'DnsCnameRecord' => %i[target last_seen],
|
|
389
|
+
'DomainIpRanges' => %i[domain redirects_to total ipv4 ranges],
|
|
390
|
+
'DomainIpRange' => %i[range name country],
|
|
391
|
+
'DisposableDetail' => [],
|
|
392
|
+
'BatchLookupError' => %i[status error],
|
|
393
|
+
'Entitlement' => %i[org_id apikey plan usage],
|
|
394
|
+
'EntitlementApikey' => %i[id expires allowed_cidrs],
|
|
395
|
+
'EntitlementPlan' => %i[key tier],
|
|
396
|
+
'EntitlementUsage' => %i[requests quota hard_limit window_start window_end],
|
|
220
397
|
'DatabaseList' => %i[databases],
|
|
221
398
|
'Database' => %i[base name summary standing open license_type starts expires renews_at notice_due_at versions],
|
|
222
399
|
'DatabaseVersion' => %i[id version summary formats],
|
|
@@ -237,13 +414,20 @@ module InternetData
|
|
|
237
414
|
RFC3339_DATE = /\A(\d{4})-(\d{2})-(\d{2})\z/
|
|
238
415
|
RFC3339_DATE_TIME = /\A(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))\z/
|
|
239
416
|
|
|
240
|
-
|
|
417
|
+
# A date in the form its type names, on a day and at a time that exist: an
|
|
418
|
+
# hour of 24 rolls over the way a missing day does.
|
|
419
|
+
def self.date?(value, type)
|
|
420
|
+
m = (type == 'Date' ? RFC3339_DATE : RFC3339_DATE_TIME).match(value)
|
|
421
|
+
return false unless m && Date.valid_date?(m[1].to_i, m[2].to_i, m[3].to_i)
|
|
241
422
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
#
|
|
246
|
-
|
|
423
|
+
type == 'Date' || (m[4].to_i < 24 && m[5].to_i < 60 && m[6].to_i < 60 && m[7].to_i < 24 && m[8].to_i < 60)
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
# True when the parsed `value` has the generated `type`, a model's members
|
|
427
|
+
# recursively; raises TypeError naming where it does not. No list entry or
|
|
428
|
+
# map value the spec describes may be null: through 2.8.1 one came back as
|
|
429
|
+
# nil, or as 0 in `size`.
|
|
430
|
+
def self.check_type!(value, type, where)
|
|
247
431
|
raise TypeError, "#{where} is null" if value.nil?
|
|
248
432
|
|
|
249
433
|
typed =
|
|
@@ -275,24 +459,24 @@ module InternetData
|
|
|
275
459
|
raise TypeError, "#{where} is not a #{type}"
|
|
276
460
|
end
|
|
277
461
|
|
|
278
|
-
# A date in the form its type names, on a day and at a time that exist: an
|
|
279
|
-
# hour of 24 rolls over the way a missing day does.
|
|
280
|
-
def date?(value, type)
|
|
281
|
-
m = (type == 'Date' ? RFC3339_DATE : RFC3339_DATE_TIME).match(value)
|
|
282
|
-
return false unless m && Date.valid_date?(m[1].to_i, m[2].to_i, m[3].to_i)
|
|
283
|
-
|
|
284
|
-
type == 'Date' || (m[4].to_i < 24 && m[5].to_i < 60 && m[6].to_i < 60 && m[7].to_i < 24 && m[8].to_i < 60)
|
|
285
|
-
end
|
|
286
|
-
|
|
287
462
|
# A member absent or null reads as absent, unless the spec requires it and
|
|
288
463
|
# does not make it nullable.
|
|
289
|
-
def check_member!(model, attr, member, value, where)
|
|
290
|
-
key = model.attribute_map[attr]
|
|
464
|
+
def self.check_member!(model, attr, member, value, where)
|
|
465
|
+
key = model.attribute_map[attr].to_s
|
|
291
466
|
return check_type!(value[key], member.to_s, "#{where}.#{key}") unless value[key].nil?
|
|
292
467
|
return true unless REQUIRED.fetch(model.name.split('::').last).include?(attr)
|
|
293
468
|
return true if model.openapi_nullable.include?(attr)
|
|
294
469
|
|
|
295
470
|
raise TypeError, "#{where}.#{key} is #{value.key?(key) ? 'null' : 'missing'}"
|
|
296
471
|
end
|
|
472
|
+
|
|
473
|
+
private_class_method :check_member!
|
|
474
|
+
|
|
475
|
+
private
|
|
476
|
+
|
|
477
|
+
def lookup_get(path, timeout)
|
|
478
|
+
build_request(:GET, path, header_params: { 'Accept' => 'application/json' }, auth_names: LOOKUP_AUTH,
|
|
479
|
+
timeout: timeout)
|
|
480
|
+
end
|
|
297
481
|
end
|
|
298
482
|
end
|
data/lib/internetdata/version.rb
CHANGED
data/lib/internetdata.rb
CHANGED
|
@@ -12,7 +12,13 @@ require 'internetdata/configuration'
|
|
|
12
12
|
Dir[File.join(__dir__, 'internetdata', 'models', '*.rb')].sort.each { |model| require model }
|
|
13
13
|
Dir[File.join(__dir__, 'internetdata', 'api', '*.rb')].sort.each { |api| require api }
|
|
14
14
|
|
|
15
|
+
require 'internetdata/bogons'
|
|
15
16
|
require 'internetdata/errors'
|
|
17
|
+
require 'internetdata/result'
|
|
18
|
+
require 'internetdata/asn_result'
|
|
19
|
+
require 'internetdata/domain_result'
|
|
20
|
+
require 'internetdata/bogon'
|
|
21
|
+
require 'internetdata/cache'
|
|
16
22
|
require 'internetdata/retries'
|
|
17
23
|
require 'internetdata/transport'
|
|
18
24
|
require 'internetdata/database_api'
|
|
@@ -21,7 +27,16 @@ require 'internetdata/client'
|
|
|
21
27
|
|
|
22
28
|
# The official Ruby client library for the InternetData API.
|
|
23
29
|
#
|
|
24
|
-
# client = InternetData::Client.new
|
|
25
|
-
# client.
|
|
30
|
+
# client = InternetData::Client.new
|
|
31
|
+
# client.lookup('146.70.116.130').location['country'] # => "AT"
|
|
26
32
|
module InternetData
|
|
33
|
+
# Whether an address is a bogon: private, loopback, link-local, documentation,
|
|
34
|
+
# multicast or otherwise not routable on the public internet, including the
|
|
35
|
+
# IPv6 equivalents and the 6to4 and Teredo ranges that wrap them.
|
|
36
|
+
#
|
|
37
|
+
# A client answers these itself, so they never cost a request. The same
|
|
38
|
+
# predicate is on the client, which is how the README teaches it.
|
|
39
|
+
def self.bogon?(ip)
|
|
40
|
+
Bogon.bogon?(ip)
|
|
41
|
+
end
|
|
27
42
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: internetdata
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.10.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mslm Dev
|
|
@@ -23,8 +23,23 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '1.4'
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: lru_redux
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.1'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.1'
|
|
40
|
+
description: Look up IP addresses, AS numbers and domains in the InternetData API,
|
|
41
|
+
and download its IP and ASN databases with their metadata, checksums and download
|
|
42
|
+
history.
|
|
28
43
|
email:
|
|
29
44
|
- dev@internetdata.io
|
|
30
45
|
executables: []
|
|
@@ -38,11 +53,25 @@ files:
|
|
|
38
53
|
- lib/internetdata/api_client.rb
|
|
39
54
|
- lib/internetdata/api_error.rb
|
|
40
55
|
- lib/internetdata/api_model_base.rb
|
|
56
|
+
- lib/internetdata/asn_result.rb
|
|
57
|
+
- lib/internetdata/bogon.rb
|
|
58
|
+
- lib/internetdata/bogons.rb
|
|
59
|
+
- lib/internetdata/cache.rb
|
|
41
60
|
- lib/internetdata/client.rb
|
|
42
61
|
- lib/internetdata/configuration.rb
|
|
43
62
|
- lib/internetdata/database_api.rb
|
|
63
|
+
- lib/internetdata/domain_result.rb
|
|
44
64
|
- lib/internetdata/errors.rb
|
|
65
|
+
- lib/internetdata/models/abuse_contact.rb
|
|
66
|
+
- lib/internetdata/models/asn.rb
|
|
67
|
+
- lib/internetdata/models/asn_lookup_response.rb
|
|
68
|
+
- lib/internetdata/models/asn_prefix.rb
|
|
69
|
+
- lib/internetdata/models/batch_lookup_error.rb
|
|
70
|
+
- lib/internetdata/models/bit_torrent_detail.rb
|
|
71
|
+
- lib/internetdata/models/carrier_detail.rb
|
|
72
|
+
- lib/internetdata/models/class_detail.rb
|
|
45
73
|
- lib/internetdata/models/client_registration.rb
|
|
74
|
+
- lib/internetdata/models/company.rb
|
|
46
75
|
- lib/internetdata/models/database.rb
|
|
47
76
|
- lib/internetdata/models/database_checksums_response.rb
|
|
48
77
|
- lib/internetdata/models/database_format.rb
|
|
@@ -52,13 +81,39 @@ files:
|
|
|
52
81
|
- lib/internetdata/models/database_version.rb
|
|
53
82
|
- lib/internetdata/models/db_checksums.rb
|
|
54
83
|
- lib/internetdata/models/device_authorization.rb
|
|
84
|
+
- lib/internetdata/models/disposable_detail.rb
|
|
85
|
+
- lib/internetdata/models/dns_address_record.rb
|
|
86
|
+
- lib/internetdata/models/dns_cname_record.rb
|
|
87
|
+
- lib/internetdata/models/dns_mx_record.rb
|
|
88
|
+
- lib/internetdata/models/dns_ns_record.rb
|
|
89
|
+
- lib/internetdata/models/dns_resolver_detail.rb
|
|
90
|
+
- lib/internetdata/models/domain_dns.rb
|
|
91
|
+
- lib/internetdata/models/domain_ip_range.rb
|
|
92
|
+
- lib/internetdata/models/domain_ip_ranges.rb
|
|
93
|
+
- lib/internetdata/models/domain_lookup_response.rb
|
|
55
94
|
- lib/internetdata/models/download.rb
|
|
56
95
|
- lib/internetdata/models/download_list.rb
|
|
96
|
+
- lib/internetdata/models/entitlement.rb
|
|
97
|
+
- lib/internetdata/models/entitlement_apikey.rb
|
|
98
|
+
- lib/internetdata/models/entitlement_plan.rb
|
|
99
|
+
- lib/internetdata/models/entitlement_usage.rb
|
|
57
100
|
- lib/internetdata/models/error_envelope.rb
|
|
101
|
+
- lib/internetdata/models/hosted_domains.rb
|
|
102
|
+
- lib/internetdata/models/location.rb
|
|
103
|
+
- lib/internetdata/models/lookup_response.rb
|
|
58
104
|
- lib/internetdata/models/oauth_metadata.rb
|
|
105
|
+
- lib/internetdata/models/proxy_detail.rb
|
|
106
|
+
- lib/internetdata/models/pubproxy_detail.rb
|
|
107
|
+
- lib/internetdata/models/rwhois.rb
|
|
108
|
+
- lib/internetdata/models/satellite_detail.rb
|
|
109
|
+
- lib/internetdata/models/smtp_detail.rb
|
|
110
|
+
- lib/internetdata/models/ssh_detail.rb
|
|
59
111
|
- lib/internetdata/models/standing.rb
|
|
60
112
|
- lib/internetdata/models/token_response.rb
|
|
113
|
+
- lib/internetdata/models/web_detail.rb
|
|
114
|
+
- lib/internetdata/models/whois.rb
|
|
61
115
|
- lib/internetdata/oauth_api.rb
|
|
116
|
+
- lib/internetdata/result.rb
|
|
62
117
|
- lib/internetdata/retries.rb
|
|
63
118
|
- lib/internetdata/transport.rb
|
|
64
119
|
- lib/internetdata/version.rb
|