geoip-lite2 2.1.27 → 2.1.29
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 +18 -33
- package/data/city.checksum +1 -1
- package/data/country.checksum +1 -1
- package/data/geoip-city-names.dat +0 -0
- package/data/geoip-city.dat +0 -0
- package/data/geoip-city6.dat +0 -0
- package/data/geoip-country.dat +0 -0
- package/data/geoip-country6.dat +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
🚀 Improved GeoIP Module by [Sefinek](https://sefinek.net)
|
|
21
|
-
------------------------------------------
|
|
20
|
+
# 🚀 Improved GeoIP Module by [Sefinek](https://sefinek.net)
|
|
22
21
|
This module is an improved and updated edition of [geoip-lite](https://github.com/geoip-lite/node-geoip), thoughtfully designed to meet the latest programming standards.
|
|
23
22
|
|
|
24
23
|
All components have undergone meticulous updates to ensure peak performance and functionality.
|
|
@@ -32,21 +31,18 @@ This change enhances testing and contributes to the overall reliability of the m
|
|
|
32
31
|
> I am not the main creator of this module! All copyright rights belong to its original [Creators](AUTHORS).
|
|
33
32
|
|
|
34
33
|
|
|
35
|
-
🌠 Version without a local database
|
|
36
|
-
-----------------------------------
|
|
34
|
+
## 🌠 Version without a local database
|
|
37
35
|
This module requires a significant amount of RAM because geolocation data is stored in memory. Nevertheless, you can always use the official and alternative [geoip2-api](https://www.npmjs.com/package/geoip2-api) module, which sends a request to the API server and retrieves information about a specific IP address from there.
|
|
38
36
|
|
|
39
37
|
|
|
40
|
-
✨ Demonstration
|
|
41
|
-
----------------
|
|
38
|
+
### ✨ Demonstration
|
|
42
39
|
You can see this module in action using my [official API](https://sefinek.net). Generally speaking, the API interface is public, and you can safely use it in your projects. Happy coding!
|
|
43
40
|
|
|
44
41
|
> Docs: https://api.sefinek.net/docs/v2
|
|
45
42
|
> Example: https://api.sefinek.net/api/v2/geoip/109.207.159.255?validation=false
|
|
46
43
|
|
|
47
44
|
|
|
48
|
-
📑 Introduction
|
|
49
|
-
---------------
|
|
45
|
+
## 📑 Introduction
|
|
50
46
|
MaxMind provides a set of data files for IP to Geo mapping along with opensource libraries to parse and lookup these data files.
|
|
51
47
|
One would typically write a wrapper around their C API to get access to this data in other languages (like JavaScript).
|
|
52
48
|
|
|
@@ -57,25 +53,22 @@ binary file to lookup IP addresses and return the country, region and city that
|
|
|
57
53
|
Both IPv4 and IPv6 addresses are supported, however since the GeoLite IPv6 database does not currently contain any city or region
|
|
58
54
|
information, city, region and postal code lookups are only supported for IPv4.
|
|
59
55
|
|
|
60
|
-
>
|
|
56
|
+
> [!WARNING]
|
|
61
57
|
> **You SHOULD update the data files after installation.** The MaxMind license does not allow us to distribute the latest version of the data files with this package. Follow the instructions under update the datafiles for details.
|
|
62
58
|
|
|
63
59
|
|
|
64
|
-
📚 Philosophy
|
|
65
|
-
-------------
|
|
60
|
+
## 📚 Philosophy
|
|
66
61
|
I was really aiming for a fast JavaScript native implementation for geomapping of IPs.
|
|
67
62
|
My prime motivator was the fact that it was really hard to get libgeoip built for Mac OSX without using the library from MacPorts.
|
|
68
63
|
|
|
69
64
|
|
|
70
|
-
🕵️♂️ Why GeoIP-Lite?
|
|
71
|
-
------------------
|
|
65
|
+
## 🕵️♂️ Why GeoIP-Lite?
|
|
72
66
|
GeoIP-Lite is a fully JavaScript implementation of the MaxMind GeoIP API. It is not as fully featured as bindings that use `libgeoip`.
|
|
73
67
|
By reducing scope, this package is about 40% faster at doing lookups. On average, an IP to Location lookup should take 20 microseconds on
|
|
74
68
|
a Macbook Pro. IPv4 addresses take about 6 microseconds, while IPv6 addresses take about 30 microseconds.
|
|
75
69
|
|
|
76
70
|
|
|
77
|
-
📝 Synopsis
|
|
78
|
-
------------
|
|
71
|
+
## 📝 Synopsis
|
|
79
72
|
### Script
|
|
80
73
|
```javascript
|
|
81
74
|
const geoIp2 = require('geoip-lite2');
|
|
@@ -102,8 +95,7 @@ console.log(geo);
|
|
|
102
95
|
```
|
|
103
96
|
|
|
104
97
|
|
|
105
|
-
🛠️ Installation
|
|
106
|
-
----------------
|
|
98
|
+
## 🛠️ Installation
|
|
107
99
|
|
|
108
100
|
### 1. Get the library
|
|
109
101
|
```cmd
|
|
@@ -115,14 +107,13 @@ Run `cd node_modules/geoip-lite2 && npm run updatedb license_key=YOUR_LICENSE_KE
|
|
|
115
107
|
|
|
116
108
|
You can create maxmind account [here](https://www.maxmind.com/en/geolite2/signup).
|
|
117
109
|
|
|
118
|
-
>
|
|
110
|
+
> [!NOTE]
|
|
119
111
|
> This requires a lot of RAM. It is known to fail on a Digital Ocean or AWS micro instance.
|
|
120
112
|
> There are no plans to change this. GeoIP-Lite2 stores all data in RAM in order to be fast.
|
|
121
113
|
> If you need an external API that provides GeoIP, you can use [this](#-demonstration).
|
|
122
114
|
|
|
123
115
|
|
|
124
|
-
🧩 API
|
|
125
|
-
-------
|
|
116
|
+
## 🧩 API
|
|
126
117
|
GeoIP-Lite2 is completely synchronous. There are no callbacks involved.
|
|
127
118
|
All blocking file IO is done at startup time, so all runtime calls are executed in-memory and are fast.
|
|
128
119
|
Startup may take up to 200ms while it reads into memory and indexes data files.
|
|
@@ -172,8 +163,7 @@ This method returns a string if the input was in a format that `geoip-lite2` can
|
|
|
172
163
|
input itself.
|
|
173
164
|
|
|
174
165
|
|
|
175
|
-
🔄 Built-in Updater
|
|
176
|
-
--------------------
|
|
166
|
+
## 🔄 Built-in Updater
|
|
177
167
|
This package contains an update script that can pull the files from MaxMind and handle the conversion from CSV.
|
|
178
168
|
A npm script alias has been setup to make this process easy. Please keep in mind this requires internet and MaxMind
|
|
179
169
|
rate limits that amount of downloads on their servers.
|
|
@@ -233,8 +223,7 @@ GEODATADIR=/some/path
|
|
|
233
223
|
```
|
|
234
224
|
|
|
235
225
|
|
|
236
|
-
⚠️ Caveats
|
|
237
|
-
-----------
|
|
226
|
+
## ⚠️ Caveats
|
|
238
227
|
This package includes the GeoLite database from MaxMind. This database is not the most accurate database available,
|
|
239
228
|
however it is the best available for free. You can use the commercial GeoIP database from MaxMind with better
|
|
240
229
|
accuracy by buying a license from MaxMind, and then using the conversion utility to convert it to a format that
|
|
@@ -264,24 +253,20 @@ console.log(process.memoryUsage());
|
|
|
264
253
|
```
|
|
265
254
|
|
|
266
255
|
|
|
267
|
-
🔀 Alternatives
|
|
268
|
-
---------------
|
|
256
|
+
## 🔀 Alternatives
|
|
269
257
|
If your use-case requires doing less than 100 queries through the lifetime of your application or if you need really fast latency on start-up, you might want to look into [fast-geoip](https://github.com/onramper/fast-geoip) a package with a compatible API that is optimized for serverless environments and provides faster boot times and lower memory consumption at the expense of longer lookup times.
|
|
270
258
|
|
|
271
259
|
|
|
272
|
-
🔖 References
|
|
273
|
-
-------------
|
|
260
|
+
## 🔖 References
|
|
274
261
|
- [Documentation from MaxMind](https://www.maxmind.com/app/iso3166)
|
|
275
262
|
- [ISO 3166 (1 & 2) codes](https://en.wikipedia.org/wiki/ISO_3166)
|
|
276
263
|
- [FIPS region codes](https://en.wikipedia.org/wiki/List_of_FIPS_region_codes)
|
|
277
264
|
|
|
278
265
|
|
|
279
|
-
👥 Copyright
|
|
280
|
-
------------
|
|
266
|
+
## 👥 Copyright
|
|
281
267
|
`GeoIP-Lite` is Copyright 2011-2018 **Philip Tellis** <philip@bluesmoon.info>
|
|
282
|
-
`GeoIP-Lite2` is Copyright 2023 **Sefinek** <contact@sefinek.net> (https://sefinek.net)
|
|
268
|
+
`GeoIP-Lite2` is Copyright 2023-2024 **Sefinek** <contact@sefinek.net> (https://sefinek.net)
|
|
283
269
|
|
|
284
270
|
|
|
285
|
-
🔐 License
|
|
286
|
-
----------
|
|
271
|
+
## 🔐 License
|
|
287
272
|
There are two licenses for the code and data. See the [LICENSE](LICENSE) file for details.
|
package/data/city.checksum
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
6780172a6afd4ec263fc5434b93ff9e4c0536f69d4c54bbcef888ea2e14a5b95 GeoLite2-City-CSV_20240209.zip
|
package/data/country.checksum
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d98edd0f6e0926bbf0545dfc1bcbf993646fdaad5374eeeb29ca0abea54ba88e GeoLite2-Country-CSV_20240209.zip
|
|
Binary file
|
package/data/geoip-city.dat
CHANGED
|
Binary file
|
package/data/geoip-city6.dat
CHANGED
|
Binary file
|
package/data/geoip-country.dat
CHANGED
|
Binary file
|
package/data/geoip-country6.dat
CHANGED
|
Binary file
|