vpndetection-express 2.0.33 → 2.0.35
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.
- package/README.md +7 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/vpndetection-express)
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
|
|
6
|
-
The official [Express](https://expressjs.com) middleware for the [VPNDetection](https://vpndetection.io) API.
|
|
6
|
+
The official [Express](https://expressjs.com) 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
|
|
8
|
+
It classifies the visitor behind each request: VPN, residential proxy, Tor, hosting, CDN, relay. It hands the answer to your handlers. Blocking is opt-in.
|
|
9
9
|
|
|
10
10
|
## Getting Started
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ npm install vpndetection-express
|
|
|
15
15
|
|
|
16
16
|
Requires Node.js 22 or newer and Express 4.18 or newer. TypeScript types are included.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
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.
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
21
|
import express from 'express';
|
|
@@ -32,7 +32,7 @@ app.get('/', (req, res) => {
|
|
|
32
32
|
});
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
By default nothing is blocked. Every request gets a `req.vpndetection` and your own code decides what
|
|
35
|
+
By default nothing is blocked. Every request gets a `req.vpndetection` and your own code decides what to do with it, since whether a VPN visitor is a problem depends on what they're doing.
|
|
36
36
|
|
|
37
37
|
## Blocking
|
|
38
38
|
|
|
@@ -68,7 +68,7 @@ app.use(vpndetection({
|
|
|
68
68
|
|
|
69
69
|
## Where the client address comes from
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
Get this setting right, or none of the above works.
|
|
72
72
|
|
|
73
73
|
By default the middleware uses `req.ip`, which is Express's own accessor. **Express resolves `req.ip` to the socket peer unless you set `trust proxy`.** So if your app sits behind nginx, a load balancer, or a CDN and you have not set it, every visitor arrives wearing your proxy's address, and that is the address that gets checked: VPN visitors pass unnoticed, and if it is a hosting address, a hosting rule blocks everyone. nginx on the same machine is `127.0.0.1` and a load balancer usually has a private address, which the middleware answers locally without a lookup, flagging nobody and logging a warning.
|
|
74
74
|
|
|
@@ -92,7 +92,7 @@ app.use(vpndetection({
|
|
|
92
92
|
}));
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
`xffIpSelector()` reads `X-Forwarded-For` directly.
|
|
95
|
+
`xffIpSelector()` reads `X-Forwarded-For` directly. The left-most entry is whatever the caller sent, since proxies append to that header, so trust it only when an edge you control overwrites it. If you know how many proxies sit in front, count from the right instead: `xffIpSelector({ depth: 1 })` is the address your nearest proxy saw.
|
|
96
96
|
|
|
97
97
|
Anything else, pass your own function. It receives the Express request and returns an address:
|
|
98
98
|
|
|
@@ -120,7 +120,7 @@ Pass `failClosed: true` to block instead. Private addresses are answered locally
|
|
|
120
120
|
|
|
121
121
|
## Cost and latency
|
|
122
122
|
|
|
123
|
-
Answers are cached per middleware 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 2500 ms by default and not retried
|
|
123
|
+
Answers are cached per middleware 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 2500 ms by default and not retried: on a request path, failing open fast beats holding a visitor while we retry. Both are adjustable, along with the cache itself:
|
|
124
124
|
|
|
125
125
|
```js
|
|
126
126
|
vpndetection({ apiKey: KEY, timeoutMs: 1000, retries: 1, cache: { max: 50000, ttlMs: 600000 } })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpndetection-express",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.35",
|
|
4
4
|
"description": "Official Express middleware for the VPNDetection API. Detect VPNs, proxies, Tor, hosting and CDN visitors on every request.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"node": ">=22"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"vpndetection": "^5.
|
|
47
|
+
"vpndetection": "^5.17.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"express": ">=4.18"
|