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.
Files changed (2) hide show
  1. package/dist/cjs/pp-util.js +31 -23
  2. package/package.json +1 -1
@@ -1083,17 +1083,21 @@ class apiUtil$2 {
1083
1083
 
1084
1084
 
1085
1085
  static getClientIp(req) {
1086
- 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);
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
- if (ip.indexOf(",") >= 0) {
1089
- ip = ip.split(',')[0];
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
- if (ip.indexOf(":") >= 0) {
1093
- ip = ip.substring(ip.lastIndexOf(':') + 1);
1097
+ req.clientIp = ip;
1094
1098
  }
1095
1099
 
1096
- return ip;
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
- // for (let i = 0; i < preconditions.checkFunctions.length; i++) {
1643
- // const f = preconditions.checkFunctions[i];
1644
- // // preconditions.addCheckPromise(f.check(f.args));
1645
- // preconditions.pushMessage(await f.check(f.args));
1646
- // }
1647
- while (preconditions$1.checkFunctions.length > 0) {
1648
- const f = preconditions$1.checkFunctions.shift();
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
- if (preconditions$1.pushMessage(await f.check(f.args)) && f.blocked) {
1651
- break;
1652
- }
1653
- } // for (let i = 0; i < preconditions.checkPromises.length; i++) {
1654
- // preconditions.pushMessage(await preconditions.checkPromises[i]);
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
- while (preconditions$1.checkPromises.length > 0) {
1659
- const p = preconditions$1.checkPromises.shift();
1660
- preconditions$1.pushMessage(await p);
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 = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abler-api",
3
- "version": "0.1.66",
3
+ "version": "0.1.68",
4
4
  "description": "API服务相关工具",
5
5
  "main": "./dist/cjs/pp-util.js",
6
6
  "-module": "./dist/es/pp-util.js",