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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -0
  3. data/lib/vpndetection/api/account_wire_api.rb +1 -1
  4. data/lib/vpndetection/api/api_keys_wire_api.rb +1 -1
  5. data/lib/vpndetection/api/authorization_wire_api.rb +1 -1
  6. data/lib/vpndetection/api/database_wire_api.rb +1 -1
  7. data/lib/vpndetection/api/entitlement_wire_api.rb +1 -1
  8. data/lib/vpndetection/api/lookup_wire_api.rb +1 -1
  9. data/lib/vpndetection/api/organization_wire_api.rb +1 -1
  10. data/lib/vpndetection/api_client.rb +1 -1
  11. data/lib/vpndetection/api_error.rb +1 -1
  12. data/lib/vpndetection/api_model_base.rb +1 -1
  13. data/lib/vpndetection/client.rb +78 -41
  14. data/lib/vpndetection/configuration.rb +1 -1
  15. data/lib/vpndetection/middleware/core.rb +61 -5
  16. data/lib/vpndetection/models/abuse_contact.rb +1 -1
  17. data/lib/vpndetection/models/account_create_apikey_request.rb +1 -1
  18. data/lib/vpndetection/models/account_created_apikey.rb +1 -1
  19. data/lib/vpndetection/models/account_org.rb +1 -1
  20. data/lib/vpndetection/models/account_org_ref.rb +1 -1
  21. data/lib/vpndetection/models/account_org_wrap.rb +1 -1
  22. data/lib/vpndetection/models/account_rc.rb +1 -1
  23. data/lib/vpndetection/models/account_revealed_apikey.rb +1 -1
  24. data/lib/vpndetection/models/account_user.rb +1 -1
  25. data/lib/vpndetection/models/apikey_detail.rb +1 -1
  26. data/lib/vpndetection/models/apikey_list.rb +1 -1
  27. data/lib/vpndetection/models/asn.rb +1 -1
  28. data/lib/vpndetection/models/batch_lookup_error.rb +1 -1
  29. data/lib/vpndetection/models/batch_lookup_request.rb +1 -1
  30. data/lib/vpndetection/models/batch_lookup_response.rb +1 -1
  31. data/lib/vpndetection/models/bit_torrent_detail.rb +3 -3
  32. data/lib/vpndetection/models/bot_detail.rb +5 -5
  33. data/lib/vpndetection/models/carrier_detail.rb +1 -1
  34. data/lib/vpndetection/models/class_detail.rb +1 -1
  35. data/lib/vpndetection/models/client_registration.rb +1 -1
  36. data/lib/vpndetection/models/client_registration_request.rb +1 -1
  37. data/lib/vpndetection/models/company.rb +1 -1
  38. data/lib/vpndetection/models/database.rb +1 -1
  39. data/lib/vpndetection/models/database_checksums_response.rb +1 -1
  40. data/lib/vpndetection/models/database_format.rb +1 -1
  41. data/lib/vpndetection/models/database_format_size.rb +1 -1
  42. data/lib/vpndetection/models/database_list.rb +1 -1
  43. data/lib/vpndetection/models/database_metadata.rb +1 -1
  44. data/lib/vpndetection/models/database_metadata_column.rb +1 -1
  45. data/lib/vpndetection/models/database_version.rb +1 -1
  46. data/lib/vpndetection/models/db_checksums.rb +1 -1
  47. data/lib/vpndetection/models/device_authorization.rb +1 -1
  48. data/lib/vpndetection/models/dns_resolver_detail.rb +3 -3
  49. data/lib/vpndetection/models/download.rb +1 -1
  50. data/lib/vpndetection/models/download_list.rb +1 -1
  51. data/lib/vpndetection/models/entitlement.rb +1 -1
  52. data/lib/vpndetection/models/entitlement_apikey.rb +1 -1
  53. data/lib/vpndetection/models/entitlement_error.rb +1 -1
  54. data/lib/vpndetection/models/entitlement_plan.rb +1 -1
  55. data/lib/vpndetection/models/entitlement_usage.rb +1 -1
  56. data/lib/vpndetection/models/error_envelope.rb +1 -1
  57. data/lib/vpndetection/models/identity.rb +1 -1
  58. data/lib/vpndetection/models/location.rb +1 -1
  59. data/lib/vpndetection/models/lookup_error.rb +1 -1
  60. data/lib/vpndetection/models/lookup_response.rb +1 -1
  61. data/lib/vpndetection/models/oauth_error.rb +1 -1
  62. data/lib/vpndetection/models/oauth_metadata.rb +1 -1
  63. data/lib/vpndetection/models/proxy_detail.rb +1 -1
  64. data/lib/vpndetection/models/pubproxy_detail.rb +1 -1
  65. data/lib/vpndetection/models/satellite_detail.rb +1 -1
  66. data/lib/vpndetection/models/smtp_detail.rb +3 -3
  67. data/lib/vpndetection/models/ssh_detail.rb +3 -3
  68. data/lib/vpndetection/models/standing.rb +1 -1
  69. data/lib/vpndetection/models/token_response.rb +1 -1
  70. data/lib/vpndetection/models/user_agent_verdict.rb +1 -1
  71. data/lib/vpndetection/models/vpn_detail.rb +1 -1
  72. data/lib/vpndetection/models/web_detail.rb +3 -3
  73. data/lib/vpndetection/result.rb +13 -0
  74. data/lib/vpndetection/transport.rb +26 -5
  75. data/lib/vpndetection/version.rb +1 -1
  76. metadata +1 -1
@@ -145,18 +145,24 @@ module VPNDetection
145
145
  Typhoeus::Request.new(url, options)
146
146
  end
147
147
 
148
- def lookup_request(ip, timeout: nil)
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
- def batch_request(ips, timeout: nil)
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: { ips: ips },
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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VPNDetection
4
- VERSION = '5.19.0'
4
+ VERSION = '5.20.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpndetection
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.19.0
4
+ version: 5.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mslm Dev