vpndetection-express 2.0.6 → 2.0.7
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 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ import { vpndetection } from 'vpndetection-express';
|
|
|
23
23
|
|
|
24
24
|
const app = express();
|
|
25
25
|
|
|
26
|
-
app.set('trust proxy',
|
|
26
|
+
app.set('trust proxy', 'loopback'); // your proxy; see "Where the client address comes from" below
|
|
27
27
|
app.use(vpndetection({ apiKey: process.env.VPNDETECTION_API_KEY }));
|
|
28
28
|
|
|
29
29
|
app.get('/', (req, res) => {
|
|
@@ -72,12 +72,15 @@ This is the setting that decides whether any of the above works, and it is the o
|
|
|
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 — which is a datacenter address, so a hosting rule would block all of them.
|
|
74
74
|
|
|
75
|
-
If you are behind a proxy you control, setting Express's own option is the right fix and everything else here follows from it:
|
|
75
|
+
If you are behind a proxy you control, setting Express's own option to that proxy's address is the right fix and everything else here follows from it:
|
|
76
76
|
|
|
77
77
|
```js
|
|
78
|
-
app.set('trust proxy',
|
|
78
|
+
app.set('trust proxy', 'loopback'); // a proxy on the same machine
|
|
79
|
+
app.set('trust proxy', '10.0.0.0/8'); // or your load balancer's subnet
|
|
79
80
|
```
|
|
80
81
|
|
|
82
|
+
Name your proxies rather than setting `true`. With `true`, `req.ip` is the left-most `X-Forwarded-For` entry, and the visitor writes that one: nginx, AWS's Application Load Balancer and Cloudflare all append to the header rather than replace it, so a visitor on a VPN who sends `X-Forwarded-For: 1.1.1.1` is looked up as `1.1.1.1`. A hop count such as `1` is no better, because it believes whoever connects to the app directly. Keep `true` only behind an edge you control that overwrites `X-Forwarded-For`.
|
|
83
|
+
|
|
81
84
|
For an edge that writes the address into its own header, name the header:
|
|
82
85
|
|
|
83
86
|
```js
|
|
@@ -131,7 +134,7 @@ app.use(vpndetection({ apiKey: KEY, skip: (req) => req.path.startsWith('/static'
|
|
|
131
134
|
|
|
132
135
|
If you already hold a `VPNDetection` client, pass it as `client` and the middleware will share it rather than building a second cache.
|
|
133
136
|
|
|
134
|
-
Beyond a few million distinct visitors a day, stop calling the API per request: [download the dataset](https://vpndetection.io
|
|
137
|
+
Beyond a few million distinct visitors a day, stop calling the API per request: [download the dataset](https://vpndetection.io/#databases) and look addresses up locally instead.
|
|
135
138
|
|
|
136
139
|
## Absent is not false
|
|
137
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpndetection-express",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
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.3.
|
|
47
|
+
"vpndetection": "^5.3.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"express": ">=4.18"
|