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.
- package/dist/cjs/pp-util.js +17 -13
- 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
|
* 获取与本机一起提供服务的所有主机
|
|
@@ -1485,10 +1489,10 @@ class apiUtil$2 {
|
|
|
1485
1489
|
static async getConfigValue(options) {
|
|
1486
1490
|
configNeeded();
|
|
1487
1491
|
const params = options.replacements;
|
|
1488
|
-
let
|
|
1489
|
-
delete params.
|
|
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(
|
|
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
|
|
1507
|
-
delete params.
|
|
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(
|
|
1515
|
+
let c = apiUtil$2.parseCfgPath(cfgItem);
|
|
1512
1516
|
|
|
1513
1517
|
if (typeof c.value === "object") {
|
|
1514
1518
|
throw [err$2.ACCESS_REFUSED, `暂不支持修改复杂配置`];
|