abler-api 0.1.66 → 0.1.67

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.
@@ -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
  * 获取与本机一起提供服务的所有主机
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abler-api",
3
- "version": "0.1.66",
3
+ "version": "0.1.67",
4
4
  "description": "API服务相关工具",
5
5
  "main": "./dist/cjs/pp-util.js",
6
6
  "-module": "./dist/es/pp-util.js",