ipinfo-rails 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c61ceb239c2e2253d2a2bf51dca8ef998cefbd974a4ecc9e30845ff4b6e00ba
4
- data.tar.gz: 44b82b211f9e4a25bbef9ed8e3ee62066773539d5f0030d57585aba3acb6a5b3
3
+ metadata.gz: b8540a5ad2a5b468813f8bcab30fa9f09d783ccdd4b03bce03b6e029904e9cc4
4
+ data.tar.gz: a28a3e886ff40cc21029f70c29d4e677379a0f06cfbc6a61bf19268b4875cbb0
5
5
  SHA512:
6
- metadata.gz: 429e3ef5365e9352d5f975357e329c78ec787df5810d90f812b22031bd0ae5f3738ae842ed759d61f2e031a3b404c1d8e4509b5ab39af78696fbec97c1bd0226
7
- data.tar.gz: fc341a7dc64b6594186665fc0bcb483f6dfcab254f849dc9e9d1aff686619362ca23c2253b23b9dd765d77f5bcd6c019f786ad58371e0821744351c13343036b
6
+ metadata.gz: 451429e2d9fe254f2c99b98dbdf9954ad5879c2b65804f376462ab69be62a4514878cf8c53e4d70959079a9fc85b6c4baea171be9b526abcccb8f14db3e351e1
7
+ data.tar.gz: 97a87924479bd46f5eb2bdc36fe9a139ab02ac0b28980d72097ad5bcc16c36962be219bf3d5f42270a528a9c5ffdc7fad2d34efa474483b9e2cd4a1d2cbdb805
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gemspec
6
6
 
7
7
  group :development do
8
8
  gem 'bundler'
9
- gem 'minitest'
9
+ gem 'minitest', '< 6'
10
10
  gem 'minitest-reporters'
11
11
  gem 'rake'
12
12
  gem 'rubocop'
data/README.md CHANGED
@@ -21,30 +21,30 @@ The library also supports the Lite API, see the [Lite API section](#lite-api) fo
21
21
 
22
22
  1. Option 1) Add this line to your application's Gemfile:
23
23
 
24
- ```ruby
25
- gem 'ipinfo-rails'
26
- ```
24
+ ```ruby
25
+ gem 'ipinfo-rails'
26
+ ```
27
27
 
28
- Then execute:
28
+ Then execute:
29
29
 
30
- ```bash
31
- $ bundle install
32
- ```
30
+ ```bash
31
+ $ bundle install
32
+ ```
33
33
 
34
- Option 2) Install it yourself by running the following command:
34
+ Option 2) Install it yourself by running the following command:
35
35
 
36
- ```bash
37
- $ gem install ipinfo-rails
38
- ```
36
+ ```bash
37
+ $ gem install ipinfo-rails
38
+ ```
39
39
 
40
40
  1. Open your `config/environment.rb` file or your preferred file in the `config/environment` directory. Add the following code to your chosen configuration file.
41
41
 
42
- ```ruby
43
- require 'ipinfo-rails'
44
- config.middleware.use(IPinfoMiddleware, {token: "<your_token>"})
45
- ```
42
+ ```ruby
43
+ require 'ipinfo-rails'
44
+ config.middleware.use(IPinfoMiddleware, {token: "<your_token>"})
45
+ ```
46
46
 
47
- Note: if editing `config/environment.rb`, this needs to come before `Rails.application.initialize!` and with `Rails.application.` prepended to `config`, otherwise you'll get runtime errors.
47
+ Note: if editing `config/environment.rb`, this needs to come before `Rails.application.initialize!` and with `Rails.application.` prepended to `config`, otherwise you'll get runtime errors.
48
48
 
49
49
  1. Restart your development server.
50
50
 
@@ -120,7 +120,7 @@ request.env['ipinfo'].all ==
120
120
 
121
121
  ## Configuration
122
122
 
123
- In addition to the steps listed in the Installation section, it is possible to configure the library with more detail. The following arguments are allowed and are described in detail below.
123
+ In addition to the steps listed in the Installation section, it is possible to configure the library with more detail. The following arguments are allowed and are described in detail below.
124
124
 
125
125
  ```ruby
126
126
  require 'ipinfo-rails/ip_selector/xforwarded_ip_selector'
@@ -231,10 +231,10 @@ config.middleware.use(IPinfoMiddleware, {:countries => <path_to_settings_file>})
231
231
 
232
232
  By default, `ipinfo-rails` filters out requests that have `bot` or `spider` in the user-agent. Instead of looking up IP address data for these requests, the `request.env['ipinfo']` attribute is set to `nil`. This is to prevent you from unnecessarily using up requests on non-user traffic.
233
233
 
234
- To set your own filtering rules, *thereby replacing the default filter*, you can set `:filter` to your own, custom callable function which satisfies the following rules:
234
+ To set your own filtering rules, _thereby replacing the default filter_, you can set `:filter` to your own, custom callable function which satisfies the following rules:
235
235
 
236
236
  - Accepts one request.
237
- - Returns *True to filter out, False to allow lookup*
237
+ - Returns _True to filter out, False to allow lookup_
238
238
 
239
239
  To use your own filter rules:
240
240
 
@@ -259,6 +259,45 @@ require 'ipinfo-rails'
259
259
  config.middleware.use(IPinfoLiteMiddleware, {token: "<your_token>"})
260
260
  ```
261
261
 
262
+ ## Core API
263
+
264
+ The library also supports the [Core API](https://ipinfo.io/developers/data-types#core-data), which provides city-level geolocation with nested geo and AS objects. Authentication with your token is required.
265
+
266
+ ```ruby
267
+ require 'ipinfo-rails'
268
+ config.middleware.use(IPinfoCoreMiddleware, {token: "<your_token>"})
269
+ ```
270
+
271
+ ## Plus API
272
+
273
+ The library also supports the [Plus API](https://ipinfo.io/developers/data-types#plus-data), which provides enhanced data including mobile carrier info and privacy detection. Authentication with your token is required.
274
+
275
+ ```ruby
276
+ require 'ipinfo-rails'
277
+ config.middleware.use(IPinfoPlusMiddleware, {token: "<your_token>"})
278
+ ```
279
+
280
+ ## Residential Proxy API
281
+
282
+ The library also supports the [Residential Proxy API](https://ipinfo.io/developers/residential-proxy-api), which allows you to check if an IP address is a residential proxy. Authentication with your token is required.
283
+
284
+ ```ruby
285
+ require 'ipinfo-rails'
286
+ config.middleware.use(IPinfoResproxyMiddleware, {token: "<your_token>"})
287
+ ```
288
+
289
+ The residential proxy details will be available through `request.env['ipinfo_resproxy']`:
290
+
291
+ ```ruby
292
+ resproxy = request.env['ipinfo_resproxy']
293
+ if resproxy
294
+ resproxy.ip # 175.107.211.204
295
+ resproxy.last_seen # 2025-01-20
296
+ resproxy.percent_days_seen # 0.85
297
+ resproxy.service # Bright Data
298
+ end
299
+ ```
300
+
262
301
  ## Other Libraries
263
302
 
264
303
  There are official IPinfo client libraries available for many languages including PHP, Go, Java, Ruby, and many popular frameworks such as Django, Rails, and Laravel. There are also many third-party libraries and integrations available for our API.
data/ipinfo-rails.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.homepage = 'https://ipinfo.io'
22
22
  s.license = 'Apache-2.0'
23
23
 
24
- s.add_dependency 'IPinfo', '~> 2.4'
24
+ s.add_dependency 'IPinfo', '~> 2.5'
25
25
  s.add_dependency 'rack', '~> 2.0'
26
26
 
27
27
  s.add_development_dependency 'mocha', '~> 2.7'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IPinfoRails
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
data/lib/ipinfo-rails.rb CHANGED
@@ -135,3 +135,33 @@ class IPinfoPlusMiddleware
135
135
  @app.call(env)
136
136
  end
137
137
  end
138
+
139
+ class IPinfoResproxyMiddleware
140
+ def initialize(app, options = {})
141
+ @app = app
142
+ @token = options.fetch(:token, nil)
143
+ @ipinfo = IPinfo.create(@token, options)
144
+ @filter = options.fetch(:filter, nil)
145
+ @ip_selector = options.fetch(:ip_selector, DefaultIPSelector)
146
+ end
147
+
148
+ def call(env)
149
+ env['called'] = 'yes'
150
+ request = Rack::Request.new(env)
151
+ ip_selector = @ip_selector.new(request)
152
+ filtered = if @filter.nil?
153
+ is_bot(request)
154
+ else
155
+ @filter.call(request)
156
+ end
157
+
158
+ if filtered
159
+ env['ipinfo_resproxy'] = nil
160
+ else
161
+ ip = ip_selector.get_ip
162
+ env['ipinfo_resproxy'] = @ipinfo.resproxy(ip)
163
+ end
164
+
165
+ @app.call(env)
166
+ end
167
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipinfo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - IPinfo releases
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-25 00:00:00.000000000 Z
11
+ date: 2026-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: IPinfo
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: '2.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.4'
26
+ version: '2.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement