geoip-lite2 2.2.1 → 2.2.3
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/geoip-data/city.checksum +1 -1
- package/geoip-data/country.checksum +1 -1
- package/geoip-data/geoip-city-names.dat +0 -0
- package/geoip-data/geoip-city.dat +0 -0
- package/geoip-data/geoip-city6.dat +0 -0
- package/geoip-data/geoip-country.dat +0 -0
- package/geoip-data/geoip-country6.dat +0 -0
- package/lib/main.js +14 -14
- package/minify.js +7 -7
- package/package.json +4 -6
- package/test/index.test.js +5 -5
- package/utils/updatedb.js +5 -5
package/geoip-data/city.checksum
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d842b81413ad144f2e5009e30350daa0479c77c451c2ae47d6e8ef1addbba739 GeoLite2-City-CSV_20250103.zip
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
bc0a5708e4bc97831c488483eba2668d50768b2155e4f29d797e2e5a886bef2b GeoLite2-Country-CSV_20250103.zip
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/main.js
CHANGED
|
@@ -18,13 +18,13 @@ const dataFiles = {
|
|
|
18
18
|
city6: join(geoDataDir, 'geoip-city6.dat'),
|
|
19
19
|
cityNames: join(geoDataDir, 'geoip-city-names.dat'),
|
|
20
20
|
country: join(geoDataDir, 'geoip-country.dat'),
|
|
21
|
-
country6: join(geoDataDir, 'geoip-country6.dat')
|
|
21
|
+
country6: join(geoDataDir, 'geoip-country6.dat'),
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const privateRange4 = [
|
|
25
25
|
[aton4('10.0.0.0'), aton4('10.255.255.255')],
|
|
26
26
|
[aton4('172.16.0.0'), aton4('172.31.255.255')],
|
|
27
|
-
[aton4('192.168.0.0'), aton4('192.168.255.255')]
|
|
27
|
+
[aton4('192.168.0.0'), aton4('192.168.255.255')],
|
|
28
28
|
];
|
|
29
29
|
|
|
30
30
|
const conf4 = {
|
|
@@ -34,7 +34,7 @@ const conf4 = {
|
|
|
34
34
|
locationBuffer: null,
|
|
35
35
|
locationRecordSize: 88,
|
|
36
36
|
mainBuffer: null,
|
|
37
|
-
recordSize: 24
|
|
37
|
+
recordSize: 24,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const conf6 = {
|
|
@@ -42,7 +42,7 @@ const conf6 = {
|
|
|
42
42
|
lastIP: null,
|
|
43
43
|
lastLine: 0,
|
|
44
44
|
mainBuffer: null,
|
|
45
|
-
recordSize: 48
|
|
45
|
+
recordSize: 48,
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// Copy original configs
|
|
@@ -74,7 +74,7 @@ const lookup4 = ip => {
|
|
|
74
74
|
city: '',
|
|
75
75
|
ll: [null, null],
|
|
76
76
|
metro: null,
|
|
77
|
-
area: null
|
|
77
|
+
area: null,
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
// Outside IPv4 range
|
|
@@ -248,7 +248,7 @@ function preload(callback) {
|
|
|
248
248
|
datSize = stats.size;
|
|
249
249
|
cb2(err);
|
|
250
250
|
});
|
|
251
|
-
}
|
|
251
|
+
},
|
|
252
252
|
], err => {
|
|
253
253
|
if (err) {
|
|
254
254
|
if (err.code !== 'ENOENT' && err.code !== 'EBADF') {
|
|
@@ -282,7 +282,7 @@ function preload(callback) {
|
|
|
282
282
|
},
|
|
283
283
|
cb2 => {
|
|
284
284
|
close(datFile, cb2);
|
|
285
|
-
}
|
|
285
|
+
},
|
|
286
286
|
], err => {
|
|
287
287
|
if (!err) {
|
|
288
288
|
asyncCache.lastLine = (datSize / asyncCache.recordSize) - 1;
|
|
@@ -292,7 +292,7 @@ function preload(callback) {
|
|
|
292
292
|
}
|
|
293
293
|
callback(err);
|
|
294
294
|
});
|
|
295
|
-
}
|
|
295
|
+
},
|
|
296
296
|
]);
|
|
297
297
|
} else {
|
|
298
298
|
try {
|
|
@@ -347,7 +347,7 @@ function preload6(callback) {
|
|
|
347
347
|
datSize = stats.size;
|
|
348
348
|
cb2(err);
|
|
349
349
|
});
|
|
350
|
-
}
|
|
350
|
+
},
|
|
351
351
|
], err => {
|
|
352
352
|
if (err) {
|
|
353
353
|
if (err.code !== 'ENOENT' && err.code !== 'EBADF') {
|
|
@@ -380,7 +380,7 @@ function preload6(callback) {
|
|
|
380
380
|
},
|
|
381
381
|
cb2 => {
|
|
382
382
|
close(datFile, cb2);
|
|
383
|
-
}
|
|
383
|
+
},
|
|
384
384
|
], err => {
|
|
385
385
|
if (!err) {
|
|
386
386
|
asyncCache6.lastLine = (datSize / asyncCache6.recordSize) - 1;
|
|
@@ -388,7 +388,7 @@ function preload6(callback) {
|
|
|
388
388
|
}
|
|
389
389
|
callback(err);
|
|
390
390
|
});
|
|
391
|
-
}
|
|
391
|
+
},
|
|
392
392
|
]);
|
|
393
393
|
} else {
|
|
394
394
|
try {
|
|
@@ -458,7 +458,7 @@ module.exports = {
|
|
|
458
458
|
preload(cb);
|
|
459
459
|
}, cb => {
|
|
460
460
|
preload6(cb);
|
|
461
|
-
}
|
|
461
|
+
},
|
|
462
462
|
], callback);
|
|
463
463
|
});
|
|
464
464
|
},
|
|
@@ -487,11 +487,11 @@ module.exports = {
|
|
|
487
487
|
},
|
|
488
488
|
cb => {
|
|
489
489
|
preload6(cb);
|
|
490
|
-
}
|
|
490
|
+
},
|
|
491
491
|
], callback);
|
|
492
492
|
},
|
|
493
493
|
|
|
494
|
-
version
|
|
494
|
+
version,
|
|
495
495
|
};
|
|
496
496
|
|
|
497
497
|
preload();
|
package/minify.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
const terser = require('terser');
|
|
1
2
|
const fs = require('node:fs/promises');
|
|
2
3
|
const path = require('node:path');
|
|
3
|
-
const terser = require('terser');
|
|
4
4
|
|
|
5
5
|
const minifyJSFiles = async (sourceDirectory, outputDirectory) => {
|
|
6
6
|
try {
|
|
@@ -29,24 +29,24 @@ const minifyJSFiles = async (sourceDirectory, outputDirectory) => {
|
|
|
29
29
|
reduce_vars: true,
|
|
30
30
|
unsafe: false,
|
|
31
31
|
unused: true,
|
|
32
|
-
dead_code: true
|
|
32
|
+
dead_code: true,
|
|
33
33
|
},
|
|
34
34
|
format: {
|
|
35
35
|
quote_style: 3,
|
|
36
36
|
preserve_annotations: true,
|
|
37
|
-
comments: false
|
|
37
|
+
comments: false,
|
|
38
38
|
},
|
|
39
|
-
toplevel: true
|
|
39
|
+
toplevel: true,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
await fs.writeFile(path.join(outputDirectory, file), result.code, 'utf8');
|
|
43
|
-
console.log(
|
|
43
|
+
console.log('Minimized:', file);
|
|
44
44
|
} catch (err) {
|
|
45
|
-
console.error(`Error processing ${file}
|
|
45
|
+
console.error(`Error processing ${file}:`, err.message);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
console.log(
|
|
49
|
+
console.log('COMPLETED:', sourceDirectory);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
(async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geoip-lite2",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "A light weight native JavaScript implementation of GeoIP API from MaxMind. Improved and faster version by Sefinek.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"city",
|
|
@@ -37,11 +37,9 @@
|
|
|
37
37
|
"ipv4",
|
|
38
38
|
"ipv6",
|
|
39
39
|
"location",
|
|
40
|
-
"low latency geoip",
|
|
41
40
|
"maxmind integration",
|
|
42
41
|
"maxmind lite",
|
|
43
42
|
"maxmind",
|
|
44
|
-
"real time ip lookup",
|
|
45
43
|
"region",
|
|
46
44
|
"state"
|
|
47
45
|
],
|
|
@@ -73,10 +71,10 @@
|
|
|
73
71
|
"rimraf": "^6.0.1"
|
|
74
72
|
},
|
|
75
73
|
"devDependencies": {
|
|
76
|
-
"@eslint/js": "^9.
|
|
77
|
-
"globals": "^15.
|
|
74
|
+
"@eslint/js": "^9.17.0",
|
|
75
|
+
"globals": "^15.14.0",
|
|
78
76
|
"jest": "^29.7.0",
|
|
79
|
-
"terser": "^5.
|
|
77
|
+
"terser": "^5.37.0"
|
|
80
78
|
},
|
|
81
79
|
"engines": {
|
|
82
80
|
"node": ">=10.3.0"
|
package/test/index.test.js
CHANGED
|
@@ -44,7 +44,7 @@ describe('GeoIP2', () => {
|
|
|
44
44
|
expect(actual.country).toBe('JP');
|
|
45
45
|
expect(actual.eu).toBe('0');
|
|
46
46
|
expect(actual.timezone).toBe('Asia/Tokyo');
|
|
47
|
-
expect(actual.city).toBe('');
|
|
47
|
+
expect(actual.city).toBe('Higashiōmiya');
|
|
48
48
|
expect(actual.ll).toBeTruthy();
|
|
49
49
|
expect(actual.metro).toBe(0);
|
|
50
50
|
expect(actual.area).toBe(200);
|
|
@@ -59,7 +59,7 @@ describe('GeoIP2', () => {
|
|
|
59
59
|
expect(actual.city).toBe('Nerl\'');
|
|
60
60
|
expect(actual.ll).toBeTruthy();
|
|
61
61
|
expect(actual.metro).toBe(0);
|
|
62
|
-
expect(actual.area).toBe(
|
|
62
|
+
expect(actual.area).toBe(10);
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
|
|
@@ -70,10 +70,10 @@ describe('GeoIP2', () => {
|
|
|
70
70
|
expect(actual.region).toBe('14');
|
|
71
71
|
expect(actual.eu).toBe('1');
|
|
72
72
|
expect(actual.timezone).toBe('Europe/Warsaw');
|
|
73
|
-
expect(actual.city).toBe('
|
|
73
|
+
expect(actual.city).toBe('Nowa Wieś');
|
|
74
74
|
expect(actual.ll).toBeTruthy();
|
|
75
75
|
expect(actual.metro).toBe(0);
|
|
76
|
-
expect(actual.area).toBe(
|
|
76
|
+
expect(actual.area).toBe(200);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it('should match data for IPv6 - NL ', () => {
|
|
@@ -105,7 +105,7 @@ describe('GeoIP2', () => {
|
|
|
105
105
|
it('should return UTF8 city name', () => {
|
|
106
106
|
const actual = geoIp2.lookup('2.139.175.1');
|
|
107
107
|
expect(actual.country).toBe('ES');
|
|
108
|
-
expect(actual.city).toBe('
|
|
108
|
+
expect(actual.city).toBe('Madrid');
|
|
109
109
|
expect(actual.timezone).toBe('Europe/Madrid');
|
|
110
110
|
});
|
|
111
111
|
|
package/utils/updatedb.js
CHANGED
|
@@ -50,9 +50,9 @@ const databases = [{
|
|
|
50
50
|
src: [
|
|
51
51
|
'GeoLite2-Country-Locations-en.csv',
|
|
52
52
|
'GeoLite2-Country-Blocks-IPv4.csv',
|
|
53
|
-
'GeoLite2-Country-Blocks-IPv6.csv'
|
|
53
|
+
'GeoLite2-Country-Blocks-IPv6.csv',
|
|
54
54
|
],
|
|
55
|
-
dest: ['', 'geoip-country.dat', 'geoip-country6.dat']
|
|
55
|
+
dest: ['', 'geoip-country.dat', 'geoip-country6.dat'],
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
type: 'city',
|
|
@@ -62,9 +62,9 @@ const databases = [{
|
|
|
62
62
|
src: [
|
|
63
63
|
'GeoLite2-City-Locations-en.csv',
|
|
64
64
|
'GeoLite2-City-Blocks-IPv4.csv',
|
|
65
|
-
'GeoLite2-City-Blocks-IPv6.csv'
|
|
65
|
+
'GeoLite2-City-Blocks-IPv6.csv',
|
|
66
66
|
],
|
|
67
|
-
dest: ['geoip-city-names.dat', 'geoip-city.dat', 'geoip-city6.dat']
|
|
67
|
+
dest: ['geoip-city-names.dat', 'geoip-city.dat', 'geoip-city6.dat'],
|
|
68
68
|
}];
|
|
69
69
|
|
|
70
70
|
function mkdir(dirName) {
|
|
@@ -124,7 +124,7 @@ function getHTTPOptions(downloadUrl) {
|
|
|
124
124
|
protocol: parsedUrl.protocol,
|
|
125
125
|
host: parsedUrl.host,
|
|
126
126
|
path: parsedUrl.pathname + parsedUrl.search,
|
|
127
|
-
headers: { 'User-Agent': UserAgent }
|
|
127
|
+
headers: { 'User-Agent': UserAgent },
|
|
128
128
|
};
|
|
129
129
|
|
|
130
130
|
if (process.env.http_proxy || process.env.https_proxy) {
|