@abtnode/util 1.8.46 → 1.8.48
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/lib/get-ip.js +1 -1
- package/lib/is-ec2.js +9 -8
- package/package.json +5 -5
package/lib/get-ip.js
CHANGED
|
@@ -16,7 +16,7 @@ const getExternalIp = async ({ v6 = false, timeout = 5000 } = {}) => {
|
|
|
16
16
|
|
|
17
17
|
const getIP = async ({ includeV6 = false, timeout = 5000, includeExternal = true } = {}) => {
|
|
18
18
|
try {
|
|
19
|
-
if (isEC2()) {
|
|
19
|
+
if (await isEC2()) {
|
|
20
20
|
const [internal, external, internalV6, externalV6] = await Promise.all([
|
|
21
21
|
getEc2Meta('local-ipv4', timeout),
|
|
22
22
|
includeExternal ? getEc2Meta('public-ipv4', timeout) : '',
|
package/lib/is-ec2.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const axios = require('./axios');
|
|
2
2
|
|
|
3
3
|
// Whether we are running in an pre-baked image
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
4
|
+
// refer: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html
|
|
5
|
+
async function isEC2() {
|
|
6
|
+
try {
|
|
7
|
+
const url = 'http://169.254.169.254/latest/dynamic/instance-identity/document';
|
|
8
|
+
const { status } = await axios.get(url, { timeout: 1000 });
|
|
9
|
+
return status === 200;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
return false;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
module.exports = isEC2;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.48",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/logger": "1.8.
|
|
21
|
+
"@abtnode/constant": "1.8.48",
|
|
22
|
+
"@abtnode/logger": "1.8.48",
|
|
23
23
|
"@arcblock/jwt": "^1.18.31",
|
|
24
|
-
"@blocklet/constant": "1.8.
|
|
24
|
+
"@blocklet/constant": "1.8.48",
|
|
25
25
|
"@ocap/mcrypto": "1.18.31",
|
|
26
26
|
"@ocap/util": "1.18.31",
|
|
27
27
|
"@ocap/wallet": "1.18.31",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"fs-extra": "^10.1.0",
|
|
64
64
|
"jest": "^27.5.1"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "39979d7a059d5f97442ac7d46604391e6656ac8d"
|
|
67
67
|
}
|