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
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#VPNDetection API
|
|
3
|
+
|
|
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
|
+
|
|
6
|
+
The version of the OpenAPI document: 2026.11.22
|
|
7
|
+
Contact: support@vpndetection.io
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.25.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module VPNDetection
|
|
17
|
+
class UserAgentVerdict < ApiModelBase
|
|
18
|
+
# The agent the user agent names, such as `Googlebot` or `Chrome`; `Unknown` where it names none.
|
|
19
|
+
attr_accessor :agent
|
|
20
|
+
|
|
21
|
+
# `browser`, `inapp`, `automation`, `bot`, `ai-bot`, `http-client` or `unknown`: what kind of client the user agent says it is.
|
|
22
|
+
attr_accessor :kind
|
|
23
|
+
|
|
24
|
+
# `verified`: the agent's operator vouches for this address as it. `spoofed`: the operator of a bot that publishes its addresses, or whose registered space it uses, does not vouch for this one, or this address posed as the bot before. `unverifiable`: a bot no published list or registered space can confirm. `not_bot`: a browser, an app or a script.
|
|
25
|
+
attr_accessor :verdict
|
|
26
|
+
|
|
27
|
+
class EnumAttributeValidator
|
|
28
|
+
attr_reader :datatype
|
|
29
|
+
attr_reader :allowable_values
|
|
30
|
+
|
|
31
|
+
def initialize(datatype, allowable_values)
|
|
32
|
+
@allowable_values = allowable_values.map do |value|
|
|
33
|
+
case datatype.to_s
|
|
34
|
+
when /Integer/i
|
|
35
|
+
value.to_i
|
|
36
|
+
when /Float/i
|
|
37
|
+
value.to_f
|
|
38
|
+
else
|
|
39
|
+
value
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def valid?(value)
|
|
45
|
+
!value || allowable_values.include?(value)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
50
|
+
def self.attribute_map
|
|
51
|
+
{
|
|
52
|
+
:'agent' => :'agent',
|
|
53
|
+
:'kind' => :'kind',
|
|
54
|
+
:'verdict' => :'verdict'
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns attribute mapping this model knows about
|
|
59
|
+
def self.acceptable_attribute_map
|
|
60
|
+
attribute_map
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Returns all the JSON keys this model knows about
|
|
64
|
+
def self.acceptable_attributes
|
|
65
|
+
acceptable_attribute_map.values
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Attribute type mapping.
|
|
69
|
+
def self.openapi_types
|
|
70
|
+
{
|
|
71
|
+
:'agent' => :'String',
|
|
72
|
+
:'kind' => :'String',
|
|
73
|
+
:'verdict' => :'String'
|
|
74
|
+
}
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# List of attributes with nullable: true
|
|
78
|
+
def self.openapi_nullable
|
|
79
|
+
Set.new([
|
|
80
|
+
])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Initializes the object
|
|
84
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
85
|
+
def initialize(attributes = {})
|
|
86
|
+
if (!attributes.is_a?(Hash))
|
|
87
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `VPNDetection::UserAgentVerdict` initialize method"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
91
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
92
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
93
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
94
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `VPNDetection::UserAgentVerdict`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
95
|
+
end
|
|
96
|
+
h[k.to_sym] = v
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if attributes.key?(:'agent')
|
|
100
|
+
self.agent = attributes[:'agent']
|
|
101
|
+
else
|
|
102
|
+
self.agent = nil
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if attributes.key?(:'kind')
|
|
106
|
+
self.kind = attributes[:'kind']
|
|
107
|
+
else
|
|
108
|
+
self.kind = nil
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if attributes.key?(:'verdict')
|
|
112
|
+
self.verdict = attributes[:'verdict']
|
|
113
|
+
else
|
|
114
|
+
self.verdict = nil
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
119
|
+
# @return Array for valid properties with the reasons
|
|
120
|
+
def list_invalid_properties
|
|
121
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
122
|
+
invalid_properties = Array.new
|
|
123
|
+
if @agent.nil?
|
|
124
|
+
invalid_properties.push('invalid value for "agent", agent cannot be nil.')
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
if @kind.nil?
|
|
128
|
+
invalid_properties.push('invalid value for "kind", kind cannot be nil.')
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
if @verdict.nil?
|
|
132
|
+
invalid_properties.push('invalid value for "verdict", verdict cannot be nil.')
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
invalid_properties
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Check to see if the all the properties in the model are valid
|
|
139
|
+
# @return true if the model is valid
|
|
140
|
+
def valid?
|
|
141
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
142
|
+
return false if @agent.nil?
|
|
143
|
+
return false if @kind.nil?
|
|
144
|
+
return false if @verdict.nil?
|
|
145
|
+
verdict_validator = EnumAttributeValidator.new('String', ["verified", "spoofed", "unverifiable", "not_bot"])
|
|
146
|
+
return false unless verdict_validator.valid?(@verdict)
|
|
147
|
+
true
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Custom attribute writer method with validation
|
|
151
|
+
# @param [Object] agent Value to be assigned
|
|
152
|
+
def agent=(agent)
|
|
153
|
+
if agent.nil?
|
|
154
|
+
fail ArgumentError, 'agent cannot be nil'
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
@agent = agent
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Custom attribute writer method with validation
|
|
161
|
+
# @param [Object] kind Value to be assigned
|
|
162
|
+
def kind=(kind)
|
|
163
|
+
if kind.nil?
|
|
164
|
+
fail ArgumentError, 'kind cannot be nil'
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
@kind = kind
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
171
|
+
# @param [Object] verdict Object to be assigned
|
|
172
|
+
def verdict=(verdict)
|
|
173
|
+
@verdict = verdict
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Checks equality by comparing each attribute.
|
|
177
|
+
# @param [Object] Object to be compared
|
|
178
|
+
def ==(o)
|
|
179
|
+
return true if self.equal?(o)
|
|
180
|
+
self.class == o.class &&
|
|
181
|
+
agent == o.agent &&
|
|
182
|
+
kind == o.kind &&
|
|
183
|
+
verdict == o.verdict
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# @see the `==` method
|
|
187
|
+
# @param [Object] Object to be compared
|
|
188
|
+
def eql?(o)
|
|
189
|
+
self == o
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Calculates hash code according to all attributes.
|
|
193
|
+
# @return [Integer] Hash code
|
|
194
|
+
def hash
|
|
195
|
+
[agent, kind, verdict].hash
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Builds the object from hash
|
|
199
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
200
|
+
# @return [Object] Returns the model itself
|
|
201
|
+
def self.build_from_hash(attributes)
|
|
202
|
+
return nil unless attributes.is_a?(Hash)
|
|
203
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
204
|
+
transformed_hash = {}
|
|
205
|
+
openapi_types.each_pair do |key, type|
|
|
206
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
207
|
+
transformed_hash["#{key}"] = nil
|
|
208
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
209
|
+
# check to ensure the input is an array given that the attribute
|
|
210
|
+
# is documented as an array but the input is not
|
|
211
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
212
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
213
|
+
end
|
|
214
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
215
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
new(transformed_hash)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# Returns the object in the form of hash
|
|
222
|
+
# @return [Hash] Returns the object in the form of hash
|
|
223
|
+
def to_hash
|
|
224
|
+
hash = {}
|
|
225
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
226
|
+
value = self.send(attr)
|
|
227
|
+
if value.nil?
|
|
228
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
229
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
hash[param] = _to_hash(value)
|
|
233
|
+
end
|
|
234
|
+
hash
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
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
|
|
@@ -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/result.rb
CHANGED
|
@@ -18,15 +18,15 @@ module VPNDetection
|
|
|
18
18
|
# wire hashes with their original string keys, so `result.vpn['provider']`.
|
|
19
19
|
class Result
|
|
20
20
|
FLAGS = %w[
|
|
21
|
-
is_vpn is_hosting is_relay is_tor is_cdn is_resproxy is_dcproxy is_mobproxy
|
|
21
|
+
is_vpn is_hosting is_relay is_tor is_cdn is_bot is_resproxy is_dcproxy is_mobproxy
|
|
22
22
|
is_pubproxy is_anycast is_carrier is_satellite is_ssh is_smtp is_web is_dns_resolver
|
|
23
23
|
is_bittorrent
|
|
24
24
|
].freeze
|
|
25
25
|
|
|
26
26
|
# The detail object behind each flag that has one; `is_anycast` has none.
|
|
27
27
|
DETAILS = %w[
|
|
28
|
-
vpn hosting relay tor cdn resproxy dcproxy mobproxy pubproxy carrier satellite ssh smtp
|
|
29
|
-
bittorrent
|
|
28
|
+
vpn hosting relay tor cdn bot resproxy dcproxy mobproxy pubproxy carrier satellite ssh smtp
|
|
29
|
+
dns_resolver bittorrent
|
|
30
30
|
].freeze
|
|
31
31
|
|
|
32
32
|
# The details that are a list of rows rather than one object.
|
|
@@ -138,6 +138,19 @@ module VPNDetection
|
|
|
138
138
|
@raw['is_cdn'] == true
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
+
# Whether an automated client uses the address, such as a search engine's
|
|
142
|
+
# or an AI company's crawler, an uptime monitor, an internet scanner or a
|
|
143
|
+
# webhook sender, or nil when your plan does not include it. Every answer,
|
|
144
|
+
# with or without a key.
|
|
145
|
+
def is_bot
|
|
146
|
+
@raw['is_bot']
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# `is_bot` with an absent member read as false.
|
|
150
|
+
def bot?
|
|
151
|
+
@raw['is_bot'] == true
|
|
152
|
+
end
|
|
153
|
+
|
|
141
154
|
# Whether the address was seen in a residential proxy pool, or nil when your
|
|
142
155
|
# plan does not include it. On every paid plan.
|
|
143
156
|
def is_resproxy
|
|
@@ -299,6 +312,15 @@ module VPNDetection
|
|
|
299
312
|
@raw['cdn']
|
|
300
313
|
end
|
|
301
314
|
|
|
315
|
+
# Detail for `is_bot`: provider, provider_name, agents, categories,
|
|
316
|
+
# verified, identity, verified_by, confidence, first_seen and last_seen.
|
|
317
|
+
# agents and categories are lists, in the order served, and `[]` where none
|
|
318
|
+
# is known; verified_by is an empty string when verified is false. Every
|
|
319
|
+
# paid plan.
|
|
320
|
+
def bot
|
|
321
|
+
@raw['bot']
|
|
322
|
+
end
|
|
323
|
+
|
|
302
324
|
# Detail for `is_resproxy`. Every paid plan.
|
|
303
325
|
def resproxy
|
|
304
326
|
@raw['resproxy']
|
|
@@ -401,6 +423,19 @@ module VPNDetection
|
|
|
401
423
|
@raw['abuse']
|
|
402
424
|
end
|
|
403
425
|
|
|
426
|
+
# What the API made of the user agent the lookup sent, as a wire hash
|
|
427
|
+
# (`result.user_agent['verdict']`): agent, the agent it names (`Googlebot`,
|
|
428
|
+
# `Chrome`, `Unknown` where it names none); kind, what kind of client it says
|
|
429
|
+
# it is (`browser`, `bot`, `ai-bot` and the rest); and verdict, `verified`
|
|
430
|
+
# where the agent's operator vouches for this address, `spoofed` where it does
|
|
431
|
+
# not, `unverifiable` for a bot nothing published can confirm, or `not_bot`
|
|
432
|
+
# for a browser, an app or a script. Present only when the lookup sent an
|
|
433
|
+
# agent and the answer has every field (a paid plan, or the trial); nil on a
|
|
434
|
+
# bogon, which is answered locally.
|
|
435
|
+
def user_agent
|
|
436
|
+
@raw['user_agent']
|
|
437
|
+
end
|
|
438
|
+
|
|
404
439
|
# On answers to a key on the free plan only: false while its organization's
|
|
405
440
|
# trial of every field lasts, true once the answer has Unlimited's; nil on any
|
|
406
441
|
# other answer.
|
|
@@ -145,18 +145,24 @@ module VPNDetection
|
|
|
145
145
|
Typhoeus::Request.new(url, options)
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
# `user_agent` goes as the query parameter only when there is one: nil or
|
|
149
|
+
# empty is none. Built here rather than by the generated LookupWireApi, which
|
|
150
|
+
# refuses an agent past the spec's 1024 characters that the API itself cuts
|
|
151
|
+
# there and answers.
|
|
152
|
+
def lookup_request(ip, timeout: nil, user_agent: nil)
|
|
149
153
|
build_request(
|
|
150
154
|
:GET, LOOKUP_PATH.sub('{ip}', CGI.escape(ip.to_s)),
|
|
155
|
+
query_params: user_agent ? { user_agent: user_agent } : {},
|
|
151
156
|
header_params: { 'Accept' => 'application/json' },
|
|
152
157
|
auth_names: %w[bearerAuth apiKeyHeader apiKeyQuery],
|
|
153
158
|
timeout: timeout,
|
|
154
159
|
)
|
|
155
160
|
end
|
|
156
161
|
|
|
157
|
-
def myip_request(timeout: nil)
|
|
162
|
+
def myip_request(timeout: nil, user_agent: nil)
|
|
158
163
|
build_request(
|
|
159
164
|
:GET, MYIP_PATH,
|
|
165
|
+
query_params: user_agent ? { user_agent: user_agent } : {},
|
|
160
166
|
header_params: { 'Accept' => 'application/json' },
|
|
161
167
|
auth_names: %w[bearerAuth apiKeyHeader apiKeyQuery],
|
|
162
168
|
timeout: timeout,
|
|
@@ -189,17 +195,32 @@ module VPNDetection
|
|
|
189
195
|
request
|
|
190
196
|
end
|
|
191
197
|
|
|
192
|
-
# The one request with a body: the batch.
|
|
193
|
-
|
|
198
|
+
# The one request with a body: the batch. `user_agents`, keyed by each
|
|
199
|
+
# address as it is in `ips`, is sent only when it holds an entry, never as
|
|
200
|
+
# `{}`: the spec types it an object, never null or empty.
|
|
201
|
+
def batch_request(ips, timeout: nil, user_agents: nil)
|
|
202
|
+
body = { ips: ips }
|
|
203
|
+
body[:user_agents] = user_agents unless user_agents.nil? || user_agents.empty?
|
|
194
204
|
build_request(
|
|
195
205
|
:POST, BATCH_PATH,
|
|
196
206
|
header_params: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' },
|
|
197
|
-
body:
|
|
207
|
+
body: body,
|
|
198
208
|
auth_names: %w[bearerAuth apiKeyHeader apiKeyQuery],
|
|
199
209
|
timeout: timeout,
|
|
200
210
|
)
|
|
201
211
|
end
|
|
202
212
|
|
|
213
|
+
# The agent a call sends: nil for none, which an empty one is, as the API
|
|
214
|
+
# reads `user_agent=`. Anything but a String or nil is refused, since its
|
|
215
|
+
# text would be sent as the agent. One past the spec's 1024 characters is
|
|
216
|
+
# sent as it is: the API cuts it there and answers.
|
|
217
|
+
def self.checked_user_agent(user_agent)
|
|
218
|
+
return nil if user_agent.nil?
|
|
219
|
+
raise ArgumentError, "user_agent must be a String, not #{user_agent.inspect}" unless user_agent.is_a?(String)
|
|
220
|
+
|
|
221
|
+
user_agent.empty? ? nil : user_agent
|
|
222
|
+
end
|
|
223
|
+
|
|
203
224
|
def self.entitlement_result(response)
|
|
204
225
|
raise Error.from_transport(response) if transport_failure?(response)
|
|
205
226
|
raise Error.from_status(response.code, response.headers, response.body) unless response.success?
|
|
@@ -310,6 +331,7 @@ module VPNDetection
|
|
|
310
331
|
'LookupResponse' => %i[ip is_vpn],
|
|
311
332
|
'VpnDetail' => [],
|
|
312
333
|
'ClassDetail' => [],
|
|
334
|
+
'BotDetail' => [],
|
|
313
335
|
'ProxyDetail' => [],
|
|
314
336
|
'PubproxyDetail' => [],
|
|
315
337
|
'CarrierDetail' => [],
|
|
@@ -322,9 +344,10 @@ module VPNDetection
|
|
|
322
344
|
'BitTorrentDetail' => [],
|
|
323
345
|
'Location' => %i[continent continent_name country country_name timezone currency_code currency_name
|
|
324
346
|
currency_symbol flag_emoji flag_unicode],
|
|
325
|
-
'Asn' => %i[asn name domain type prefix],
|
|
347
|
+
'Asn' => %i[asn name domain type prefix country rpki_status],
|
|
326
348
|
'Company' => %i[name domain],
|
|
327
349
|
'AbuseContact' => %i[email],
|
|
350
|
+
'UserAgentVerdict' => %i[agent kind verdict],
|
|
328
351
|
'BatchLookupError' => %i[status error],
|
|
329
352
|
'Entitlement' => %i[org_id apikey plan usage],
|
|
330
353
|
'EntitlementApikey' => %i[id expires allowed_cidrs],
|
data/lib/vpndetection/version.rb
CHANGED
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.
|
|
4
|
+
version: 5.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mslm Dev
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- lib/vpndetection/models/batch_lookup_request.rb
|
|
85
85
|
- lib/vpndetection/models/batch_lookup_response.rb
|
|
86
86
|
- lib/vpndetection/models/bit_torrent_detail.rb
|
|
87
|
+
- lib/vpndetection/models/bot_detail.rb
|
|
87
88
|
- lib/vpndetection/models/carrier_detail.rb
|
|
88
89
|
- lib/vpndetection/models/class_detail.rb
|
|
89
90
|
- lib/vpndetection/models/client_registration.rb
|
|
@@ -121,6 +122,7 @@ files:
|
|
|
121
122
|
- lib/vpndetection/models/ssh_detail.rb
|
|
122
123
|
- lib/vpndetection/models/standing.rb
|
|
123
124
|
- lib/vpndetection/models/token_response.rb
|
|
125
|
+
- lib/vpndetection/models/user_agent_verdict.rb
|
|
124
126
|
- lib/vpndetection/models/vpn_detail.rb
|
|
125
127
|
- lib/vpndetection/models/web_detail.rb
|
|
126
128
|
- lib/vpndetection/oauth_api.rb
|