vpndetection 5.19.0 → 5.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/vpndetection/api/account_wire_api.rb +1 -1
- data/lib/vpndetection/api/api_keys_wire_api.rb +1 -1
- 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 +1 -1
- data/lib/vpndetection/api/organization_wire_api.rb +1 -1
- 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 +1 -1
- data/lib/vpndetection/models/batch_lookup_error.rb +1 -1
- data/lib/vpndetection/models/batch_lookup_request.rb +1 -1
- data/lib/vpndetection/models/batch_lookup_response.rb +1 -1
- data/lib/vpndetection/models/bit_torrent_detail.rb +3 -3
- data/lib/vpndetection/models/bot_detail.rb +5 -5
- 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 +3 -3
- 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 +1 -1
- 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 +3 -3
- data/lib/vpndetection/models/ssh_detail.rb +3 -3
- 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 +1 -1
- data/lib/vpndetection/models/vpn_detail.rb +1 -1
- data/lib/vpndetection/models/web_detail.rb +3 -3
- data/lib/vpndetection/result.rb +13 -0
- data/lib/vpndetection/transport.rb +26 -5
- data/lib/vpndetection/version.rb +1 -1
- metadata +1 -1
|
@@ -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?
|
data/lib/vpndetection/version.rb
CHANGED