vpndetection 5.18.1 → 5.20.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 +15 -2
- data/lib/vpndetection/api/account_wire_api.rb +3 -3
- data/lib/vpndetection/api/api_keys_wire_api.rb +9 -9
- data/lib/vpndetection/api/authorization_wire_api.rb +1 -1
- data/lib/vpndetection/api/database_wire_api.rb +1 -1
- data/lib/vpndetection/api/entitlement_wire_api.rb +1 -1
- data/lib/vpndetection/api/lookup_wire_api.rb +15 -1
- data/lib/vpndetection/api/organization_wire_api.rb +5 -5
- data/lib/vpndetection/api_client.rb +1 -1
- data/lib/vpndetection/api_error.rb +1 -1
- data/lib/vpndetection/api_model_base.rb +1 -1
- data/lib/vpndetection/client.rb +78 -41
- data/lib/vpndetection/configuration.rb +1 -1
- data/lib/vpndetection/middleware/core.rb +61 -5
- data/lib/vpndetection/models/abuse_contact.rb +1 -1
- data/lib/vpndetection/models/account_create_apikey_request.rb +1 -1
- data/lib/vpndetection/models/account_created_apikey.rb +1 -1
- data/lib/vpndetection/models/account_org.rb +1 -1
- data/lib/vpndetection/models/account_org_ref.rb +1 -1
- data/lib/vpndetection/models/account_org_wrap.rb +1 -1
- data/lib/vpndetection/models/account_rc.rb +1 -1
- data/lib/vpndetection/models/account_revealed_apikey.rb +1 -1
- data/lib/vpndetection/models/account_user.rb +1 -1
- data/lib/vpndetection/models/apikey_detail.rb +1 -1
- data/lib/vpndetection/models/apikey_list.rb +1 -1
- data/lib/vpndetection/models/asn.rb +35 -1
- data/lib/vpndetection/models/batch_lookup_error.rb +1 -1
- data/lib/vpndetection/models/batch_lookup_request.rb +17 -5
- data/lib/vpndetection/models/batch_lookup_response.rb +1 -1
- data/lib/vpndetection/models/bit_torrent_detail.rb +1 -1
- data/lib/vpndetection/models/bot_detail.rb +243 -0
- data/lib/vpndetection/models/carrier_detail.rb +1 -1
- data/lib/vpndetection/models/class_detail.rb +1 -1
- data/lib/vpndetection/models/client_registration.rb +1 -1
- data/lib/vpndetection/models/client_registration_request.rb +1 -1
- data/lib/vpndetection/models/company.rb +1 -1
- data/lib/vpndetection/models/database.rb +1 -1
- data/lib/vpndetection/models/database_checksums_response.rb +1 -1
- data/lib/vpndetection/models/database_format.rb +1 -1
- data/lib/vpndetection/models/database_format_size.rb +1 -1
- data/lib/vpndetection/models/database_list.rb +1 -1
- data/lib/vpndetection/models/database_metadata.rb +1 -1
- data/lib/vpndetection/models/database_metadata_column.rb +1 -1
- data/lib/vpndetection/models/database_version.rb +1 -1
- data/lib/vpndetection/models/db_checksums.rb +1 -1
- data/lib/vpndetection/models/device_authorization.rb +1 -1
- data/lib/vpndetection/models/dns_resolver_detail.rb +1 -1
- data/lib/vpndetection/models/download.rb +1 -1
- data/lib/vpndetection/models/download_list.rb +1 -1
- data/lib/vpndetection/models/entitlement.rb +1 -1
- data/lib/vpndetection/models/entitlement_apikey.rb +1 -1
- data/lib/vpndetection/models/entitlement_error.rb +1 -1
- data/lib/vpndetection/models/entitlement_plan.rb +1 -1
- data/lib/vpndetection/models/entitlement_usage.rb +1 -1
- data/lib/vpndetection/models/error_envelope.rb +1 -1
- data/lib/vpndetection/models/identity.rb +1 -1
- data/lib/vpndetection/models/location.rb +1 -1
- data/lib/vpndetection/models/lookup_error.rb +1 -1
- data/lib/vpndetection/models/lookup_response.rb +32 -2
- data/lib/vpndetection/models/oauth_error.rb +1 -1
- data/lib/vpndetection/models/oauth_metadata.rb +1 -1
- data/lib/vpndetection/models/proxy_detail.rb +1 -1
- data/lib/vpndetection/models/pubproxy_detail.rb +1 -1
- data/lib/vpndetection/models/satellite_detail.rb +1 -1
- data/lib/vpndetection/models/smtp_detail.rb +1 -1
- data/lib/vpndetection/models/ssh_detail.rb +1 -1
- data/lib/vpndetection/models/standing.rb +1 -1
- data/lib/vpndetection/models/token_response.rb +1 -1
- data/lib/vpndetection/models/user_agent_verdict.rb +239 -0
- data/lib/vpndetection/models/vpn_detail.rb +1 -1
- data/lib/vpndetection/models/web_detail.rb +1 -1
- data/lib/vpndetection/result.rb +38 -3
- data/lib/vpndetection/transport.rb +29 -6
- data/lib/vpndetection/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0752e89f4d6355b042703b60a37c1c9e27d9d4d11d62faced4cf9adb29009b02
|
|
4
|
+
data.tar.gz: 0cbc519247f2cddc8bf2f79ba5b9b8f81f96f423aec1490ae885c69b22ee64e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 88105b406ef6df997ce3a204f7d9b564810302e818d97bbec0238dacdebae40c9deb1ea1b2f3532de025e22fd8d2e7d3d07f7b8cf8d3886a78f4258d9e0d74d5
|
|
7
|
+
data.tar.gz: c779276341271b701c9e1b7ed3a3f9fd422bac442a18af256197e566c846452dee577129d5cd5d725c8094045b02fb0d36dcc3dc10cb348b1aa710c64d5b1f03
|
data/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Requires Ruby 3.3 or newer, and libcurl at runtime, which the `curl` package bri
|
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
25
25
|
|
|
26
|
-
**No API key needed to start.** Unlimited, the free plan, answers `ip`, `is_vpn`, Tor and relay detection, `is_anycast`, `hostname` (the reverse DNS name), country-level `location` and `asn` with the AS's country and RPKI status, with no daily or monthly cap, with a key or without one.
|
|
26
|
+
**No API key needed to start.** Unlimited, the free plan, answers `ip`, `is_vpn`, Tor and relay detection, `is_anycast`, `is_bot` (whether an automated client, such as a search engine's crawler, uses the address), `hostname` (the reverse DNS name), country-level `location` and `asn` with the AS's country and RPKI status, with no daily or monthly cap, with a key or without one.
|
|
27
27
|
|
|
28
28
|
```ruby
|
|
29
29
|
require 'vpndetection'
|
|
@@ -38,7 +38,7 @@ result.asn['name'] # who runs the announcing network
|
|
|
38
38
|
|
|
39
39
|
### With an API key
|
|
40
40
|
|
|
41
|
-
Every paid plan answers every field: `is_hosting`, `is_cdn` and the four proxy flags as well, the carrier and satellite flags, the five service flags (SSH, SMTP, web, DNS resolver and BitTorrent), city-level `location`, the `company` and the `abuse` contact, and the provider (its ID and its name), confidence and last-seen detail behind each flag. The plans differ only in how many lookups they include, and a free account tries every field. Create a key in the [console](https://app.vpndetection.io), then pass it in:
|
|
41
|
+
Every paid plan answers every field: `is_hosting`, `is_cdn` and the four proxy flags as well, the carrier and satellite flags, the five service flags (SSH, SMTP, web, DNS resolver and BitTorrent), city-level `location`, the `company` and the `abuse` contact, `bot` (whose bot uses the address, what it does and whether its operator vouches for the address), and the provider (its ID and its name), confidence and last-seen detail behind each flag. The plans differ only in how many lookups they include, and a free account tries every field. Create a key in the [console](https://app.vpndetection.io), then pass it in:
|
|
42
42
|
|
|
43
43
|
```ruby
|
|
44
44
|
client = VPNDetection::Client.new(api_key: ENV['VPNDETECTION_API_KEY'])
|
|
@@ -72,6 +72,19 @@ Usage counts against the anniversary of your subscription on a paid plan, not th
|
|
|
72
72
|
|
|
73
73
|
Show `plan.name` and compare against `plan.key`: a plan's name can change, and its key never does. A value the API adds later to a plan's `tier`, a database's `standing` or `license_type`, a format or a download's `outcome` comes back as the string it served (from 5.16.0), so check for the values you know rather than assuming the list is complete.
|
|
74
74
|
|
|
75
|
+
### Is that crawler who it says it is?
|
|
76
|
+
|
|
77
|
+
Pass the `User-Agent` of the request you are deciding on, and with every field (a paid plan, or a free account's trial) the answer says whose agent it names and whether this address bears that out:
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
result = client.lookup('66.249.66.1', user_agent: request.user_agent)
|
|
81
|
+
result.user_agent # => {"agent"=>"Googlebot", "kind"=>"bot", "verdict"=>"verified"}
|
|
82
|
+
|
|
83
|
+
results = client.lookup_batch(ips, user_agents: { '66.249.66.1' => request.user_agent })
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`verdict` is `verified` where the agent's operator vouches for the address, `spoofed` where it does not, `unverifiable` for a bot nothing published can confirm, and `not_bot` for a browser, an app or a script. `my_ip` takes `user_agent:` too. A batch's `user_agents` is keyed by each address as you list it, and an address with no agent, or an empty one, is looked up plainly. An answer with an agent is cached apart from the address's plain answer and from another agent's. Unlimited's answers, a private address's and a lookup that sent none carry no `user_agent` (`nil`).
|
|
87
|
+
|
|
75
88
|
### Batch lookup
|
|
76
89
|
|
|
77
90
|
Look up as many addresses as you like at once. Bogons and cached answers are handled locally, and everything else goes to the batch endpoint in chunks of up to 1000 addresses, in parallel. The batch endpoint needs a paid plan:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -20,7 +20,7 @@ module VPNDetection
|
|
|
20
20
|
@api_client = api_client
|
|
21
21
|
end
|
|
22
22
|
# Identity
|
|
23
|
-
# The identity behind this credential: what it is, the organization it is scoped to, and the scopes it currently holds. `user` is present for an OAuth token and absent for an API key, which has an organization but no person behind it. `credential.kind` says which you are holding, so a client can branch without guessing from a missing field. `scopes` is what the credential may do now, so a client can check before it calls.
|
|
23
|
+
# The identity behind this credential: what it is, the organization it is scoped to, and the scopes it currently holds. `user` is present for an OAuth token and absent for an API key, which has an organization but no person behind it. `credential.kind` says which you are holding, so a client can branch without guessing from a missing field. `scopes` is what the credential may do now, so a client can check before it calls. Needs the `account.read` scope.
|
|
24
24
|
# @param [Hash] opts the optional parameters
|
|
25
25
|
# @return [Identity]
|
|
26
26
|
def account_identity(opts = {})
|
|
@@ -29,7 +29,7 @@ module VPNDetection
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Identity
|
|
32
|
-
# The identity behind this credential: what it is, the organization it is scoped to, and the scopes it currently holds. `user` is present for an OAuth token and absent for an API key, which has an organization but no person behind it. `credential.kind` says which you are holding, so a client can branch without guessing from a missing field. `scopes` is what the credential may do now, so a client can check before it calls.
|
|
32
|
+
# The identity behind this credential: what it is, the organization it is scoped to, and the scopes it currently holds. `user` is present for an OAuth token and absent for an API key, which has an organization but no person behind it. `credential.kind` says which you are holding, so a client can branch without guessing from a missing field. `scopes` is what the credential may do now, so a client can check before it calls. Needs the `account.read` scope.
|
|
33
33
|
# @param [Hash] opts the optional parameters
|
|
34
34
|
# @return [Array<(Identity, Integer, Hash)>] Identity data, response status code and response headers
|
|
35
35
|
def account_identity_with_http_info(opts = {})
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -20,7 +20,7 @@ module VPNDetection
|
|
|
20
20
|
@api_client = api_client
|
|
21
21
|
end
|
|
22
22
|
# Create
|
|
23
|
-
# Creates a key and returns its secret. Store the secret now. Reading it back later takes `reveal` and the `apikeys.reveal` scope.
|
|
23
|
+
# Creates a key and returns its secret. Store the secret now. Reading it back later takes `reveal` and the `apikeys.reveal` scope. Needs the `apikeys.manage` scope.
|
|
24
24
|
# @param account_create_apikey_request [AccountCreateApikeyRequest]
|
|
25
25
|
# @param [Hash] opts the optional parameters
|
|
26
26
|
# @return [AccountCreatedApikey]
|
|
@@ -30,7 +30,7 @@ module VPNDetection
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
# Create
|
|
33
|
-
# Creates a key and returns its secret. Store the secret now. Reading it back later takes `reveal` and the `apikeys.reveal` scope.
|
|
33
|
+
# Creates a key and returns its secret. Store the secret now. Reading it back later takes `reveal` and the `apikeys.reveal` scope. Needs the `apikeys.manage` scope.
|
|
34
34
|
# @param account_create_apikey_request [AccountCreateApikeyRequest]
|
|
35
35
|
# @param [Hash] opts the optional parameters
|
|
36
36
|
# @return [Array<(AccountCreatedApikey, Integer, Hash)>] AccountCreatedApikey data, response status code and response headers
|
|
@@ -88,7 +88,7 @@ module VPNDetection
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
# List
|
|
91
|
-
# Each key's metadata. A list never carries a secret, here or in the console: `reveal` reads one. `retrievable` says whether the secret could still be read back at all. A key issued before this product stored secrets recoverably was never kept, so `reveal` will refuse it permanently; rotating produces one that can be read.
|
|
91
|
+
# Each key's metadata. A list never carries a secret, here or in the console: `reveal` reads one. `retrievable` says whether the secret could still be read back at all. A key issued before this product stored secrets recoverably was never kept, so `reveal` will refuse it permanently; rotating produces one that can be read. Needs the `apikeys.read` scope.
|
|
92
92
|
# @param [Hash] opts the optional parameters
|
|
93
93
|
# @return [ApikeyList]
|
|
94
94
|
def account_list_apikeys(opts = {})
|
|
@@ -97,7 +97,7 @@ module VPNDetection
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# List
|
|
100
|
-
# Each key's metadata. A list never carries a secret, here or in the console: `reveal` reads one. `retrievable` says whether the secret could still be read back at all. A key issued before this product stored secrets recoverably was never kept, so `reveal` will refuse it permanently; rotating produces one that can be read.
|
|
100
|
+
# Each key's metadata. A list never carries a secret, here or in the console: `reveal` reads one. `retrievable` says whether the secret could still be read back at all. A key issued before this product stored secrets recoverably was never kept, so `reveal` will refuse it permanently; rotating produces one that can be read. Needs the `apikeys.read` scope.
|
|
101
101
|
# @param [Hash] opts the optional parameters
|
|
102
102
|
# @return [Array<(ApikeyList, Integer, Hash)>] ApikeyList data, response status code and response headers
|
|
103
103
|
def account_list_apikeys_with_http_info(opts = {})
|
|
@@ -145,7 +145,7 @@ module VPNDetection
|
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
# Reveal
|
|
148
|
-
# Returns an existing key's secret. It needs the `apikeys.reveal` scope, which `apikeys.manage` doesn't include. Refused with `NOT_RETRIEVABLE` for a key issued before we kept secrets. Rotate that key instead.
|
|
148
|
+
# Returns an existing key's secret. It needs the `apikeys.reveal` scope, which `apikeys.manage` doesn't include. Refused with `NOT_RETRIEVABLE` for a key issued before we kept secrets. Rotate that key instead. Needs the `apikeys.reveal` scope.
|
|
149
149
|
# @param id [String] The key's ID, as returned by the list endpoint. Never the key itself.
|
|
150
150
|
# @param [Hash] opts the optional parameters
|
|
151
151
|
# @return [AccountRevealedApikey]
|
|
@@ -155,7 +155,7 @@ module VPNDetection
|
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
# Reveal
|
|
158
|
-
# Returns an existing key's secret. It needs the `apikeys.reveal` scope, which `apikeys.manage` doesn't include. Refused with `NOT_RETRIEVABLE` for a key issued before we kept secrets. Rotate that key instead.
|
|
158
|
+
# Returns an existing key's secret. It needs the `apikeys.reveal` scope, which `apikeys.manage` doesn't include. Refused with `NOT_RETRIEVABLE` for a key issued before we kept secrets. Rotate that key instead. Needs the `apikeys.reveal` scope.
|
|
159
159
|
# @param id [String] The key's ID, as returned by the list endpoint. Never the key itself.
|
|
160
160
|
# @param [Hash] opts the optional parameters
|
|
161
161
|
# @return [Array<(AccountRevealedApikey, Integer, Hash)>] AccountRevealedApikey data, response status code and response headers
|
|
@@ -208,7 +208,7 @@ module VPNDetection
|
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
# Revoke
|
|
211
|
-
# Stops the key working. Revocation is soft: the key stays listed with a `revoked_at`, because the organization still owns whatever it did while it was alive.
|
|
211
|
+
# Stops the key working. Revocation is soft: the key stays listed with a `revoked_at`, because the organization still owns whatever it did while it was alive. Needs the `apikeys.manage` scope.
|
|
212
212
|
# @param id [String] The key's ID, as returned by the list endpoint. Never the key itself.
|
|
213
213
|
# @param [Hash] opts the optional parameters
|
|
214
214
|
# @return [AccountRc]
|
|
@@ -218,7 +218,7 @@ module VPNDetection
|
|
|
218
218
|
end
|
|
219
219
|
|
|
220
220
|
# Revoke
|
|
221
|
-
# Stops the key working. Revocation is soft: the key stays listed with a `revoked_at`, because the organization still owns whatever it did while it was alive.
|
|
221
|
+
# Stops the key working. Revocation is soft: the key stays listed with a `revoked_at`, because the organization still owns whatever it did while it was alive. Needs the `apikeys.manage` scope.
|
|
222
222
|
# @param id [String] The key's ID, as returned by the list endpoint. Never the key itself.
|
|
223
223
|
# @param [Hash] opts the optional parameters
|
|
224
224
|
# @return [Array<(AccountRc, Integer, Hash)>] AccountRc data, response status code and response headers
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -91,6 +91,7 @@ module VPNDetection
|
|
|
91
91
|
# Answers what is known about a single IPv4 or IPv6 address. Which fields come back is decided by the presented key; with no key, on Unlimited, the free plan, the answer is `ip`, `is_vpn`, the Tor and relay members, `is_anycast`, `hostname`, `location` and `asn`.
|
|
92
92
|
# @param ip [String] The IPv4 or IPv6 address to classify.
|
|
93
93
|
# @param [Hash] opts the optional parameters
|
|
94
|
+
# @option opts [String] :user_agent The `User-Agent` header of the request you are deciding on. With every field, on a paid plan or the trial, the answer then carries `user_agent`: the agent it names, and whether this address bears that out. Never kept, and nothing sent with a lookup feeds our data.
|
|
94
95
|
# @return [LookupResponse]
|
|
95
96
|
def lookup_ip(ip, opts = {})
|
|
96
97
|
data, _status_code, _headers = lookup_ip_with_http_info(ip, opts)
|
|
@@ -101,6 +102,7 @@ module VPNDetection
|
|
|
101
102
|
# Answers what is known about a single IPv4 or IPv6 address. Which fields come back is decided by the presented key; with no key, on Unlimited, the free plan, the answer is `ip`, `is_vpn`, the Tor and relay members, `is_anycast`, `hostname`, `location` and `asn`.
|
|
102
103
|
# @param ip [String] The IPv4 or IPv6 address to classify.
|
|
103
104
|
# @param [Hash] opts the optional parameters
|
|
105
|
+
# @option opts [String] :user_agent The `User-Agent` header of the request you are deciding on. With every field, on a paid plan or the trial, the answer then carries `user_agent`: the agent it names, and whether this address bears that out. Never kept, and nothing sent with a lookup feeds our data.
|
|
104
106
|
# @return [Array<(LookupResponse, Integer, Hash)>] LookupResponse data, response status code and response headers
|
|
105
107
|
def lookup_ip_with_http_info(ip, opts = {})
|
|
106
108
|
if @api_client.config.debugging
|
|
@@ -110,11 +112,16 @@ module VPNDetection
|
|
|
110
112
|
if @api_client.config.client_side_validation && ip.nil?
|
|
111
113
|
fail ArgumentError, "Missing the required parameter 'ip' when calling LookupWireApi.lookup_ip"
|
|
112
114
|
end
|
|
115
|
+
if @api_client.config.client_side_validation && !opts[:'user_agent'].nil? && opts[:'user_agent'].to_s.length > 1024
|
|
116
|
+
fail ArgumentError, 'invalid value for "opts[:"user_agent"]" when calling LookupWireApi.lookup_ip, the character length must be smaller than or equal to 1024.'
|
|
117
|
+
end
|
|
118
|
+
|
|
113
119
|
# resource path
|
|
114
120
|
local_var_path = '/{ip}'.sub('{ip}', CGI.escape(ip.to_s))
|
|
115
121
|
|
|
116
122
|
# query parameters
|
|
117
123
|
query_params = opts[:query_params] || {}
|
|
124
|
+
query_params[:'user_agent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?
|
|
118
125
|
|
|
119
126
|
# header parameters
|
|
120
127
|
header_params = opts[:header_params] || {}
|
|
@@ -153,6 +160,7 @@ module VPNDetection
|
|
|
153
160
|
# My IP
|
|
154
161
|
# Answers what is known about the address this request came from, which is the same answer `GET /{ip}` gives for that address: the presented key decides which fields come back, and the request counts against the same limits. The address is the one our edge observed, so a request through a proxy or a VPN reports the exit it left through rather than the machine that made it. That is usually the point of asking.
|
|
155
162
|
# @param [Hash] opts the optional parameters
|
|
163
|
+
# @option opts [String] :user_agent The `User-Agent` header of the request you are deciding on. With every field, on a paid plan or the trial, the answer then carries `user_agent`: the agent it names, and whether this address bears that out. Never kept, and nothing sent with a lookup feeds our data.
|
|
156
164
|
# @return [LookupResponse]
|
|
157
165
|
def lookup_my_ip(opts = {})
|
|
158
166
|
data, _status_code, _headers = lookup_my_ip_with_http_info(opts)
|
|
@@ -162,16 +170,22 @@ module VPNDetection
|
|
|
162
170
|
# My IP
|
|
163
171
|
# Answers what is known about the address this request came from, which is the same answer `GET /{ip}` gives for that address: the presented key decides which fields come back, and the request counts against the same limits. The address is the one our edge observed, so a request through a proxy or a VPN reports the exit it left through rather than the machine that made it. That is usually the point of asking.
|
|
164
172
|
# @param [Hash] opts the optional parameters
|
|
173
|
+
# @option opts [String] :user_agent The `User-Agent` header of the request you are deciding on. With every field, on a paid plan or the trial, the answer then carries `user_agent`: the agent it names, and whether this address bears that out. Never kept, and nothing sent with a lookup feeds our data.
|
|
165
174
|
# @return [Array<(LookupResponse, Integer, Hash)>] LookupResponse data, response status code and response headers
|
|
166
175
|
def lookup_my_ip_with_http_info(opts = {})
|
|
167
176
|
if @api_client.config.debugging
|
|
168
177
|
@api_client.config.logger.debug 'Calling API: LookupWireApi.lookup_my_ip ...'
|
|
169
178
|
end
|
|
179
|
+
if @api_client.config.client_side_validation && !opts[:'user_agent'].nil? && opts[:'user_agent'].to_s.length > 1024
|
|
180
|
+
fail ArgumentError, 'invalid value for "opts[:"user_agent"]" when calling LookupWireApi.lookup_my_ip, the character length must be smaller than or equal to 1024.'
|
|
181
|
+
end
|
|
182
|
+
|
|
170
183
|
# resource path
|
|
171
184
|
local_var_path = '/myip'
|
|
172
185
|
|
|
173
186
|
# query parameters
|
|
174
187
|
query_params = opts[:query_params] || {}
|
|
188
|
+
query_params[:'user_agent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?
|
|
175
189
|
|
|
176
190
|
# header parameters
|
|
177
191
|
header_params = opts[:header_params] || {}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -20,7 +20,7 @@ module VPNDetection
|
|
|
20
20
|
@api_client = api_client
|
|
21
21
|
end
|
|
22
22
|
# Organization
|
|
23
|
-
# The organization this credential is scoped to. A credential belongs to one organization, so this takes no ID.
|
|
23
|
+
# The organization this credential is scoped to. A credential belongs to one organization, so this takes no ID. Needs the `org.read` scope.
|
|
24
24
|
# @param [Hash] opts the optional parameters
|
|
25
25
|
# @return [AccountOrgWrap]
|
|
26
26
|
def account_org(opts = {})
|
|
@@ -29,7 +29,7 @@ module VPNDetection
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Organization
|
|
32
|
-
# The organization this credential is scoped to. A credential belongs to one organization, so this takes no ID.
|
|
32
|
+
# The organization this credential is scoped to. A credential belongs to one organization, so this takes no ID. Needs the `org.read` scope.
|
|
33
33
|
# @param [Hash] opts the optional parameters
|
|
34
34
|
# @return [Array<(AccountOrgWrap, Integer, Hash)>] AccountOrgWrap data, response status code and response headers
|
|
35
35
|
def account_org_with_http_info(opts = {})
|
|
@@ -77,7 +77,7 @@ module VPNDetection
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
# Members
|
|
80
|
-
# The members of the organization this credential is scoped to. Read-only. Members are invited by email from the console.
|
|
80
|
+
# The members of the organization this credential is scoped to. Read-only. Members are invited by email from the console. Needs the `org.read` scope.
|
|
81
81
|
# @param [Hash] opts the optional parameters
|
|
82
82
|
# @return [AccountRc]
|
|
83
83
|
def account_org_members(opts = {})
|
|
@@ -86,7 +86,7 @@ module VPNDetection
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
# Members
|
|
89
|
-
# The members of the organization this credential is scoped to. Read-only. Members are invited by email from the console.
|
|
89
|
+
# The members of the organization this credential is scoped to. Read-only. Members are invited by email from the console. Needs the `org.read` scope.
|
|
90
90
|
# @param [Hash] opts the optional parameters
|
|
91
91
|
# @return [Array<(AccountRc, Integer, Hash)>] AccountRc data, response status code and response headers
|
|
92
92
|
def account_org_members_with_http_info(opts = {})
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|
data/lib/vpndetection/client.rb
CHANGED
|
@@ -85,28 +85,37 @@ module VPNDetection
|
|
|
85
85
|
#
|
|
86
86
|
# @param retries [Integer, nil] extra attempts, for THIS call only.
|
|
87
87
|
# @param timeout [Numeric, nil] seconds each attempt may take, for THIS call only.
|
|
88
|
-
|
|
88
|
+
# @param user_agent [String, nil] the `User-Agent` of the request you are
|
|
89
|
+
# deciding on. With every field (a paid plan, or the trial) the answer then
|
|
90
|
+
# carries {Result#user_agent}: the agent it names, and whether this address
|
|
91
|
+
# bears that out. An empty one is none. An answer with one is cached apart
|
|
92
|
+
# from the address's plain answer and from another agent's. A bogon is still
|
|
93
|
+
# answered locally, with no `user_agent`.
|
|
94
|
+
# @raise [ArgumentError] for a `user_agent` that is not a String.
|
|
95
|
+
def lookup(ip, retries: nil, timeout: nil, user_agent: nil)
|
|
89
96
|
# Here as well as in the transport: a bogon or a cached answer returns before any request.
|
|
90
97
|
Transport.checked_timeout(timeout) unless timeout.nil?
|
|
91
98
|
Retries.checked_count(retries) unless retries.nil?
|
|
99
|
+
agent = Transport.checked_user_agent(user_agent)
|
|
92
100
|
# Judged, cached and sent as the IPv4 address it carries, if it is mapped.
|
|
93
101
|
ip = Bogon.unmapped(ip)
|
|
94
102
|
return Bogon.result(ip) if Bogon.bogon?(ip)
|
|
95
103
|
|
|
104
|
+
key = key_of(ip, agent)
|
|
96
105
|
loop do
|
|
97
|
-
hit = @cache&.get(
|
|
106
|
+
hit = @cache&.get(key)
|
|
98
107
|
return hit unless hit.nil?
|
|
99
108
|
|
|
100
|
-
flight, leader = board(
|
|
101
|
-
return fetch(ip, retries, timeout) if flight.nil?
|
|
109
|
+
flight, leader = board(key)
|
|
110
|
+
return fetch(ip, agent, retries, timeout) if flight.nil?
|
|
102
111
|
|
|
103
112
|
if leader
|
|
104
113
|
# Read once more now the address is boarded: a leader that landed
|
|
105
114
|
# between the miss above and boarding has already cached its answer.
|
|
106
|
-
hit = @cache.get(
|
|
107
|
-
return unboard(
|
|
115
|
+
hit = @cache.get(key)
|
|
116
|
+
return unboard(key, flight, :served, hit) unless hit.nil?
|
|
108
117
|
|
|
109
|
-
return lead(
|
|
118
|
+
return lead(key, flight) { fetch(ip, agent, retries, timeout) }
|
|
110
119
|
end
|
|
111
120
|
state, value = flight.wait
|
|
112
121
|
return value if state == :served
|
|
@@ -125,10 +134,13 @@ module VPNDetection
|
|
|
125
134
|
# Deliberately NOT cached. The cache is keyed by address, and which address
|
|
126
135
|
# this is IS the question: a machine that moves between networks would
|
|
127
136
|
# otherwise be told where it used to be.
|
|
128
|
-
|
|
137
|
+
#
|
|
138
|
+
# @param user_agent [String, nil] as {#lookup} takes it.
|
|
139
|
+
def my_ip(retries: nil, timeout: nil, user_agent: nil)
|
|
129
140
|
Retries.checked_count(retries) unless retries.nil?
|
|
141
|
+
agent = Transport.checked_user_agent(user_agent)
|
|
130
142
|
Retries.with_retries(retries || @retries) do
|
|
131
|
-
Transport.lookup_result(@transport.myip_request(timeout: timeout).run)
|
|
143
|
+
Transport.lookup_result(@transport.myip_request(timeout: timeout, user_agent: agent).run)
|
|
132
144
|
end
|
|
133
145
|
end
|
|
134
146
|
|
|
@@ -179,32 +191,47 @@ module VPNDetection
|
|
|
179
191
|
# request, and before a bogon or a cached answer is returned.
|
|
180
192
|
# @param retries [Integer, nil] extra attempts for a failed chunk, for THIS batch only.
|
|
181
193
|
# @param timeout [Numeric, nil] seconds each chunk's attempt may take, for THIS batch only.
|
|
194
|
+
# @param user_agents [Hash{String => String}, nil] the `User-Agent` to send
|
|
195
|
+
# with each address, keyed by the address as given in `ips`: as
|
|
196
|
+
# {#lookup}'s `user_agent:`, per address. An address with none, or an empty
|
|
197
|
+
# one, is looked up plainly. Where two spellings of one IPv4-mapped address
|
|
198
|
+
# carry different agents, the first given is sent.
|
|
199
|
+
# @raise [ArgumentError] for `user_agents` that is not a Hash, or an agent in
|
|
200
|
+
# it that is not a String.
|
|
182
201
|
# @return [Hash{String => Result, Error}] in the order the addresses were given
|
|
183
|
-
def lookup_batch(ips, concurrency: nil, retries: nil, timeout: nil)
|
|
202
|
+
def lookup_batch(ips, concurrency: nil, retries: nil, timeout: nil, user_agents: nil)
|
|
184
203
|
limit = concurrency || @concurrency
|
|
185
204
|
unless concurrency?(limit)
|
|
186
205
|
raise Error.new(:bad_request, "concurrency must be an Integer from 1, not #{limit.inspect}")
|
|
187
206
|
end
|
|
188
207
|
Transport.checked_timeout(timeout) unless timeout.nil?
|
|
189
208
|
Retries.checked_count(retries) unless retries.nil?
|
|
209
|
+
unless user_agents.nil? || user_agents.is_a?(Hash)
|
|
210
|
+
raise ArgumentError, "user_agents must be a Hash of address to agent, not #{user_agents.inspect}"
|
|
211
|
+
end
|
|
190
212
|
|
|
191
213
|
# An IPv4-mapped address is sent as the address it carries, once however
|
|
192
214
|
# many of its spellings were asked, and answered under each one asked.
|
|
193
215
|
asked = ips.to_a.uniq
|
|
216
|
+
agents = {}
|
|
217
|
+
asked.each do |ip|
|
|
218
|
+
agent = Transport.checked_user_agent(user_agents&.[](ip))
|
|
219
|
+
agents[Bogon.unmapped(ip)] ||= agent unless agent.nil?
|
|
220
|
+
end
|
|
194
221
|
addresses = asked.map { |ip| Bogon.unmapped(ip) }.uniq
|
|
195
222
|
answers = {}
|
|
196
223
|
pending = []
|
|
197
224
|
|
|
198
225
|
addresses.each do |ip|
|
|
199
|
-
hit = Bogon.bogon?(ip) ? Bogon.result(ip) : @cache&.get(ip)
|
|
226
|
+
hit = Bogon.bogon?(ip) ? Bogon.result(ip) : @cache&.get(key_of(ip, agents[ip]))
|
|
200
227
|
hit.nil? ? pending << ip : answers[ip] = hit
|
|
201
228
|
end
|
|
202
229
|
# Boarded before any chunk is built, so a lookup arriving meanwhile waits
|
|
203
|
-
# for this batch; an address already in flight is not sent again.
|
|
230
|
+
# for this batch; an address and agent already in flight is not sent again.
|
|
204
231
|
boarded = {}
|
|
205
232
|
joined = {}
|
|
206
233
|
pending.each do |ip|
|
|
207
|
-
flight, leader = board(ip)
|
|
234
|
+
flight, leader = board(key_of(ip, agents[ip]))
|
|
208
235
|
if leader == false
|
|
209
236
|
joined[ip] = flight
|
|
210
237
|
else
|
|
@@ -214,12 +241,12 @@ module VPNDetection
|
|
|
214
241
|
begin
|
|
215
242
|
unless boarded.empty?
|
|
216
243
|
chunks = boarded.keys.each_slice(BATCH_MAX).to_a
|
|
217
|
-
run_batch(chunks, answers, limit, retries || @retries, timeout, boarded)
|
|
244
|
+
run_batch(chunks, agents, answers, limit, retries || @retries, timeout, boarded)
|
|
218
245
|
end
|
|
219
246
|
ensure
|
|
220
|
-
boarded.each { |ip, flight| unboard(ip, flight, :abandoned) unless flight.nil? }
|
|
247
|
+
boarded.each { |ip, flight| unboard(key_of(ip, agents[ip]), flight, :abandoned) unless flight.nil? }
|
|
221
248
|
end
|
|
222
|
-
joined.each { |ip, flight| answers[ip] = joined_answer(ip, flight, retries, timeout) }
|
|
249
|
+
joined.each { |ip, flight| answers[ip] = joined_answer(ip, agents[ip], flight, retries, timeout) }
|
|
223
250
|
|
|
224
251
|
# Reinstated in input order: a hydra settles in completion order, and a
|
|
225
252
|
# caller iterating the hash should see what they passed in.
|
|
@@ -234,6 +261,13 @@ module VPNDetection
|
|
|
234
261
|
value.is_a?(Integer) && value >= 1
|
|
235
262
|
end
|
|
236
263
|
|
|
264
|
+
# What an answer is cached and shared under: the address alone, or the
|
|
265
|
+
# address and the agent sent with it, since that answer carries a verdict
|
|
266
|
+
# the plain one does not.
|
|
267
|
+
def key_of(ip, agent)
|
|
268
|
+
agent.nil? ? ip : [ip, agent]
|
|
269
|
+
end
|
|
270
|
+
|
|
237
271
|
# Concurrent misses for one address share ONE request: 5.4.2 sent one per
|
|
238
272
|
# calling thread. The first miss boards the
|
|
239
273
|
# address and every miss after it, a batch's included, waits on its Flight.
|
|
@@ -265,21 +299,21 @@ module VPNDetection
|
|
|
265
299
|
end
|
|
266
300
|
end
|
|
267
301
|
|
|
268
|
-
# [flight, true] when this caller leads the request for `
|
|
269
|
-
# false] when one is already in flight,
|
|
270
|
-
# lookup is then served, so nothing is shared.
|
|
271
|
-
def board(
|
|
302
|
+
# [flight, true] when this caller leads the request for `key`, an address
|
|
303
|
+
# or an address and agent, [flight, false] when one is already in flight,
|
|
304
|
+
# and nil without a cache: every lookup is then served, so nothing is shared.
|
|
305
|
+
def board(key)
|
|
272
306
|
return nil if @cache.nil?
|
|
273
307
|
|
|
274
308
|
@flights_lock.synchronize do
|
|
275
|
-
existing = @flights[
|
|
276
|
-
existing ? [existing, false] : [@flights[
|
|
309
|
+
existing = @flights[key]
|
|
310
|
+
existing ? [existing, false] : [@flights[key] = Flight.new, true]
|
|
277
311
|
end
|
|
278
312
|
end
|
|
279
313
|
|
|
280
|
-
# Takes `
|
|
281
|
-
def unboard(
|
|
282
|
-
@flights_lock.synchronize { @flights.delete(
|
|
314
|
+
# Takes `key` off the board and lands its flight. Returns `value`.
|
|
315
|
+
def unboard(key, flight, state, value = nil)
|
|
316
|
+
@flights_lock.synchronize { @flights.delete(key) if @flights[key].equal?(flight) }
|
|
283
317
|
flight.land(state, value)
|
|
284
318
|
value
|
|
285
319
|
end
|
|
@@ -289,39 +323,42 @@ module VPNDetection
|
|
|
289
323
|
# reaches every waiter and is cached for none; and a leader that never
|
|
290
324
|
# finishes - a killed thread, a Timeout.timeout - abandons the flight, so
|
|
291
325
|
# its waiters ask again rather than failing with it.
|
|
292
|
-
def lead(
|
|
293
|
-
unboard(
|
|
326
|
+
def lead(key, flight)
|
|
327
|
+
unboard(key, flight, :served, yield)
|
|
294
328
|
rescue Error => e
|
|
295
|
-
unboard(
|
|
329
|
+
unboard(key, flight, :failed, e)
|
|
296
330
|
raise
|
|
297
331
|
ensure
|
|
298
|
-
unboard(
|
|
332
|
+
unboard(key, flight, :abandoned)
|
|
299
333
|
end
|
|
300
334
|
|
|
301
|
-
def fetch(ip, retries, timeout)
|
|
335
|
+
def fetch(ip, agent, retries, timeout)
|
|
302
336
|
result = Retries.with_retries(retries || @retries) do
|
|
303
|
-
Transport.lookup_result(@transport.lookup_request(ip, timeout: timeout).run)
|
|
337
|
+
Transport.lookup_result(@transport.lookup_request(ip, timeout: timeout, user_agent: agent).run)
|
|
304
338
|
end
|
|
305
|
-
@cache&.set(ip, result)
|
|
339
|
+
@cache&.set(key_of(ip, agent), result)
|
|
306
340
|
result
|
|
307
341
|
end
|
|
308
342
|
|
|
309
343
|
# One hydra per call, sized for THIS call. Reusing an instance-level hydra
|
|
310
344
|
# would silently cap a per-call concurrency at the client's setting, and
|
|
311
345
|
# would not be safe to drive from two threads either. Each request is one
|
|
312
|
-
# chunk of up to 1000 addresses
|
|
313
|
-
|
|
346
|
+
# chunk of up to 1000 addresses, carrying the agents of that chunk's
|
|
347
|
+
# addresses alone.
|
|
348
|
+
def run_batch(chunks, agents, answers, concurrency, retries, timeout, boarded)
|
|
314
349
|
hydra = Typhoeus::Hydra.new(max_concurrency: concurrency)
|
|
315
350
|
attempts = Hash.new(0)
|
|
316
351
|
|
|
317
352
|
enqueue = lambda do |chunk|
|
|
318
|
-
|
|
353
|
+
sent = chunk.filter_map { |ip| [ip, agents[ip]] if agents.key?(ip) }.to_h
|
|
354
|
+
request = @transport.batch_request(chunk, timeout: timeout, user_agents: sent)
|
|
319
355
|
request.on_complete do |response|
|
|
320
|
-
outcome = settle(chunk, response, attempts, retries, enqueue)
|
|
356
|
+
outcome = settle(chunk, agents, response, attempts, retries, enqueue)
|
|
321
357
|
outcome&.each do |ip, answer|
|
|
322
358
|
answers[ip] = answer
|
|
323
359
|
flight = boarded[ip]
|
|
324
|
-
|
|
360
|
+
state = answer.is_a?(Result) ? :served : :failed
|
|
361
|
+
unboard(key_of(ip, agents[ip]), flight, state, answer) unless flight.nil?
|
|
325
362
|
end
|
|
326
363
|
end
|
|
327
364
|
hydra.queue(request)
|
|
@@ -335,11 +372,11 @@ module VPNDetection
|
|
|
335
372
|
# chunk-level failure - the call refused, the transport failing, the retries
|
|
336
373
|
# exhausted - becomes every address's error, exactly as it would have been
|
|
337
374
|
# had each been looked up alone.
|
|
338
|
-
def settle(chunk, response, attempts, retries, enqueue)
|
|
375
|
+
def settle(chunk, agents, response, attempts, retries, enqueue)
|
|
339
376
|
body = Transport.batch_body(response)
|
|
340
377
|
chunk.to_h do |ip|
|
|
341
378
|
answer = batch_answer(ip, body)
|
|
342
|
-
@cache&.set(ip, answer) if answer.is_a?(Result)
|
|
379
|
+
@cache&.set(key_of(ip, agents[ip]), answer) if answer.is_a?(Result)
|
|
343
380
|
[ip, answer]
|
|
344
381
|
end
|
|
345
382
|
rescue Error => e
|
|
@@ -355,11 +392,11 @@ module VPNDetection
|
|
|
355
392
|
|
|
356
393
|
# What a batch takes for an address another call was fetching: that call's
|
|
357
394
|
# answer or error, or, when its leader never finished, its own lookup.
|
|
358
|
-
def joined_answer(ip, flight, retries, timeout)
|
|
395
|
+
def joined_answer(ip, agent, flight, retries, timeout)
|
|
359
396
|
state, value = flight.wait
|
|
360
397
|
return value unless state == :abandoned
|
|
361
398
|
|
|
362
|
-
lookup(ip, retries: retries, timeout: timeout)
|
|
399
|
+
lookup(ip, retries: retries, timeout: timeout, user_agent: agent)
|
|
363
400
|
rescue Error => e
|
|
364
401
|
e
|
|
365
402
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The VPNDetection API: classify any IP address, and download the databases behind the answers. Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key). See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 2026.11.
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
7
|
Contact: support@vpndetection.io
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.25.0
|