node-red-contrib-ipgeolocation 1.0.1 → 1.1.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.
- package/README.md +51 -13
- package/nodes/ipgeo-bulk.html +1 -0
- package/nodes/ipgeo-lookup.html +1 -0
- package/nodes/lib/api-client.js +1 -1
- package/package.json +21 -7
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://nodejs.org)
|
|
9
9
|
[](./LICENSE)
|
|
10
10
|
|
|
11
|
-
A complete, production-ready set of **Node-RED IP geolocation nodes**. Look up the country, city, latitude, and longitude of any IP address or domain, score IPs for proxy, VPN,
|
|
11
|
+
A complete, production-ready set of **Node-RED IP geolocation nodes**. Look up the country, city, latitude, and longitude of any IP address or domain, score IPs for proxy, VPN, Tor, and bot risk, resolve ASN and abuse-contact data, parse user-agent strings, and fetch timezone and astronomy data, all from low-code Node-RED flows.
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -37,11 +37,11 @@ A complete, production-ready set of **Node-RED IP geolocation nodes**. Look up t
|
|
|
37
37
|
|
|
38
38
|
- **Single IP geolocation:** resolve country, region, city, latitude, longitude, currency, and timezone for any IPv4, IPv6, or domain.
|
|
39
39
|
- **Bulk IP geolocation:** process up to 50,000 IP addresses in one request.
|
|
40
|
-
- **IP security and threat intelligence:** detect proxy, VPN,
|
|
40
|
+
- **IP security and threat intelligence:** detect proxy, VPN, Tor, bot, and threat scores for fraud prevention and access control.
|
|
41
41
|
- **Bulk security lookup:** score large IP lists in a single call.
|
|
42
42
|
- **Abuse contact lookup:** retrieve the abuse email, phone, and owning organization for an IP.
|
|
43
43
|
- **ASN lookup:** resolve Autonomous System details by IP or AS number.
|
|
44
|
-
- **
|
|
44
|
+
- **Time Zone API:** get timezone data by name, IP, coordinates, city, IATA code, ICAO code, or UN/LOCODE.
|
|
45
45
|
- **Astronomy API:** sunrise, sunset, moonrise, moonset, twilight phases, moon phase, and solar and lunar positions by coordinates, address, or IP.
|
|
46
46
|
- **User-agent parser:** identify browser, device, OS, and engine from a user-agent string.
|
|
47
47
|
- **Developer friendly:** dynamic `msg`, `flow`, and `global` inputs, an optional dedicated error output, automatic retries with exponential backoff, secure credential storage, and per-request credit reporting.
|
|
@@ -91,6 +91,13 @@ cd ~/.node-red
|
|
|
91
91
|
npm install node-red-contrib-ipgeolocation
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
For an existing installation, update the package and refresh its HTTP dependencies in the Node-RED user directory:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install node-red-contrib-ipgeolocation@latest
|
|
98
|
+
npm update axios follow-redirects
|
|
99
|
+
```
|
|
100
|
+
|
|
94
101
|
Restart Node-RED. All ten nodes appear under the **IPGeolocation** category in the palette.
|
|
95
102
|
|
|
96
103
|
---
|
|
@@ -159,7 +166,7 @@ Include modules:
|
|
|
159
166
|
|
|
160
167
|
| Module | Extra credits | Adds |
|
|
161
168
|
|--------|:---:|------|
|
|
162
|
-
| `security` | +2 | Proxy, VPN,
|
|
169
|
+
| `security` | +2 | Proxy, VPN, Tor, bot, threat score |
|
|
163
170
|
| `abuse` | +1 | Abuse contact (email, phone, org) |
|
|
164
171
|
| `user_agent` | 0 | Parsed user-agent |
|
|
165
172
|
| `geo_accuracy` | 0 | Accuracy radius and confidence |
|
|
@@ -184,7 +191,7 @@ const resolved = msg.payload.filter(r => r.ip);
|
|
|
184
191
|
|
|
185
192
|
### ipgeo-security: IP security and threat intelligence
|
|
186
193
|
|
|
187
|
-
Single-IP risk lookup: proxy, VPN,
|
|
194
|
+
Single-IP risk lookup: proxy, VPN, Tor, and bot detection plus a threat score, useful for fraud checks, login protection, and access control. Supports **Fields** and **Excludes**.
|
|
188
195
|
|
|
189
196
|
### ipgeo-bulk-security: bulk IP security
|
|
190
197
|
|
|
@@ -213,7 +220,7 @@ Looks up Autonomous System details. The **Query type** selects what gets sent:
|
|
|
213
220
|
|
|
214
221
|
Supports an **Include** list (`peers`, `downstreams`, `upstreams`, and more), overridable per message via `msg.ipgeo_include`, plus **Fields** and **Excludes**.
|
|
215
222
|
|
|
216
|
-
### ipgeo-timezone:
|
|
223
|
+
### ipgeo-timezone: Time Zone API
|
|
217
224
|
|
|
218
225
|
Seven lookup modes:
|
|
219
226
|
|
|
@@ -287,7 +294,7 @@ On failure, the node sets `msg.error` with a typed `code`, a readable `message`,
|
|
|
287
294
|
| `FORBIDDEN` | Plan restriction or origin not whitelisted (HTTP 403) |
|
|
288
295
|
| `NOT_FOUND` | Endpoint or resource not found (HTTP 404) |
|
|
289
296
|
| `VALIDATION` | Validation error (HTTP 422) |
|
|
290
|
-
| `LOCKED` |
|
|
297
|
+
| `LOCKED` | Private or bogon IP address (HTTP 423). Check that the input is a valid public IP and that your application resolved the visitor's address correctly. Localhost and private-network addresses cannot be geolocated. |
|
|
291
298
|
| `RATE_LIMITED` | Too many requests (HTTP 429) |
|
|
292
299
|
| `SERVER_ERROR` | API internal error (HTTP 500) |
|
|
293
300
|
| `HTTP_ERROR` | Any other non-2xx status |
|
|
@@ -333,7 +340,33 @@ return msg;
|
|
|
333
340
|
|
|
334
341
|
### Geolocate the visitor in an HTTP flow
|
|
335
342
|
|
|
336
|
-
|
|
343
|
+
Give `ipgeo-lookup` one validated client IP. Do not map the raw `req.headers['x-forwarded-for']` chain: the node sends it as one value, for example `203.0.113.7, 10.0.0.2`, and any entry your own proxies did not add is whatever the client sent. Never let the input be empty either, because the API then looks up the caller's IP, which is your Node-RED server.
|
|
344
|
+
|
|
345
|
+
Read the address from `msg.req.ip`. The **http in** node runs on Express, which sets `msg.req.ip` to a single address:
|
|
346
|
+
|
|
347
|
+
- **Direct connection:** with the default settings, `msg.req.ip` is the socket's remote address.
|
|
348
|
+
- **Behind a reverse proxy:** list your proxies under `httpServerOptions` in Node-RED's `settings.js`. Express then reads `X-Forwarded-For` from right to left, skips the trusted proxies, and uses the first address it does not trust. Do not set `"trust proxy": true`, which trusts every entry, including ones the client wrote.
|
|
349
|
+
|
|
350
|
+
```javascript
|
|
351
|
+
// settings.js: nginx on the same host as Node-RED, behind a load balancer at 10.0.0.2
|
|
352
|
+
httpServerOptions: {
|
|
353
|
+
"trust proxy": ["loopback", "10.0.0.2"],
|
|
354
|
+
},
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Add a Function node with two outputs between **http in** and `ipgeo-lookup`. Wire output 1 to `ipgeo-lookup` and output 2 to a fallback such as an **http response**, then set **IP / Domain** to the `msg` property `ipgeo_ip`:
|
|
358
|
+
|
|
359
|
+
```javascript
|
|
360
|
+
let ip = msg.req.ip || "";
|
|
361
|
+
if (ip.startsWith("::ffff:")) ip = ip.slice(7); // IPv4 client on a dual-stack listener
|
|
362
|
+
if (!/^(\d{1,3}\.){3}\d{1,3}$|^[0-9a-f]*:[0-9a-f:.]+$/i.test(ip)) {
|
|
363
|
+
return [null, msg]; // not one IP address; an empty value would look up your server's IP
|
|
364
|
+
}
|
|
365
|
+
msg.ipgeo_ip = ip;
|
|
366
|
+
return [msg, null];
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
If your proxy instead overwrites a dedicated header with the client address, for example nginx `proxy_set_header X-Real-IP $remote_addr;`, read `msg.req.headers['x-real-ip']` in the first line. Do this only when clients cannot reach Node-RED without passing through that proxy.
|
|
337
370
|
|
|
338
371
|
### Block proxies and VPNs at the edge
|
|
339
372
|
|
|
@@ -363,20 +396,25 @@ Each node reports the real charge in `msg.ipgeo_credits`. See the [Credits Usage
|
|
|
363
396
|
## Development and testing
|
|
364
397
|
|
|
365
398
|
```bash
|
|
366
|
-
npm
|
|
399
|
+
npm ci # install the locked dependencies
|
|
367
400
|
npm test # run the mocha test suite
|
|
368
401
|
npm run coverage # run tests with an HTML and text coverage report
|
|
402
|
+
npm run audit:security # check runtime and development dependencies
|
|
403
|
+
npm run test:package # test fresh installs and upgrades of the packed npm package
|
|
404
|
+
npm run test:http # test HTTPS behavior with the locally installed Postman CLI
|
|
369
405
|
```
|
|
370
406
|
|
|
371
407
|
Tests use `mocha`, `node-red-node-test-helper`, `should`, and `nock`, with all HTTP fully mocked so the suite runs offline with no live API calls. Specs live in `test/**/*_spec.js` and cover the shared API client, the helpers, every node, and the bundled example flows.
|
|
372
408
|
|
|
409
|
+
`test:http` starts a local Postman simulation and checks real HTTPS requests, redirects, retries and timeouts. It uses test credentials and stops the proxy when the checks finish. `test:package` requires registry access to verify fresh installations and upgrades from version 1.0.1, including an existing lock with current Axios and an older redirect dependency.
|
|
410
|
+
|
|
373
411
|
---
|
|
374
412
|
|
|
375
413
|
## Frequently Asked Questions
|
|
376
414
|
|
|
377
415
|
<details>
|
|
378
416
|
<summary><strong>How do I get an IPGeolocation.io API key?</strong></summary>
|
|
379
|
-
Sign up for a free account at <code>app.ipgeolocation.io/signup</code>. The free
|
|
417
|
+
Sign up for a free account at <code>app.ipgeolocation.io/signup</code>. The free plan covers the lookup, timezone, astronomy, and user-agent nodes, within free-plan fields and options. Bulk, security, dedicated ASN, and abuse nodes require a paid plan.
|
|
380
418
|
</details>
|
|
381
419
|
|
|
382
420
|
<details>
|
|
@@ -390,13 +428,13 @@ Yes. Use the <code>ipgeo-bulk</code> node for geolocation lookups or the <code>i
|
|
|
390
428
|
</details>
|
|
391
429
|
|
|
392
430
|
<details>
|
|
393
|
-
<summary><strong>How do I detect VPNs, proxies, or
|
|
394
|
-
Use the <code>ipgeo-security</code> node, or enable the <code>security</code> include module when using <code>ipgeo-lookup</code>. The response includes fields indicating proxy usage, VPN detection,
|
|
431
|
+
<summary><strong>How do I detect VPNs, proxies, or Tor exit nodes?</strong></summary>
|
|
432
|
+
Use the <code>ipgeo-security</code> node, or enable the <code>security</code> include module when using <code>ipgeo-lookup</code>. The response includes fields indicating proxy usage, VPN detection, Tor exit node status, and other threat-related information.
|
|
395
433
|
</details>
|
|
396
434
|
|
|
397
435
|
<details>
|
|
398
436
|
<summary><strong>Does it work behind a reverse proxy?</strong></summary>
|
|
399
|
-
Yes.
|
|
437
|
+
Yes. List your proxies under <code>"trust proxy"</code> in <code>httpServerOptions</code> in Node-RED's <code>settings.js</code>. Express then sets <code>msg.req.ip</code> to one client address selected through those trusted proxies; check it in a Function node and pass it to <code>ipgeo-lookup</code> as a dynamic <code>msg</code> input. Do not pass the raw <code>X-Forwarded-For</code> header, which can hold several addresses, some of them written by the client. The "Geolocate the visitor in an HTTP flow" recipe shows the full setup.
|
|
400
438
|
</details>
|
|
401
439
|
|
|
402
440
|
<details>
|
package/nodes/ipgeo-bulk.html
CHANGED
package/nodes/ipgeo-lookup.html
CHANGED
package/nodes/lib/api-client.js
CHANGED
|
@@ -76,7 +76,7 @@ function mapAxiosError(err) {
|
|
|
76
76
|
case 422: return new IPGeoError(
|
|
77
77
|
`Unprocessable entity: ${apiMsg || 'Validation error'}`, 'VALIDATION', 422, data);
|
|
78
78
|
case 423: return new IPGeoError(
|
|
79
|
-
`
|
|
79
|
+
`Private or bogon IP address: ${apiMsg || 'Localhost and private-network addresses cannot be geolocated'}`, 'LOCKED', 423, data);
|
|
80
80
|
case 429: return new IPGeoError(
|
|
81
81
|
`Rate limit exceeded: ${apiMsg || 'Too many requests'}`, 'RATE_LIMITED', 429, data);
|
|
82
82
|
case 500: return new IPGeoError(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-ipgeolocation",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Node-RED nodes for the IPGeolocation.io v3 API: IP geolocation, security and threat intelligence (VPN, proxy, and TOR detection), abuse contacts, ASN lookup, bulk IP processing, timezone, astronomy, and user-agent parsing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"axios": "^1.
|
|
47
|
+
"axios": "^1.21.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@node-red/editor-client": "^
|
|
51
|
-
"mocha": "^
|
|
50
|
+
"@node-red/editor-client": "^4.1.17",
|
|
51
|
+
"mocha": "^12.0.2",
|
|
52
52
|
"nock": "^13.5.6",
|
|
53
|
-
"node-red": "^
|
|
53
|
+
"node-red": "^4.1.17",
|
|
54
54
|
"node-red-node-test-helper": "^0.3.6",
|
|
55
|
-
"nyc": "^
|
|
55
|
+
"nyc": "^18.0.0",
|
|
56
56
|
"should": "^13.2.3",
|
|
57
57
|
"sinon": "^17.0.1"
|
|
58
58
|
},
|
|
@@ -65,8 +65,22 @@
|
|
|
65
65
|
],
|
|
66
66
|
"scripts": {
|
|
67
67
|
"test": "mocha",
|
|
68
|
+
"test:http": "node test/run-http.js",
|
|
69
|
+
"test:package": "node test/package-install.js",
|
|
70
|
+
"audit:security": "node scripts/audit.js",
|
|
68
71
|
"test:watch": "mocha --watch",
|
|
69
72
|
"coverage": "nyc --reporter=text --reporter=html mocha",
|
|
70
|
-
"prepublishOnly": "npm test"
|
|
73
|
+
"prepublishOnly": "npm test && npm run audit:security"
|
|
74
|
+
},
|
|
75
|
+
"overrides": {
|
|
76
|
+
"@node-red/registry": {
|
|
77
|
+
"npm": "^11.21.1"
|
|
78
|
+
},
|
|
79
|
+
"multer": "^2.5.0",
|
|
80
|
+
"express": "^4.22.3",
|
|
81
|
+
"qs": "^6.17.0",
|
|
82
|
+
"body-parser@^1": "^1.20.9",
|
|
83
|
+
"glob": "^14.0.2",
|
|
84
|
+
"minimatch": "^11.0.1"
|
|
71
85
|
}
|
|
72
86
|
}
|