vpndetection-fastify 2.0.6 → 2.0.8
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 +9 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,9 +21,9 @@ You need an API key. Create one in the [console](https://app.vpndetection.io); t
|
|
|
21
21
|
import Fastify from 'fastify';
|
|
22
22
|
import { vpndetection } from 'vpndetection-fastify';
|
|
23
23
|
|
|
24
|
-
// trustProxy
|
|
25
|
-
// address comes from" below.
|
|
26
|
-
const app = Fastify({ trustProxy:
|
|
24
|
+
// trustProxy names the proxy whose X-Forwarded-For Fastify believes; see
|
|
25
|
+
// "Where the client address comes from" below.
|
|
26
|
+
const app = Fastify({ trustProxy: '127.0.0.1' });
|
|
27
27
|
|
|
28
28
|
await app.register(vpndetection, { apiKey: process.env.VPNDETECTION_API_KEY });
|
|
29
29
|
|
|
@@ -77,12 +77,15 @@ This is the setting that decides whether any of the above works, and it is the o
|
|
|
77
77
|
|
|
78
78
|
By default the plugin uses `request.ip`, which is Fastify's own accessor. **Fastify resolves `request.ip` to the socket peer unless you built the server with `trustProxy`.** 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.
|
|
79
79
|
|
|
80
|
-
If you are behind a proxy you control, setting Fastify's own option is the right fix and everything else here follows from it:
|
|
80
|
+
If you are behind a proxy you control, setting Fastify's own option to that proxy's address is the right fix and everything else here follows from it:
|
|
81
81
|
|
|
82
82
|
```js
|
|
83
|
-
const app = Fastify({ trustProxy:
|
|
83
|
+
const app = Fastify({ trustProxy: '127.0.0.1' }); // a proxy on the same machine
|
|
84
|
+
const app = Fastify({ trustProxy: '10.0.0.0/8' }); // or your load balancer's subnet
|
|
84
85
|
```
|
|
85
86
|
|
|
87
|
+
Name your proxies rather than setting `true`. With `true`, `request.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`. Keep `true` only behind an edge you control that overwrites `X-Forwarded-For`.
|
|
88
|
+
|
|
86
89
|
For an edge that writes the address into its own header, name the header:
|
|
87
90
|
|
|
88
91
|
```js
|
|
@@ -145,7 +148,7 @@ await app.register(vpndetection, {
|
|
|
145
148
|
|
|
146
149
|
If you already hold a `VPNDetection` client, pass it as `client` and the plugin will share it rather than building a second cache.
|
|
147
150
|
|
|
148
|
-
Beyond a few million distinct visitors a day, stop calling the API per request: [download the dataset](https://vpndetection.io
|
|
151
|
+
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.
|
|
149
152
|
|
|
150
153
|
## Absent is not false
|
|
151
154
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpndetection-fastify",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Official Fastify plugin for the VPNDetection API. Detect VPNs, proxies, Tor, hosting and CDN visitors on every request.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"fastify-plugin": "^5.0.1",
|
|
48
|
-
"vpndetection": "^5.3.
|
|
48
|
+
"vpndetection": "^5.3.4"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"fastify": "4.x || 5.x"
|