vpndetection-rails 2.1.23 → 2.1.25

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: e7d98950a71884abfad45b38c6c366d4e580896bd30ebe2e8818dff76d57b7ec
4
- data.tar.gz: ce362b261ffdb7bac10dd72fe3fff04fed81e8948ab342409073fb57afd83c4c
3
+ metadata.gz: d32eb7fab945784a513946647d35922a2149e3e8877b12611c3266b918c916dc
4
+ data.tar.gz: b32f52d52f36c8532a41c9dc1d67af768d88799a93a713ba59d56fb0fc45b1ea
5
5
  SHA512:
6
- metadata.gz: 2bd02b2e08f446198d2738194a0ea6ac2070648fdcab6b0411d32abe1ffb5a72398a47db4b5ee152ce0657b26010907ac5605d412aee84004024e98b162d13a4
7
- data.tar.gz: 7f363356b8ac3e6a4d7006e8e146a72738cd6a35e4fc6512bbedb52a4327192a2eed30b81ce2eaceebcfc91cfc39521084da03eec6078d6cbba3f4bf5228cabb
6
+ metadata.gz: 4afe0a2650817d62e2300e47f3ee5fdac01901b5dbcce1898d70805f6826b35c3e1279b32ff1d4c2208bb7609000244f38bff1bcf7b2a04bf849dd340ad7f153
7
+ data.tar.gz: 763b5e626cc8c4e340173f856afeed657b7960bb36eda8173fca4cdf29e4c09b4ddd3c0d8eda6c50f05c733fef4bc1758d361b06a1020d79085fb6e236d62c25
data/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  [![Gem](https://img.shields.io/gem/v/vpndetection-rails.svg)](https://rubygems.org/gems/vpndetection-rails)
4
4
  [![license](https://img.shields.io/github/license/vpndetection-io/sdk-ruby-rails.svg)](LICENSE)
5
5
 
6
- The official Rails middleware for the [VPNDetection](https://vpndetection.io) API.
6
+ The official Rails middleware for the [VPNDetection](https://vpndetection.io) API: it checks each visitor's IP for VPN, Tor and proxy use, and can block them with a 403.
7
7
 
8
- It classifies the visitor behind each request — VPN, residential proxy, Tor, hosting, CDN, relay — and hands the answer to your controllers. Blocking is opt-in.
8
+ It classifies the visitor behind each request as VPN, residential proxy, Tor, hosting, CDN or relay, and hands the answer to your controllers. Blocking is opt-in.
9
9
 
10
10
  It is Rack middleware, so it works in Sinatra, Hanami, Roda or a bare Rack app too; the Railtie is only what saves a Rails user from inserting it by hand.
11
11
 
@@ -15,9 +15,9 @@ It is Rack middleware, so it works in Sinatra, Hanami, Roda or a bare Rack app t
15
15
  bundle add vpndetection-rails
16
16
  ```
17
17
 
18
- Requires Ruby 3.3 or newer.
18
+ Requires Ruby 3.3 or newer, and libcurl at runtime, which the `curl` package brings on Debian and Alpine. The Dockerfile Rails generates already installs it.
19
19
 
20
- You need an API key on a paid plan. Create one in the [console](https://app.vpndetection.io); without one a lookup is on Unlimited, the free plan, and leaves out the hosting, CDN and proxy flags, so a paid plan is what makes this usable in production rather than optional. A free account tries every field, 100 lookups a day.
20
+ No API key needed to start. Without one, a lookup is on Unlimited, the free plan, which answers VPN, Tor and relay detection with no daily or monthly cap. A paid plan's key adds the hosting, CDN and proxy flags and the provider behind each flag: create one in the [console](https://app.vpndetection.io). A free account tries every field.
21
21
 
22
22
  ```ruby
23
23
  # config/application.rb
@@ -39,7 +39,7 @@ In a non-Rails Rack app, insert it yourself:
39
39
  use VPNDetection::Rails::Middleware, api_key: ENV["VPNDETECTION_API_KEY"]
40
40
  ```
41
41
 
42
- By default nothing is blocked. Every request gets an answer and your own code decides what that means — which is usually what you want, because whether a VPN visitor is a problem depends entirely on what they are doing.
42
+ By default nothing is blocked. Every request gets an answer and your own code decides what to do with it, since whether a VPN visitor is a problem depends on what they're doing.
43
43
 
44
44
  ## Blocking
45
45
 
@@ -68,9 +68,9 @@ on_blocked: ->(request, lookup) { [303, { "location" => "/no-vpn" }, []] }
68
68
 
69
69
  ## Where the client address comes from
70
70
 
71
- This is the setting that decides whether any of the above works, and it is the one thing only you can get right.
71
+ Get this setting right, or none of the above works.
72
72
 
73
- **In Rails**, the default reads `env["action_dispatch.remote_ip"]` — the answer `ActionDispatch::RemoteIp` computed from `X-Forwarded-For` minus your `config.action_dispatch.trusted_proxies`. That is the right fix behind a load balancer: tell Rails which proxies are yours and it resolves the visitor for you. `Rack::Request#ip` does *not* read that entry, so reading Rails' own is what makes your `trusted_proxies` mean anything here. **With nothing in front of the app server, that default can be forged**: `RemoteIp` believes `X-Forwarded-For` without checking that the connection came from a proxy, so any visitor picks the address that gets looked up. There, pass `ip_selector: ->(request) { request.ip }`. The middleware warns once when it sees that setup: a request carrying `X-Forwarded-For`, `Client-IP` or `Forwarded` from a public address outside `trusted_proxies`.
73
+ **In Rails**, the default reads `env["action_dispatch.remote_ip"]`, the answer `ActionDispatch::RemoteIp` computed from `X-Forwarded-For` minus your `config.action_dispatch.trusted_proxies`. That is the right fix behind a load balancer: tell Rails which proxies are yours and it resolves the visitor for you. `Rack::Request#ip` does *not* read that entry, so reading Rails' own is what makes your `trusted_proxies` mean anything here. **With nothing in front of the app server, that default can be forged**: `RemoteIp` believes `X-Forwarded-For` without checking that the connection came from a proxy, so any visitor picks the address that gets looked up. There, pass `ip_selector: ->(request) { request.ip }`. The middleware warns once when it sees that setup: a request carrying `X-Forwarded-For`, `Client-IP` or `Forwarded` from a public address outside `trusted_proxies`.
74
74
 
75
75
  **In a bare Rack app** there is no such entry and the default falls back to `Rack::Request#ip`. Rack's `ip` returns the connecting address, `REMOTE_ADDR`, unless that is a trusted proxy, which by default means a loopback or private address. Only then does it read the forwarding headers, and it takes the right-most entry that is not a trusted proxy. The test suite pins both. Behind an edge on a public address, or one that appends rather than overwrites, name your edge's header instead:
76
76
 
@@ -78,7 +78,7 @@ This is the setting that decides whether any of the above works, and it is the o
78
78
  ip_selector: VPNDetection::Rails.header_ip_selector("CF-Connecting-IP")
79
79
  ```
80
80
 
81
- `VPNDetection::Rails.xff_ip_selector` reads `X-Forwarded-For` directly, and `xff_ip_selector(1)` counts one trusted hop from the right. Anything else, pass your own callable — it receives the Rack request and returns an address.
81
+ `VPNDetection::Rails.xff_ip_selector` reads `X-Forwarded-For` directly, and `xff_ip_selector(1)` counts one trusted hop from the right. Anything else, pass your own callable: it receives the Rack request and returns an address.
82
82
 
83
83
  **Behind a proxy that writes only `X-Forwarded-For`, a visitor's own `Forwarded` header names the address.** Rack 3 reads `Forwarded` first, for `Rack::Request#ip` and Rails' `remote_ip` alike, and nginx passes a visitor's copy through untouched, so a request sending `Forwarded: for=1.1.1.1` is looked up as `1.1.1.1`. Clear the header at the proxy, `proxy_set_header Forwarded "";` in nginx, or tell Rack to read `X-Forwarded-For` alone at the top of `config.ru`:
84
84
 
@@ -96,7 +96,7 @@ The request is let through, and the reason is on `lookup.error`. Our outage shou
96
96
 
97
97
  ## Cost and latency
98
98
 
99
- Answers are cached for an hour, so a returning visitor costs nothing, and private addresses never leave the process. A cache miss is one request to our API, bounded at 2.5 seconds by default and not retried — on a request path, failing open quickly beats holding a visitor while we try again.
99
+ Answers are cached for an hour, so a returning visitor costs nothing, and private addresses never leave the process. A cache miss is one request to our API, bounded at 2.5 seconds by default and not retried: on a request path, failing open fast beats holding a visitor while we retry.
100
100
 
101
101
  Files in `public/`, compiled assets included, never reach the middleware: `ActionDispatch::Static` answers them first, so they cost no lookup. Skip the routes you do not care about:
102
102
 
@@ -108,7 +108,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
108
108
 
109
109
  ## Absent is not false
110
110
 
111
- Unlimited, with a key or without one, leaves out `is_hosting`, `is_cdn` and the four proxy flags, and of the detail behind each flag it answers only Tor's and relay's. A member your plan does not include is `nil`, which means "not in your plan" rather than "checked, and no" — and Ruby makes that easy to lose, since `nil` and `false` are both falsy.
111
+ Unlimited, with a key or without one, leaves out `is_hosting`, `is_cdn` and the four proxy flags, and of the detail behind each flag it answers only Tor's and relay's. A member your plan does not include is `nil`, which means "not in your plan" rather than "checked, and no". Ruby makes that easy to lose, since `nil` and `false` are both falsy.
112
112
 
113
113
  ```ruby
114
114
  lookup.result.hosting? # true or false, never nil
@@ -2,6 +2,6 @@
2
2
 
3
3
  module VPNDetection
4
4
  module Rails
5
- VERSION = '2.1.23'
5
+ VERSION = '2.1.25'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpndetection-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.23
4
+ version: 2.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mslm Dev
@@ -29,7 +29,7 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 5.17.0
32
+ version: 5.18.0
33
33
  - - "<"
34
34
  - !ruby/object:Gem::Version
35
35
  version: '6'
@@ -39,7 +39,7 @@ dependencies:
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 5.17.0
42
+ version: 5.18.0
43
43
  - - "<"
44
44
  - !ruby/object:Gem::Version
45
45
  version: '6'