vpndetection 1.0.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +171 -0
- data/lib/vpndetection/api/database_api.rb +351 -0
- data/lib/vpndetection/api/lookup_api.rb +85 -0
- data/lib/vpndetection/api_client.rb +397 -0
- data/lib/vpndetection/api_error.rb +58 -0
- data/lib/vpndetection/api_model_base.rb +88 -0
- data/lib/vpndetection/bogon.rb +60 -0
- data/lib/vpndetection/bogons.rb +67 -0
- data/lib/vpndetection/cache.rb +35 -0
- data/lib/vpndetection/client.rb +133 -0
- data/lib/vpndetection/configuration.rb +326 -0
- data/lib/vpndetection/database.rb +167 -0
- data/lib/vpndetection/errors.rb +107 -0
- data/lib/vpndetection/models/class_detail.rb +169 -0
- data/lib/vpndetection/models/dataset_checksums.rb +174 -0
- data/lib/vpndetection/models/dataset_checksums_response.rb +216 -0
- data/lib/vpndetection/models/dataset_format_size.rb +201 -0
- data/lib/vpndetection/models/dataset_list.rb +166 -0
- data/lib/vpndetection/models/dataset_metadata.rb +280 -0
- data/lib/vpndetection/models/dataset_metadata_column.rb +199 -0
- data/lib/vpndetection/models/download.rb +276 -0
- data/lib/vpndetection/models/download_list.rb +166 -0
- data/lib/vpndetection/models/error_envelope.rb +164 -0
- data/lib/vpndetection/models/licensed_dataset.rb +358 -0
- data/lib/vpndetection/models/licensed_version.rb +262 -0
- data/lib/vpndetection/models/lookup_error.rb +166 -0
- data/lib/vpndetection/models/lookup_response.rb +343 -0
- data/lib/vpndetection/models/proxy_detail.rb +199 -0
- data/lib/vpndetection/models/vpn_detail.rb +179 -0
- data/lib/vpndetection/result.rb +211 -0
- data/lib/vpndetection/retries.rb +33 -0
- data/lib/vpndetection/transport.rb +116 -0
- data/lib/vpndetection/version.rb +5 -0
- data/lib/vpndetection.rb +40 -0
- metadata +109 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2d5b803c31c66b90be11f47ec33b35212e4e86c344d68aa9174046e8ad8aa716
|
|
4
|
+
data.tar.gz: cb643393284652c75bca2ce3af3900bbc112c3b77f7d4907a0338759d8f6cb4b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 36e5bc3aff41057a0c60697cf64a3becc2cf99908b0c27b3420a70239668ef73413670db91a846448338282671544571cb95c0c43950024060763f759fada754
|
|
7
|
+
data.tar.gz: 7155eeb3668becdb69da5cec89ac63596824225d46b74e5111ff41b71abb15f8f411f5401277be6dc054a377d047c4baac609785f2994c176d1c1b6c99ae51c8
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mslm Dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# [<img src="https://s3.vpndetection.io/vpndetection-public/brand/mark.svg" alt="VPNDetection" width="24"/>](https://vpndetection.io/) VPNDetection Ruby Client Library
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/vpndetection)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
The official Ruby client library for the [VPNDetection](https://vpndetection.io) API.
|
|
7
|
+
|
|
8
|
+
The library helps you query VPNDetection's APIs for anonymity detection including VPNs, residential proxies, Tor nodes, hosting servers, CDNs, relays and more.
|
|
9
|
+
|
|
10
|
+
## Getting Started
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
gem install vpndetection
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or add it to your Gemfile:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'vpndetection'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Requires Ruby 3.1 or newer.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
**No API key needed to start.** The free tier answers `ip` and `is_vpn`, and allows 1000 requests per day per source address.
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
require 'vpndetection'
|
|
30
|
+
|
|
31
|
+
client = VPNDetection::Client.new
|
|
32
|
+
|
|
33
|
+
result = client.lookup('45.83.91.1')
|
|
34
|
+
result.is_vpn # => true
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### With an API key
|
|
38
|
+
|
|
39
|
+
An API key raises your quota, and raises your features on a paid plan. Create one in the [console](https://app.vpndetection.io), then pass it in:
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
client = VPNDetection::Client.new(api_key: ENV['VPNDETECTION_API_KEY'])
|
|
43
|
+
|
|
44
|
+
result = client.lookup('45.83.91.1')
|
|
45
|
+
result.is_vpn # => true
|
|
46
|
+
result.vpn['provider'] # => "mullvad"
|
|
47
|
+
result.is_hosting # => true
|
|
48
|
+
result.hosting['provider'] # => "M247"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Batch lookup
|
|
52
|
+
|
|
53
|
+
You can do batch lookups with a list, which parallelizes requests for you efficiently:
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
results = client.lookup_batch(['45.83.91.1', '8.8.8.8', '1.1.1.1'])
|
|
57
|
+
|
|
58
|
+
results.each do |ip, result|
|
|
59
|
+
if result.is_a?(VPNDetection::Error)
|
|
60
|
+
warn "#{ip}: #{result.message}"
|
|
61
|
+
next
|
|
62
|
+
end
|
|
63
|
+
puts "#{ip}: #{result.is_vpn}"
|
|
64
|
+
end
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Results are keyed by address, so duplicates in your list collapse into a single request and one address failing never loses the rest.
|
|
68
|
+
|
|
69
|
+
Concurrency and other variables are configurable per-call:
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
results = client.lookup_batch(many_ips, concurrency: 32, retries: 4)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Caching
|
|
76
|
+
|
|
77
|
+
Answers are cached by default, so repeat lookups of the same address are free:
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
client = VPNDetection::Client.new
|
|
81
|
+
|
|
82
|
+
result = client.lookup('45.83.91.1')
|
|
83
|
+
result.is_vpn # => true, API request
|
|
84
|
+
|
|
85
|
+
result2 = client.lookup('45.83.91.1')
|
|
86
|
+
result2.is_vpn # => true, no API request, result was cached
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
You can change the default cache variables (max size, TTL in seconds) on initialization, or even disable it:
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
client = VPNDetection::Client.new(cache_max_size: 50_000, cache_ttl: 6 * 60 * 60)
|
|
93
|
+
client_no_cache = VPNDetection::Client.new(cache: false)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Private and reserved addresses
|
|
97
|
+
|
|
98
|
+
Private, loopback, link-local, documentation and multicast addresses (and their IPv6 equivalents, including the 6to4 and Teredo ranges) can never be VPN or proxy infrastructure. The library answers them locally, so they cost no request and no quota:
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
result = client.lookup('192.168.1.1')
|
|
102
|
+
result.bogon? # => true, this answer was computed rather than served
|
|
103
|
+
result.is_vpn # => false
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The check is available on the client, which is handy when your inputs are addresses anyway:
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
client.bogon?('10.0.0.1') # => true
|
|
110
|
+
client.bogon?('8.8.8.8') # => false
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
It is also on the module itself, if you want it without a client:
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
VPNDetection.bogon?('10.0.0.1') # => true
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Errors
|
|
120
|
+
|
|
121
|
+
Failures raise a `VPNDetection::Error` carrying a `kind` and a `retryable?` flag:
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
begin
|
|
125
|
+
client.lookup('1.1.1.1')
|
|
126
|
+
rescue VPNDetection::Error => e
|
|
127
|
+
warn "#{e.kind} #{e.retryable?}: #{e.message}"
|
|
128
|
+
end
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`kind` is one of `:bad_request`, `:unauthorized`, `:forbidden`, `:rate_limited`, `:quota_exceeded`, `:server_error` or `:network`.
|
|
132
|
+
|
|
133
|
+
Note that `:rate_limited` and `:quota_exceeded` both arrive as HTTP 429 and are not the same thing. A rate limit is when the API faces extreme traffic bursts and so retrying later works; but a spent quota needs your allowance raised or the window to roll over. The library retries rate limits for you, but not if your quota is exceeded.
|
|
134
|
+
|
|
135
|
+
### Database downloads
|
|
136
|
+
|
|
137
|
+
If your key carries the `db.download` scope, the licensed datasets are available through `client.database`. A license covers a dataset FAMILY and a download names one of its versions, so the id comes from `versions`:
|
|
138
|
+
|
|
139
|
+
```ruby
|
|
140
|
+
family = client.database.list.first
|
|
141
|
+
id = family.versions.last.id
|
|
142
|
+
|
|
143
|
+
written = client.database.download(id, 'mmdb', './vpn_ip_extended_v1.mmdb')
|
|
144
|
+
url = client.database.download_url(id, 'mmdb')
|
|
145
|
+
bytes = client.database.download_bytes('cdn_ip_v1', 'csvgz')
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`download` streams straight to disk, so nothing bigger than a chunk is ever held in memory whatever the dataset 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.
|
|
149
|
+
|
|
150
|
+
### Absent is not false
|
|
151
|
+
|
|
152
|
+
Every field beyond `ip` and `is_vpn` is present when your plan includes it and `nil` when it does not. `nil` means "not in your plan"; `false` means "we checked, and no".
|
|
153
|
+
|
|
154
|
+
```ruby
|
|
155
|
+
result.hosting? # false when absent, for when you only want the flag
|
|
156
|
+
result.included?(:is_hosting) # whether your plan carries the field at all
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Other Libraries
|
|
160
|
+
|
|
161
|
+
There are official VPNDetection client libraries available for many languages including PHP, Python, Go, Java, Ruby, and many popular frameworks such as Django, Rails, and Laravel. See our GitHub at https://github.com/vpndetection-io for more.
|
|
162
|
+
|
|
163
|
+
## About VPNDetection
|
|
164
|
+
|
|
165
|
+
VPN Detection API: Accurate anonymity detection identifying VPNs, residential proxies, hosting servers, Tor nodes, CDNs, relays and more.
|
|
166
|
+
|
|
167
|
+
[<img src="https://s3.vpndetection.io/vpndetection-public/brand/mark.svg" alt="VPNDetection" width="96"/>](https://vpndetection.io/)
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#VPNDetection API
|
|
3
|
+
|
|
4
|
+
#The VPNDetection API: classify any IP address, and download the datasets behind the answers. See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 2026.09.04
|
|
7
|
+
Contact: support@vpndetection.io
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.25.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module VPNDetection
|
|
16
|
+
class DatabaseApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Checksums for one published file, to verify a download
|
|
23
|
+
# @param id [String]
|
|
24
|
+
# @param format [String]
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @return [DatasetChecksumsResponse]
|
|
27
|
+
def database_checksum(id, format, opts = {})
|
|
28
|
+
data, _status_code, _headers = database_checksum_with_http_info(id, format, opts)
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Checksums for one published file, to verify a download
|
|
33
|
+
# @param id [String]
|
|
34
|
+
# @param format [String]
|
|
35
|
+
# @param [Hash] opts the optional parameters
|
|
36
|
+
# @return [Array<(DatasetChecksumsResponse, Integer, Hash)>] DatasetChecksumsResponse data, response status code and response headers
|
|
37
|
+
def database_checksum_with_http_info(id, format, opts = {})
|
|
38
|
+
if @api_client.config.debugging
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: DatabaseApi.database_checksum ...'
|
|
40
|
+
end
|
|
41
|
+
# verify the required parameter 'id' is set
|
|
42
|
+
if @api_client.config.client_side_validation && id.nil?
|
|
43
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling DatabaseApi.database_checksum"
|
|
44
|
+
end
|
|
45
|
+
# verify the required parameter 'format' is set
|
|
46
|
+
if @api_client.config.client_side_validation && format.nil?
|
|
47
|
+
fail ArgumentError, "Missing the required parameter 'format' when calling DatabaseApi.database_checksum"
|
|
48
|
+
end
|
|
49
|
+
# verify enum value
|
|
50
|
+
allowable_values = ["csvgz", "mmdb"]
|
|
51
|
+
if @api_client.config.client_side_validation && !allowable_values.include?(format)
|
|
52
|
+
fail ArgumentError, "invalid value for \"format\", must be one of #{allowable_values}"
|
|
53
|
+
end
|
|
54
|
+
# resource path
|
|
55
|
+
local_var_path = '/api/v1/database/checksum'
|
|
56
|
+
|
|
57
|
+
# query parameters
|
|
58
|
+
query_params = opts[:query_params] || {}
|
|
59
|
+
query_params[:'id'] = id
|
|
60
|
+
query_params[:'format'] = format
|
|
61
|
+
|
|
62
|
+
# header parameters
|
|
63
|
+
header_params = opts[:header_params] || {}
|
|
64
|
+
# HTTP header 'Accept' (if needed)
|
|
65
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
66
|
+
|
|
67
|
+
# form parameters
|
|
68
|
+
form_params = opts[:form_params] || {}
|
|
69
|
+
|
|
70
|
+
# http body (model)
|
|
71
|
+
post_body = opts[:debug_body]
|
|
72
|
+
|
|
73
|
+
# return_type
|
|
74
|
+
return_type = opts[:debug_return_type] || 'DatasetChecksumsResponse'
|
|
75
|
+
|
|
76
|
+
# auth_names
|
|
77
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth', 'apiKeyQuery', 'apiKeyHeader']
|
|
78
|
+
|
|
79
|
+
new_options = opts.merge(
|
|
80
|
+
:operation => :"DatabaseApi.database_checksum",
|
|
81
|
+
:header_params => header_params,
|
|
82
|
+
:query_params => query_params,
|
|
83
|
+
:form_params => form_params,
|
|
84
|
+
:body => post_body,
|
|
85
|
+
:auth_names => auth_names,
|
|
86
|
+
:return_type => return_type
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
90
|
+
if @api_client.config.debugging
|
|
91
|
+
@api_client.config.logger.debug "API called: DatabaseApi#database_checksum\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
92
|
+
end
|
|
93
|
+
return data, status_code, headers
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# What is inside one dataset - schema, samples, row count, sizes
|
|
97
|
+
# Poll this to decide whether today's build is worth fetching: it carries `updated` and `entries` without downloading anything. No `format` parameter - one document describes every format the dataset is built in.
|
|
98
|
+
# @param id [String]
|
|
99
|
+
# @param [Hash] opts the optional parameters
|
|
100
|
+
# @return [DatasetMetadata]
|
|
101
|
+
def database_metadata(id, opts = {})
|
|
102
|
+
data, _status_code, _headers = database_metadata_with_http_info(id, opts)
|
|
103
|
+
data
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# What is inside one dataset - schema, samples, row count, sizes
|
|
107
|
+
# Poll this to decide whether today's build is worth fetching: it carries `updated` and `entries` without downloading anything. No `format` parameter - one document describes every format the dataset is built in.
|
|
108
|
+
# @param id [String]
|
|
109
|
+
# @param [Hash] opts the optional parameters
|
|
110
|
+
# @return [Array<(DatasetMetadata, Integer, Hash)>] DatasetMetadata data, response status code and response headers
|
|
111
|
+
def database_metadata_with_http_info(id, opts = {})
|
|
112
|
+
if @api_client.config.debugging
|
|
113
|
+
@api_client.config.logger.debug 'Calling API: DatabaseApi.database_metadata ...'
|
|
114
|
+
end
|
|
115
|
+
# verify the required parameter 'id' is set
|
|
116
|
+
if @api_client.config.client_side_validation && id.nil?
|
|
117
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling DatabaseApi.database_metadata"
|
|
118
|
+
end
|
|
119
|
+
# resource path
|
|
120
|
+
local_var_path = '/api/v1/database/metadata'
|
|
121
|
+
|
|
122
|
+
# query parameters
|
|
123
|
+
query_params = opts[:query_params] || {}
|
|
124
|
+
query_params[:'id'] = id
|
|
125
|
+
|
|
126
|
+
# header parameters
|
|
127
|
+
header_params = opts[:header_params] || {}
|
|
128
|
+
# HTTP header 'Accept' (if needed)
|
|
129
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
130
|
+
|
|
131
|
+
# form parameters
|
|
132
|
+
form_params = opts[:form_params] || {}
|
|
133
|
+
|
|
134
|
+
# http body (model)
|
|
135
|
+
post_body = opts[:debug_body]
|
|
136
|
+
|
|
137
|
+
# return_type
|
|
138
|
+
return_type = opts[:debug_return_type] || 'DatasetMetadata'
|
|
139
|
+
|
|
140
|
+
# auth_names
|
|
141
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth', 'apiKeyQuery', 'apiKeyHeader']
|
|
142
|
+
|
|
143
|
+
new_options = opts.merge(
|
|
144
|
+
:operation => :"DatabaseApi.database_metadata",
|
|
145
|
+
:header_params => header_params,
|
|
146
|
+
:query_params => query_params,
|
|
147
|
+
:form_params => form_params,
|
|
148
|
+
:body => post_body,
|
|
149
|
+
:auth_names => auth_names,
|
|
150
|
+
:return_type => return_type
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
154
|
+
if @api_client.config.debugging
|
|
155
|
+
@api_client.config.logger.debug "API called: DatabaseApi#database_metadata\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
156
|
+
end
|
|
157
|
+
return data, status_code, headers
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Redirect to a time-limited download URL for one dataset
|
|
161
|
+
# @param id [String] Dataset id, e.g. vpn_ip_extended_v1
|
|
162
|
+
# @param format [String] Not every dataset is built in every format. The `_provider` catalogues are keyed by provider id rather than by IP range, so no MMDB exists for them.
|
|
163
|
+
# @param [Hash] opts the optional parameters
|
|
164
|
+
# @return [nil]
|
|
165
|
+
def download_database(id, format, opts = {})
|
|
166
|
+
download_database_with_http_info(id, format, opts)
|
|
167
|
+
nil
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Redirect to a time-limited download URL for one dataset
|
|
171
|
+
# @param id [String] Dataset id, e.g. vpn_ip_extended_v1
|
|
172
|
+
# @param format [String] Not every dataset is built in every format. The `_provider` catalogues are keyed by provider id rather than by IP range, so no MMDB exists for them.
|
|
173
|
+
# @param [Hash] opts the optional parameters
|
|
174
|
+
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
|
175
|
+
def download_database_with_http_info(id, format, opts = {})
|
|
176
|
+
if @api_client.config.debugging
|
|
177
|
+
@api_client.config.logger.debug 'Calling API: DatabaseApi.download_database ...'
|
|
178
|
+
end
|
|
179
|
+
# verify the required parameter 'id' is set
|
|
180
|
+
if @api_client.config.client_side_validation && id.nil?
|
|
181
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling DatabaseApi.download_database"
|
|
182
|
+
end
|
|
183
|
+
# verify the required parameter 'format' is set
|
|
184
|
+
if @api_client.config.client_side_validation && format.nil?
|
|
185
|
+
fail ArgumentError, "Missing the required parameter 'format' when calling DatabaseApi.download_database"
|
|
186
|
+
end
|
|
187
|
+
# verify enum value
|
|
188
|
+
allowable_values = ["csvgz", "mmdb"]
|
|
189
|
+
if @api_client.config.client_side_validation && !allowable_values.include?(format)
|
|
190
|
+
fail ArgumentError, "invalid value for \"format\", must be one of #{allowable_values}"
|
|
191
|
+
end
|
|
192
|
+
# resource path
|
|
193
|
+
local_var_path = '/api/v1/database/download'
|
|
194
|
+
|
|
195
|
+
# query parameters
|
|
196
|
+
query_params = opts[:query_params] || {}
|
|
197
|
+
query_params[:'id'] = id
|
|
198
|
+
query_params[:'format'] = format
|
|
199
|
+
|
|
200
|
+
# header parameters
|
|
201
|
+
header_params = opts[:header_params] || {}
|
|
202
|
+
# HTTP header 'Accept' (if needed)
|
|
203
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
204
|
+
|
|
205
|
+
# form parameters
|
|
206
|
+
form_params = opts[:form_params] || {}
|
|
207
|
+
|
|
208
|
+
# http body (model)
|
|
209
|
+
post_body = opts[:debug_body]
|
|
210
|
+
|
|
211
|
+
# return_type
|
|
212
|
+
return_type = opts[:debug_return_type]
|
|
213
|
+
|
|
214
|
+
# auth_names
|
|
215
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth', 'apiKeyQuery', 'apiKeyHeader']
|
|
216
|
+
|
|
217
|
+
new_options = opts.merge(
|
|
218
|
+
:operation => :"DatabaseApi.download_database",
|
|
219
|
+
:header_params => header_params,
|
|
220
|
+
:query_params => query_params,
|
|
221
|
+
:form_params => form_params,
|
|
222
|
+
:body => post_body,
|
|
223
|
+
:auth_names => auth_names,
|
|
224
|
+
:return_type => return_type
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
228
|
+
if @api_client.config.debugging
|
|
229
|
+
@api_client.config.logger.debug "API called: DatabaseApi#download_database\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
230
|
+
end
|
|
231
|
+
return data, status_code, headers
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# The datasets your organization is licensed to download
|
|
235
|
+
# @param [Hash] opts the optional parameters
|
|
236
|
+
# @return [DatasetList]
|
|
237
|
+
def list_databases(opts = {})
|
|
238
|
+
data, _status_code, _headers = list_databases_with_http_info(opts)
|
|
239
|
+
data
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# The datasets your organization is licensed to download
|
|
243
|
+
# @param [Hash] opts the optional parameters
|
|
244
|
+
# @return [Array<(DatasetList, Integer, Hash)>] DatasetList data, response status code and response headers
|
|
245
|
+
def list_databases_with_http_info(opts = {})
|
|
246
|
+
if @api_client.config.debugging
|
|
247
|
+
@api_client.config.logger.debug 'Calling API: DatabaseApi.list_databases ...'
|
|
248
|
+
end
|
|
249
|
+
# resource path
|
|
250
|
+
local_var_path = '/api/v1/database/list'
|
|
251
|
+
|
|
252
|
+
# query parameters
|
|
253
|
+
query_params = opts[:query_params] || {}
|
|
254
|
+
|
|
255
|
+
# header parameters
|
|
256
|
+
header_params = opts[:header_params] || {}
|
|
257
|
+
# HTTP header 'Accept' (if needed)
|
|
258
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
259
|
+
|
|
260
|
+
# form parameters
|
|
261
|
+
form_params = opts[:form_params] || {}
|
|
262
|
+
|
|
263
|
+
# http body (model)
|
|
264
|
+
post_body = opts[:debug_body]
|
|
265
|
+
|
|
266
|
+
# return_type
|
|
267
|
+
return_type = opts[:debug_return_type] || 'DatasetList'
|
|
268
|
+
|
|
269
|
+
# auth_names
|
|
270
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth', 'apiKeyQuery', 'apiKeyHeader']
|
|
271
|
+
|
|
272
|
+
new_options = opts.merge(
|
|
273
|
+
:operation => :"DatabaseApi.list_databases",
|
|
274
|
+
:header_params => header_params,
|
|
275
|
+
:query_params => query_params,
|
|
276
|
+
:form_params => form_params,
|
|
277
|
+
:body => post_body,
|
|
278
|
+
:auth_names => auth_names,
|
|
279
|
+
:return_type => return_type
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
283
|
+
if @api_client.config.debugging
|
|
284
|
+
@api_client.config.logger.debug "API called: DatabaseApi#list_databases\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
285
|
+
end
|
|
286
|
+
return data, status_code, headers
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# Your organization's recent download attempts, newest first
|
|
290
|
+
# @param [Hash] opts the optional parameters
|
|
291
|
+
# @option opts [Integer] :limit (default to 50)
|
|
292
|
+
# @return [DownloadList]
|
|
293
|
+
def list_downloads(opts = {})
|
|
294
|
+
data, _status_code, _headers = list_downloads_with_http_info(opts)
|
|
295
|
+
data
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Your organization's recent download attempts, newest first
|
|
299
|
+
# @param [Hash] opts the optional parameters
|
|
300
|
+
# @option opts [Integer] :limit (default to 50)
|
|
301
|
+
# @return [Array<(DownloadList, Integer, Hash)>] DownloadList data, response status code and response headers
|
|
302
|
+
def list_downloads_with_http_info(opts = {})
|
|
303
|
+
if @api_client.config.debugging
|
|
304
|
+
@api_client.config.logger.debug 'Calling API: DatabaseApi.list_downloads ...'
|
|
305
|
+
end
|
|
306
|
+
if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 200
|
|
307
|
+
fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling DatabaseApi.list_downloads, must be smaller than or equal to 200.'
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# resource path
|
|
311
|
+
local_var_path = '/api/v1/database/downloads'
|
|
312
|
+
|
|
313
|
+
# query parameters
|
|
314
|
+
query_params = opts[:query_params] || {}
|
|
315
|
+
query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
|
|
316
|
+
|
|
317
|
+
# header parameters
|
|
318
|
+
header_params = opts[:header_params] || {}
|
|
319
|
+
# HTTP header 'Accept' (if needed)
|
|
320
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
321
|
+
|
|
322
|
+
# form parameters
|
|
323
|
+
form_params = opts[:form_params] || {}
|
|
324
|
+
|
|
325
|
+
# http body (model)
|
|
326
|
+
post_body = opts[:debug_body]
|
|
327
|
+
|
|
328
|
+
# return_type
|
|
329
|
+
return_type = opts[:debug_return_type] || 'DownloadList'
|
|
330
|
+
|
|
331
|
+
# auth_names
|
|
332
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth', 'apiKeyQuery', 'apiKeyHeader']
|
|
333
|
+
|
|
334
|
+
new_options = opts.merge(
|
|
335
|
+
:operation => :"DatabaseApi.list_downloads",
|
|
336
|
+
:header_params => header_params,
|
|
337
|
+
:query_params => query_params,
|
|
338
|
+
:form_params => form_params,
|
|
339
|
+
:body => post_body,
|
|
340
|
+
:auth_names => auth_names,
|
|
341
|
+
:return_type => return_type
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
345
|
+
if @api_client.config.debugging
|
|
346
|
+
@api_client.config.logger.debug "API called: DatabaseApi#list_downloads\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
347
|
+
end
|
|
348
|
+
return data, status_code, headers
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#VPNDetection API
|
|
3
|
+
|
|
4
|
+
#The VPNDetection API: classify any IP address, and download the datasets behind the answers. See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 2026.09.04
|
|
7
|
+
Contact: support@vpndetection.io
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.25.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module VPNDetection
|
|
16
|
+
class LookupApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Classify one IP address
|
|
23
|
+
# Answers what is known about a single IPv4 or IPv6 address. Which fields come back is decided by the plan behind the presented key; with no key the answer is `ip` and `is_vpn`.
|
|
24
|
+
# @param ip [String] The IPv4 or IPv6 address to classify.
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @return [LookupResponse]
|
|
27
|
+
def lookup_ip(ip, opts = {})
|
|
28
|
+
data, _status_code, _headers = lookup_ip_with_http_info(ip, opts)
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Classify one IP address
|
|
33
|
+
# Answers what is known about a single IPv4 or IPv6 address. Which fields come back is decided by the plan behind the presented key; with no key the answer is `ip` and `is_vpn`.
|
|
34
|
+
# @param ip [String] The IPv4 or IPv6 address to classify.
|
|
35
|
+
# @param [Hash] opts the optional parameters
|
|
36
|
+
# @return [Array<(LookupResponse, Integer, Hash)>] LookupResponse data, response status code and response headers
|
|
37
|
+
def lookup_ip_with_http_info(ip, opts = {})
|
|
38
|
+
if @api_client.config.debugging
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: LookupApi.lookup_ip ...'
|
|
40
|
+
end
|
|
41
|
+
# verify the required parameter 'ip' is set
|
|
42
|
+
if @api_client.config.client_side_validation && ip.nil?
|
|
43
|
+
fail ArgumentError, "Missing the required parameter 'ip' when calling LookupApi.lookup_ip"
|
|
44
|
+
end
|
|
45
|
+
# resource path
|
|
46
|
+
local_var_path = '/{ip}'.sub('{ip}', CGI.escape(ip.to_s))
|
|
47
|
+
|
|
48
|
+
# query parameters
|
|
49
|
+
query_params = opts[:query_params] || {}
|
|
50
|
+
|
|
51
|
+
# header parameters
|
|
52
|
+
header_params = opts[:header_params] || {}
|
|
53
|
+
# HTTP header 'Accept' (if needed)
|
|
54
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
55
|
+
|
|
56
|
+
# form parameters
|
|
57
|
+
form_params = opts[:form_params] || {}
|
|
58
|
+
|
|
59
|
+
# http body (model)
|
|
60
|
+
post_body = opts[:debug_body]
|
|
61
|
+
|
|
62
|
+
# return_type
|
|
63
|
+
return_type = opts[:debug_return_type] || 'LookupResponse'
|
|
64
|
+
|
|
65
|
+
# auth_names
|
|
66
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth', 'apiKeyQuery', 'apiKeyHeader']
|
|
67
|
+
|
|
68
|
+
new_options = opts.merge(
|
|
69
|
+
:operation => :"LookupApi.lookup_ip",
|
|
70
|
+
:header_params => header_params,
|
|
71
|
+
:query_params => query_params,
|
|
72
|
+
:form_params => form_params,
|
|
73
|
+
:body => post_body,
|
|
74
|
+
:auth_names => auth_names,
|
|
75
|
+
:return_type => return_type
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
79
|
+
if @api_client.config.debugging
|
|
80
|
+
@api_client.config.logger.debug "API called: LookupApi#lookup_ip\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
81
|
+
end
|
|
82
|
+
return data, status_code, headers
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|