ac-geoip 3.0.0 → 3.0.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/.github/workflows/node.js.yml +36 -0
- package/.ncurc.js +7 -0
- package/CHANGELOG.md +45 -0
- package/README.md +2 -0
- package/index.js +10 -6
- package/package.json +12 -9
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ master ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [16.x, 18.x]
|
|
20
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
21
|
+
redis-version: [6]
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v3
|
|
25
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
26
|
+
uses: actions/setup-node@v3
|
|
27
|
+
with:
|
|
28
|
+
node-version: ${{ matrix.node-version }}
|
|
29
|
+
|
|
30
|
+
- name: Start Redis
|
|
31
|
+
uses: supercharge/redis-github-action@1.4.0
|
|
32
|
+
with:
|
|
33
|
+
redis-version: ${{ matrix.redis-version }}
|
|
34
|
+
|
|
35
|
+
- run: yarn install
|
|
36
|
+
- run: yarn run test
|
package/.ncurc.js
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
<a name="3.0.3"></a>
|
|
2
|
+
|
|
3
|
+
## [3.0.3](https://github.com/admiralcloud/ac-geoip/compare/v3.0.2..v3.0.3) (2024-07-06 12:44:21)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fix
|
|
7
|
+
|
|
8
|
+
* **App:** Package updates | MP | [89c90ffb42fbc601449bff5c58d866bcdb11a28c](https://github.com/admiralcloud/ac-geoip/commit/89c90ffb42fbc601449bff5c58d866bcdb11a28c)
|
|
9
|
+
Replaced ip with ac-ip
|
|
10
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
11
|
+
<a name="3.0.2"></a>
|
|
12
|
+
|
|
13
|
+
## [3.0.2](https://github.com/admiralcloud/ac-geoip/compare/v3.0.1..v3.0.2) (2024-02-26 07:45:31)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fix
|
|
17
|
+
|
|
18
|
+
* **App:** Package updates | MP | [e6ab5710fa897109578b6f640fabde9773b3cc56](https://github.com/admiralcloud/ac-geoip/commit/e6ab5710fa897109578b6f640fabde9773b3cc56)
|
|
19
|
+
Package updates
|
|
20
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
21
|
+
<a name="3.0.1"></a>
|
|
22
|
+
|
|
23
|
+
## [3.0.1](https://github.com/admiralcloud/ac-geoip/compare/v3.0.0..v3.0.1) (2023-07-26 06:14:56)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fix
|
|
27
|
+
|
|
28
|
+
* **App:** Make cacheTime for NodeCache configurable | MP | [89a63cbf3ae6e1bbcc277bd1cd45348c314c9080](https://github.com/admiralcloud/ac-geoip/commit/89a63cbf3ae6e1bbcc277bd1cd45348c314c9080)
|
|
29
|
+
Make cacheTime for NodeCache configurable. It still defaults to 7 days.
|
|
30
|
+
Related issues: [/issues#undefined](https://github.com//issues/undefined)
|
|
31
|
+
### Documentation
|
|
32
|
+
|
|
33
|
+
* **App:** Added status badge from Github aciton | MP | [1b71085160da67310dc568e981625a3ca5a2efa0](https://github.com/admiralcloud/ac-geoip/commit/1b71085160da67310dc568e981625a3ca5a2efa0)
|
|
34
|
+
Added status badge from Github action
|
|
35
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
36
|
+
### Chores
|
|
37
|
+
|
|
38
|
+
* **App:** Updated packages | MP | [49d773010e3cb55ccdf0c6de6f9a9e8af17974fa](https://github.com/admiralcloud/ac-geoip/commit/49d773010e3cb55ccdf0c6de6f9a9e8af17974fa)
|
|
39
|
+
Updated packages
|
|
40
|
+
Related issues: [/issues#undefined](https://github.com//issues/undefined)
|
|
41
|
+
### Chores
|
|
42
|
+
|
|
43
|
+
* **App:** Added Github action for automated testing | MP | [2302e4a9c71c67ba2caa2ce89fa03e1a1a0c1459](https://github.com/admiralcloud/ac-geoip/commit/2302e4a9c71c67ba2caa2ce89fa03e1a1a0c1459)
|
|
44
|
+
Added Github action for automated testing
|
|
45
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
1
46
|
<a name="3.0.0"></a>
|
|
2
47
|
|
|
3
48
|
# [3.0.0](https://github.com/admiralcloud/ac-geoip/compare/v2.0.0..v3.0.0) (2022-12-18 08:36:22)
|
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@ GEOIP web service requires an account at Maxmind.
|
|
|
5
5
|
|
|
6
6
|
You can also use the Geolite2 database from Maxmind: https://dev.maxmind.com/geoip/geoip2/geolite2/
|
|
7
7
|
|
|
8
|
+
[](https://github.com/AdmiralCloud/ac-geoip/actions/workflows/node.js.yml)
|
|
9
|
+
|
|
8
10
|
## Usage
|
|
9
11
|
|
|
10
12
|
### Using Webservice
|
package/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
const _ = require('lodash')
|
|
2
|
-
const ipPackage = require('ip')
|
|
2
|
+
const ipPackage = require('ac-ip')
|
|
3
3
|
const fs = require('fs')
|
|
4
4
|
|
|
5
5
|
const WebServiceClient = require('@maxmind/geoip2-node').WebServiceClient
|
|
6
6
|
const Reader = require('@maxmind/geoip2-node').Reader
|
|
7
7
|
|
|
8
8
|
const NodeCache = require("node-cache")
|
|
9
|
-
const geoCache = new NodeCache({ stdTTL: 7 * 86400, checkperiod: 3600 })
|
|
10
9
|
|
|
11
10
|
const acgeoip = () => {
|
|
12
11
|
|
|
@@ -50,6 +49,11 @@ const acgeoip = () => {
|
|
|
50
49
|
geoip.geolite.reader = geoipReader
|
|
51
50
|
})
|
|
52
51
|
}
|
|
52
|
+
|
|
53
|
+
if (!_.has(params, 'redis')) {
|
|
54
|
+
geoip.geoCache = new NodeCache({ stdTTL: _.get(geoip, 'cacheTime'), checkperiod: 3600 })
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
const lookupLocal = async (params) => {
|
|
@@ -60,7 +64,7 @@ const acgeoip = () => {
|
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
const ip = _.get(params, 'ip')
|
|
63
|
-
if (ipPackage.
|
|
67
|
+
if (ipPackage.isPrivateIP(ip)) return
|
|
64
68
|
|
|
65
69
|
const mapping = _.get(params, 'mapping', geoip.mapping)
|
|
66
70
|
const debug = _.get(params, 'debug')
|
|
@@ -151,7 +155,7 @@ const acgeoip = () => {
|
|
|
151
155
|
throw Error(message)
|
|
152
156
|
}
|
|
153
157
|
const ip = _.get(params, 'ip')
|
|
154
|
-
if (ipPackage.
|
|
158
|
+
if (ipPackage.isPrivateIP(ip)) {
|
|
155
159
|
return
|
|
156
160
|
}
|
|
157
161
|
|
|
@@ -222,13 +226,13 @@ const acgeoip = () => {
|
|
|
222
226
|
const geoipResponse = _.get(params, 'geoipResponse')
|
|
223
227
|
const ip = _.get(params, 'ip')
|
|
224
228
|
const storageKey = _.get(geoip, 'environment') + ':geoip:' + ip
|
|
225
|
-
geoCache.set(storageKey, geoipResponse)
|
|
229
|
+
geoip.geoCache.set(storageKey, geoipResponse)
|
|
226
230
|
}
|
|
227
231
|
|
|
228
232
|
const getFromMemory = (params) => {
|
|
229
233
|
const ip = _.get(params, 'ip')
|
|
230
234
|
const storageKey = _.get(geoip, 'environment') + ':geoip:' + ip
|
|
231
|
-
return geoCache.get(storageKey)
|
|
235
|
+
return geoip.geoCache.get(storageKey)
|
|
232
236
|
}
|
|
233
237
|
|
|
234
238
|
const checkRedis = async (params) => {
|
package/package.json
CHANGED
|
@@ -3,24 +3,27 @@
|
|
|
3
3
|
"author": "Mark Poepping (https://www.admiralcloud.com)",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "admiralcloud/ac-geoip",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.3",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@maxmind/geoip2-node": "^
|
|
9
|
-
"ip": "^
|
|
8
|
+
"@maxmind/geoip2-node": "^5.0.0",
|
|
9
|
+
"ac-ip": "^4.0.0",
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
11
|
"node-cache": "^5.1.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"ac-semantic-release": "^0.
|
|
15
|
-
"chai": "^4.
|
|
16
|
-
"eslint": "^
|
|
17
|
-
"ioredis": "^5.
|
|
18
|
-
"mocha": "^10.
|
|
14
|
+
"ac-semantic-release": "^0.4.2",
|
|
15
|
+
"chai": "^4.4.1",
|
|
16
|
+
"eslint": "^9.6.0",
|
|
17
|
+
"ioredis": "^5.4.1",
|
|
18
|
+
"mocha": "^10.6.0"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"test": "./node_modules/.bin/mocha --bail --exit --slow 1000 ./test/test.js || :"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": ">=18.0"
|
|
25
|
+
},
|
|
26
|
+
"resolutions": {
|
|
27
|
+
"mocha/chokidar/braces": "^3.0.3"
|
|
25
28
|
}
|
|
26
29
|
}
|