vpndetection 5.2.0 → 5.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 199c0adec648e1556593cb36414f58482fdf2f638f59fad25ca04ee43c0de02c
4
- data.tar.gz: f8a7d728594094a46cfcac9ba2306ebd351bc3d80b785eabd1743252a7f6588e
3
+ metadata.gz: b1a72dc0f5b07ed01b35b61d0cc8a50fda1f1872a18af970690499e0823abc77
4
+ data.tar.gz: 96a2bbd19642f678ce5f60a8898662a84b27f50cd0d129bc8eaaafaea9fab59b
5
5
  SHA512:
6
- metadata.gz: b148e272ab33acca1a14b5523c448411d92882a6069ba183522e223077ed5185854feeca378608d68009abaf08ee9a1bcffada932cb42e006455992d07e98eb7
7
- data.tar.gz: a42507f48287500895380ded3951be855dcfd24311933efc9a50e79c3c81a230ab32a9f9378d7de9aa33a9778f4e15c5f5d55e94c0f8f8f60bae519cc51f6ece
6
+ metadata.gz: 7aa1e6b3fe0e4c2b210b9c0a61a28d5d997b794265eb8b40d64d0838834adf850f15854bf267d1b72aafee6af864b6b3c07f2c9b983c39be5d2993ae2c22bb2d
7
+ data.tar.gz: 42b9392f37d9baffbe6e8aa94d032c6173f1435fa5f0017122c9df8f422bfc6670712487a79617daea87ffd52d225ccc36cccae57cebfe2028f792c08ead26d0
data/README.md CHANGED
@@ -19,7 +19,7 @@ Or add it to your Gemfile:
19
19
  gem 'vpndetection'
20
20
  ```
21
21
 
22
- Requires Ruby 3.1 or newer.
22
+ Requires Ruby 3.3 or newer.
23
23
 
24
24
  ## Usage
25
25
 
@@ -160,7 +160,7 @@ client = VPNDetection::Client.new(timeout: 10, retries: 4)
160
160
  result = client.lookup('45.83.91.1', timeout: 2, retries: 0)
161
161
  ```
162
162
 
163
- `timeout` is in seconds and bounds each attempt, body included, so a call that is retried can take longer in total. It defaults to 30 seconds; before 5.2.0 the default was 10, so pass `timeout: 10` to keep that bound. The client's values are defaults: `lookup`, `lookup_batch`, `my_ip` and `my_entitlement` each take `timeout:` and `retries:` for that call alone, and every `client.oauth` method takes `timeout:`. A database download bounds only its connection with it, because a whole transfer can take minutes.
163
+ `timeout` is in seconds and bounds each attempt, body included, so a call that is retried can take longer in total. It defaults to 30 seconds; before 5.2.0 the default was 10, so pass `timeout: 10` to keep that bound. The client's values are defaults: `lookup`, `lookup_batch`, `my_ip` and `my_entitlement` each take `timeout:` and `retries:` for that call alone, and every `client.oauth` method and every `client.database` call that is not a transfer takes `timeout:` (from 5.3.0). A database download bounds only its connection with it, because a whole transfer can take minutes.
164
164
 
165
165
  ### Database downloads
166
166
 
@@ -177,6 +177,15 @@ bytes = client.database.download_bytes('cdn_ip_v1', 'csvgz')
177
177
 
178
178
  `download` streams straight to disk, so nothing bigger than a chunk is ever held in memory whatever the database weighs, and it writes through a neighboring `.part` file so a transfer that dies half way leaves no truncated copy behind. `download_url` hands back the time-limited link and follows nothing, for when you want to run the transfer yourself. `download_bytes` holds the whole file in memory, and the catalog runs from `cdn_ip_v1` at 10 KB to `resproxy_ip_90d_v1` at 1.79 GB, so reach for `download` for anything you have not measured.
179
179
 
180
+ From 5.3.0, `list`, `metadata`, `checksums`, `downloads` and `download_url` each take `timeout:` in seconds for that call alone, overriding the client's for one attempt of it:
181
+
182
+ ```ruby
183
+ catalog = client.database.list(timeout: 5)
184
+ sums = client.database.checksums(id, 'mmdb', timeout: 5)
185
+ ```
186
+
187
+ `download` and `download_bytes` deliberately take no `timeout:` and raise `ArgumentError` if handed one, rather than accepting it and quietly doing nothing: a transfer runs to gigabytes and minutes, so any bound that suits a JSON call would abandon a healthy download. `download_url` does take one, because minting the link is an ordinary API request - it bounds that request, not whatever you do with the link afterwards.
188
+
180
189
  ### Sign in with OAuth (device flow)
181
190
 
182
191
  A program running on a person's own machine can let them sign in with their browser and pick one of their API keys, instead of asking them to paste one.
@@ -5,6 +5,12 @@ module VPNDetection
5
5
  #
6
6
  # Access is granted by contract rather than self-serve, so every method here
7
7
  # needs a key carrying the `db.download` scope.
8
+ #
9
+ # Every JSON call here takes `timeout:`, in seconds, bounding each ATTEMPT of
10
+ # that call alone and overriding the bound the client was built with. The two
11
+ # transfers take none, and are refused it rather than ignoring it: a dataset
12
+ # runs to gigabytes and minutes, so a bound that suits a JSON call would
13
+ # abandon a healthy download.
8
14
  class DatabaseApi
9
15
  def initialize(transport, retries:)
10
16
  @transport = transport
@@ -17,13 +23,17 @@ module VPNDetection
17
23
  # A license is held against the family, while a download names one version,
18
24
  # so the ids {#download}, {#download_bytes}, {#download_url} and {#checksums}
19
25
  # take come from each family's `versions`, not from the family itself.
20
- def list
21
- call { @api.list_databases.databases }
26
+ #
27
+ # @param timeout [Numeric, nil] seconds this attempt may take, for THIS call only.
28
+ def list(timeout: nil)
29
+ call { @api.list_databases(timeout: timeout).databases }
22
30
  end
23
31
 
24
32
  # What is inside one dataset: schema, samples, row count and sizes.
25
- def metadata(id)
26
- call { @api.database_metadata(id) }
33
+ #
34
+ # @param timeout [Numeric, nil] seconds this attempt may take, for THIS call only.
35
+ def metadata(id, timeout: nil)
36
+ call { @api.database_metadata(id, timeout: timeout) }
27
37
  end
28
38
 
29
39
  # The digests for one dataset file.
@@ -31,14 +41,18 @@ module VPNDetection
31
41
  # Returns the whole set rather than one algorithm: which digests a dataset
32
42
  # publishes is the API's choice, not ours, and the response nests them one
33
43
  # level down under `checksums`.
34
- def checksums(id, format)
44
+ #
45
+ # @param timeout [Numeric, nil] seconds this attempt may take, for THIS call only.
46
+ def checksums(id, format, timeout: nil)
35
47
  check_format!(format)
36
- call { @api.database_checksum(id, format).checksums }
48
+ call { @api.database_checksum(id, format, timeout: timeout).checksums }
37
49
  end
38
50
 
39
51
  # Your organization's recent download attempts, newest first.
40
- def downloads(limit: nil)
41
- call { @api.list_downloads(limit.nil? ? {} : { limit: limit }).downloads }
52
+ #
53
+ # @param timeout [Numeric, nil] seconds this attempt may take, for THIS call only.
54
+ def downloads(limit: nil, timeout: nil)
55
+ call { @api.list_downloads(limit: limit, timeout: timeout).downloads }
42
56
  end
43
57
 
44
58
  # The time-limited URL for one dataset file.
@@ -47,9 +61,13 @@ module VPNDetection
47
61
  # transfer a file that routinely runs to gigabytes; the link authorizes the
48
62
  # START of a transfer, so one already running is not interrupted when it
49
63
  # lapses.
50
- def download_url(id, format)
64
+ #
65
+ # @param timeout [Numeric, nil] seconds this attempt may take, for THIS call
66
+ # only. It bounds the request that MINTS the link, which is an ordinary
67
+ # JSON call, and says nothing about the transfer you then run with it.
68
+ def download_url(id, format, timeout: nil)
51
69
  check_format!(format)
52
- call { redirect_location(id, format) }
70
+ call { redirect_location(id, format, timeout) }
53
71
  end
54
72
 
55
73
  # Download one dataset file to `path`, and return the bytes written.
@@ -161,8 +179,8 @@ module VPNDetection
161
179
  # The 302 is this operation's SUCCESS case, but the generated client treats
162
180
  # every non-2xx as a failure, so it arrives as an ApiError carrying the
163
181
  # Location header.
164
- def redirect_location(id, format)
165
- @api.download_database(id, format)
182
+ def redirect_location(id, format, timeout)
183
+ @api.download_database(id, format, timeout: timeout)
166
184
  raise Error.new(:server_error, 'expected a redirect to object storage')
167
185
  rescue ApiError => e
168
186
  raise unless e.code == 302
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VPNDetection
4
- VERSION = '5.2.0'
4
+ VERSION = '5.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpndetection
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mslm Dev
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: '3.1'
133
+ version: '3.3'
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="