abler-api 0.1.65 → 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.
Files changed (2) hide show
  1. package/dist/cjs/pp-util.js +17 -13
  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
  * 获取与本机一起提供服务的所有主机
@@ -1485,10 +1489,10 @@ class apiUtil$2 {
1485
1489
  static async getConfigValue(options) {
1486
1490
  configNeeded();
1487
1491
  const params = options.replacements;
1488
- let item = params.item;
1489
- delete params.item;
1492
+ let cfgItem = params._cfgItem;
1493
+ delete params._cfgItem;
1490
1494
  if (await apiUtil$2.checkForwardsHost(options)) return true;
1491
- let c = apiUtil$2.parseCfgPath(item);
1495
+ let c = apiUtil$2.parseCfgPath(cfgItem);
1492
1496
  delete c.parent;
1493
1497
  c.host = ppUtil$4.getMyIp();
1494
1498
  return c;
@@ -1503,12 +1507,12 @@ class apiUtil$2 {
1503
1507
  static async setConfigValue(options) {
1504
1508
  configNeeded();
1505
1509
  const params = options.replacements;
1506
- let item = params.item;
1507
- delete params.item; // if (await checkForwardsHost(options))
1510
+ let cfgItem = params._cfgItem;
1511
+ delete params._cfgItem; // if (await checkForwardsHost(options))
1508
1512
  // return true;
1509
1513
 
1510
1514
  await apiUtil$2.parametersOK(params, "value");
1511
- let c = apiUtil$2.parseCfgPath(item);
1515
+ let c = apiUtil$2.parseCfgPath(cfgItem);
1512
1516
 
1513
1517
  if (typeof c.value === "object") {
1514
1518
  throw [err$2.ACCESS_REFUSED, `暂不支持修改复杂配置`];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abler-api",
3
- "version": "0.1.65",
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",