abler-api 0.1.66 → 0.1.68
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/dist/cjs/pp-util.js +31 -23
- package/package.json +1 -1
package/dist/cjs/pp-util.js
CHANGED
|
@@ -1083,17 +1083,21 @@ class apiUtil$2 {
|
|
|
1083
1083
|
|
|
1084
1084
|
|
|
1085
1085
|
static getClientIp(req) {
|
|
1086
|
-
|
|
1086
|
+
if (!req.hasOwnProperty("clientIp")) {
|
|
1087
|
+
let ip = req.headers["x-real-ip"] || req.headers["x-true-ip"] || req.headers['x-forwarded-for'] || req.headers['x-forward-for'] || req.connection.remoteAddress || req.socket.remoteAddress || req.headers['host'] || ""; // console.log("Request IP:", ip, "req: ", req);
|
|
1087
1088
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1089
|
+
if (ip.indexOf(",") >= 0) {
|
|
1090
|
+
ip = ip.split(',')[0];
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if (ip.indexOf(":") >= 0) {
|
|
1094
|
+
ip = ip.substring(ip.lastIndexOf(':') + 1);
|
|
1095
|
+
}
|
|
1091
1096
|
|
|
1092
|
-
|
|
1093
|
-
ip = ip.substring(ip.lastIndexOf(':') + 1);
|
|
1097
|
+
req.clientIp = ip;
|
|
1094
1098
|
}
|
|
1095
1099
|
|
|
1096
|
-
return
|
|
1100
|
+
return req.clientIp;
|
|
1097
1101
|
}
|
|
1098
1102
|
/**
|
|
1099
1103
|
* 获取与本机一起提供服务的所有主机
|
|
@@ -1639,25 +1643,29 @@ class preconditions$1 {
|
|
|
1639
1643
|
}
|
|
1640
1644
|
|
|
1641
1645
|
static async checkAll() {
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1646
|
+
try {
|
|
1647
|
+
// for (let i = 0; i < preconditions.checkFunctions.length; i++) {
|
|
1648
|
+
// const f = preconditions.checkFunctions[i];
|
|
1649
|
+
// // preconditions.addCheckPromise(f.check(f.args));
|
|
1650
|
+
// preconditions.pushMessage(await f.check(f.args));
|
|
1651
|
+
// }
|
|
1652
|
+
while (preconditions$1.checkFunctions.length > 0) {
|
|
1653
|
+
const f = preconditions$1.checkFunctions.shift();
|
|
1649
1654
|
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1655
|
+
if (preconditions$1.pushMessage(await f.check(f.args)) && f.blocked) {
|
|
1656
|
+
break;
|
|
1657
|
+
}
|
|
1658
|
+
} // for (let i = 0; i < preconditions.checkPromises.length; i++) {
|
|
1659
|
+
// preconditions.pushMessage(await preconditions.checkPromises[i]);
|
|
1660
|
+
// }
|
|
1656
1661
|
|
|
1657
1662
|
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1663
|
+
while (preconditions$1.checkPromises.length > 0) {
|
|
1664
|
+
const p = preconditions$1.checkPromises.shift();
|
|
1665
|
+
preconditions$1.pushMessage(await p);
|
|
1666
|
+
}
|
|
1667
|
+
} catch (e) {
|
|
1668
|
+
preconditions$1.pushMessage(e.message);
|
|
1661
1669
|
}
|
|
1662
1670
|
|
|
1663
1671
|
let text = "";
|