geoip-lite2 2.1.8 β 2.1.10
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 +37 -30
- 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 +3 -3
- package/test/one.js +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<br
|
|
2
|
+
<a href="https://cdn.sefinek.net/images/npm/geoip-lite2/banner.jpg" target="_blank" title="Full screen">
|
|
3
|
+
<img src="https://cdn.sefinek.net/images/npm/geoip-lite2/banner.jpg" alt="GeoIP-Lite2 v2.1 πΊοΈ Now even faster!">
|
|
4
|
+
</a>
|
|
5
|
+
<br>
|
|
6
|
+
<p>
|
|
7
|
+
A native <a href="https://nodejs.org" target="_blank" title="Open nodejs.org">Node.js</a> API for the GeoLite data from MaxMind.<br>
|
|
8
|
+
This product includes GeoLite data created by MaxMind, available from: <a href="https://www.maxmind.com" target="_blank" title="Open www.maxmind.com">www.maxmind.com</a>
|
|
9
|
+
</p>
|
|
6
10
|
<a href="https://www.npmjs.com/package/geoip-lite2" target="_blank" title="geoip-lite2 - npm" style="text-decoration:none">
|
|
7
11
|
<img src="https://img.shields.io/npm/dt/geoip-lite2?maxAge=3600" alt="The number of downloads">
|
|
8
12
|
<img src="https://img.shields.io/github/last-commit/sefinek24/geoip-lite2" alt="Last commit">
|
|
@@ -14,7 +18,7 @@
|
|
|
14
18
|
|
|
15
19
|
|
|
16
20
|
π Improved GeoIP Module by [Sefinek](https://sefinek.net)
|
|
17
|
-
|
|
21
|
+
------------------------------------------
|
|
18
22
|
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.
|
|
19
23
|
|
|
20
24
|
All components have undergone meticulous updates to ensure peak performance and functionality.
|
|
@@ -27,15 +31,17 @@ This change enhances testing and contributes to the overall reliability of the m
|
|
|
27
31
|
|
|
28
32
|
> I am not the creator of this npm module! All copyright rights belong to its original [Creators](AUTHORS).
|
|
29
33
|
|
|
34
|
+
|
|
30
35
|
β¨ Demonstration
|
|
31
|
-
|
|
32
|
-
You can see this module in action on my official API. Generally speaking, the API interface is public, and you can safely use it in your projects. Happy coding!
|
|
36
|
+
----------------
|
|
37
|
+
You can see this module in action on my [official API](https://sefinek.net). Generally speaking, the API interface is public, and you can safely use it in your projects. Happy coding!
|
|
33
38
|
|
|
34
|
-
> Endpoint : https://api.sefinek.net/api/v2/geoip/
|
|
39
|
+
> Endpoint : https://api.sefinek.net/api/v2/geoip/
|
|
35
40
|
> Example : https://api.sefinek.net/api/v2/geoip/109.207.159.255
|
|
36
41
|
|
|
42
|
+
|
|
37
43
|
π Introduction
|
|
38
|
-
|
|
44
|
+
---------------
|
|
39
45
|
MaxMind provides a set of data files for IP to Geo mapping along with opensource libraries to parse and lookup these data files.
|
|
40
46
|
One would typically write a wrapper around their C API to get access to this data in other languages (like JavaScript).
|
|
41
47
|
|
|
@@ -47,24 +53,24 @@ Both IPv4 and IPv6 addresses are supported, however since the GeoLite IPv6 datab
|
|
|
47
53
|
information, city, region and postal code lookups are only supported for IPv4.
|
|
48
54
|
|
|
49
55
|
> **Warning**
|
|
50
|
-
> **You
|
|
56
|
+
> **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.
|
|
51
57
|
|
|
52
58
|
|
|
53
59
|
π Philosophy
|
|
54
|
-
|
|
60
|
+
-------------
|
|
55
61
|
I was really aiming for a fast JavaScript native implementation for geomapping of IPs.
|
|
56
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.
|
|
57
63
|
|
|
58
64
|
|
|
59
65
|
π΅οΈββοΈ Why GeoIP-Lite?
|
|
60
|
-
|
|
66
|
+
------------------
|
|
61
67
|
GeoIP-Lite is a fully JavaScript implementation of the MaxMind GeoIP API. It is not as fully featured as bindings that use `libgeoip`.
|
|
62
68
|
By reducing scope, this package is about 40% faster at doing lookups. On average, an IP to Location lookup should take 20 microseconds on
|
|
63
69
|
a Macbook Pro. IPv4 addresses take about 6 microseconds, while IPv6 addresses take about 30 microseconds.
|
|
64
70
|
|
|
65
71
|
|
|
66
72
|
π Synopsis
|
|
67
|
-
|
|
73
|
+
------------
|
|
68
74
|
### Script
|
|
69
75
|
```javascript
|
|
70
76
|
const geoIp2 = require('geoip-lite2');
|
|
@@ -92,7 +98,8 @@ console.log(geo);
|
|
|
92
98
|
|
|
93
99
|
|
|
94
100
|
π οΈ Installation
|
|
95
|
-
|
|
101
|
+
----------------
|
|
102
|
+
|
|
96
103
|
### 1. Get the library
|
|
97
104
|
```cmd
|
|
98
105
|
npm install geoip-lite2
|
|
@@ -110,7 +117,7 @@ You can create maxmind account [here](https://www.maxmind.com/en/geolite2/signup
|
|
|
110
117
|
|
|
111
118
|
|
|
112
119
|
π§© API
|
|
113
|
-
|
|
120
|
+
-------
|
|
114
121
|
GeoIP-Lite2 is completely synchronous. There are no callbacks involved.
|
|
115
122
|
All blocking file IO is done at startup time, so all runtime calls are executed in-memory and are fast.
|
|
116
123
|
Startup may take up to 200ms while it reads into memory and indexes data files.
|
|
@@ -129,7 +136,7 @@ If the IP address was found, the `lookup` method returns an object with the foll
|
|
|
129
136
|
```javascript
|
|
130
137
|
{
|
|
131
138
|
range: [ <low bound of IP block>, <high bound of IP block> ],
|
|
132
|
-
country: '
|
|
139
|
+
country: 'CC', // 2 letter ISO-3166-1 country code
|
|
133
140
|
region: 'RR', // Up to 3 alphanumeric variable length characters as ISO 3166-2 code
|
|
134
141
|
// For US states this is the 2 letter state
|
|
135
142
|
// For the United Kingdom this could be ENG as a country like βEngland
|
|
@@ -161,7 +168,7 @@ input itself.
|
|
|
161
168
|
|
|
162
169
|
|
|
163
170
|
π Built-in Updater
|
|
164
|
-
|
|
171
|
+
--------------------
|
|
165
172
|
This package contains an update script that can pull the files from MaxMind and handle the conversion from CSV.
|
|
166
173
|
A npm script alias has been setup to make this process easy. Please keep in mind this requires internet and MaxMind
|
|
167
174
|
rate limits that amount of downloads on their servers.
|
|
@@ -180,7 +187,7 @@ npm run updatedb-force license_key=YOUR_LICENSE_KEY
|
|
|
180
187
|
```
|
|
181
188
|
|
|
182
189
|
You can also run it by doing:
|
|
183
|
-
```
|
|
190
|
+
```shell
|
|
184
191
|
node ./node_modules/geoip-lite2/scripts/updatedb.js license_key=YOUR_LICENSE_KEY
|
|
185
192
|
```
|
|
186
193
|
|
|
@@ -211,7 +218,7 @@ This tool can be used with `npm run updatedb` to periodically update geo data on
|
|
|
211
218
|
|
|
212
219
|
|
|
213
220
|
β οΈ Caveats
|
|
214
|
-
|
|
221
|
+
-----------
|
|
215
222
|
This package includes the GeoLite database from MaxMind. This database is not the most accurate database available,
|
|
216
223
|
however it is the best available for free. You can use the commercial GeoIP database from MaxMind with better
|
|
217
224
|
accuracy by buying a license from MaxMind, and then using the conversion utility to convert it to a format that
|
|
@@ -222,7 +229,7 @@ how busy your disk is at that time. It can take as little as 200ms on a lightly
|
|
|
222
229
|
cost though, and you make it up at run time with very fast lookups.
|
|
223
230
|
|
|
224
231
|
### Memory usage
|
|
225
|
-
Quick test on memory consumption shows that library uses around
|
|
232
|
+
Quick test on memory consumption shows that library uses around 100 MB per process.
|
|
226
233
|
|
|
227
234
|
```javascript
|
|
228
235
|
const geoIp2 = require('geoip-lite2');
|
|
@@ -242,23 +249,23 @@ console.log(process.memoryUsage());
|
|
|
242
249
|
|
|
243
250
|
|
|
244
251
|
π Alternatives
|
|
245
|
-
|
|
252
|
+
---------------
|
|
246
253
|
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.
|
|
247
254
|
|
|
248
255
|
|
|
249
256
|
π References
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
-------------
|
|
258
|
+
- [Documentation from MaxMind](https://www.maxmind.com/app/iso3166)
|
|
259
|
+
- [ISO 3166 (1 & 2) codes](https://en.wikipedia.org/wiki/ISO_3166)
|
|
260
|
+
- [FIPS region codes](https://en.wikipedia.org/wiki/List_of_FIPS_region_codes)
|
|
254
261
|
|
|
255
262
|
|
|
256
263
|
Β©οΈ Copyright
|
|
257
|
-
|
|
258
|
-
`GeoIP-Lite` is Copyright 2011-2018 Philip Tellis <philip@bluesmoon.info>
|
|
259
|
-
`GeoIP-Lite2` is Copyright 2023 Sefinek <contact@sefinek.net> (https://sefinek.net)
|
|
264
|
+
------------
|
|
265
|
+
`GeoIP-Lite` is Copyright 2011-2018 **Philip Tellis** <philip@bluesmoon.info>
|
|
266
|
+
`GeoIP-Lite2` is Copyright 2023 **Sefinek** <contact@sefinek.net> (https://sefinek.net)
|
|
260
267
|
|
|
261
268
|
|
|
262
269
|
π License
|
|
263
|
-
|
|
264
|
-
There are two licenses for the code and data. See the [LICENSE](LICENSE) file for details.
|
|
270
|
+
----------
|
|
271
|
+
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
|
+
26de70dfbc16d299fbe08a7f61b939865a63c7a34eefb4b755236330daa96a9a GeoLite2-City-CSV_20230926.zip
|
package/data/country.checksum
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
81a25a98517b6b65004457a70df9bfdd25a95ec923e120fb9ceb4b1ce80181b0 GeoLite2-Country-CSV_20230926.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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geoip-lite2",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.10",
|
|
4
4
|
"description": "A light weight native JavaScript implementation of GeoIP API from MaxMind.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"city",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"async": "^3.2.4",
|
|
63
63
|
"chalk": "4.1.2",
|
|
64
64
|
"iconv-lite": "0.6.3",
|
|
65
|
-
"ip-address": "^
|
|
65
|
+
"ip-address": "^9.0.5",
|
|
66
66
|
"lazy": "1.0.11",
|
|
67
|
-
"rimraf": "^5.0.
|
|
67
|
+
"rimraf": "^5.0.5"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"eslint": "^8.50.0",
|
package/test/one.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o=require('../lib/geoip.js').lookup('
|
|
1
|
+
const o=require('../lib/geoip.js').lookup('86.63.89.41');console.log(o);
|